Skip to content

Commit 758e962

Browse files
committed
Auto merge of #160388 - JonathanBrouwer:rollup-SYNLyMf, r=<try>
Rollup of 12 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-*
2 parents 8c3a200 + 7dbc70f commit 758e962

119 files changed

Lines changed: 3396 additions & 697 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3760,7 +3760,6 @@ dependencies = [
37603760
"rustc_session",
37613761
"rustc_span",
37623762
"rustc_trait_selection",
3763-
"rustc_traits",
37643763
"smallvec",
37653764
"tracing",
37663765
]

compiler/rustc_borrowck/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
2222
rustc_session = { path = "../rustc_session" }
2323
rustc_span = { path = "../rustc_span" }
2424
rustc_trait_selection = { path = "../rustc_trait_selection" }
25-
rustc_traits = { path = "../rustc_traits" }
2625
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2726
tracing = "0.1"
2827
# tidy-alphabetical-end

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use rustc_span::Span;
2020
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
2121
use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
2222
use rustc_trait_selection::traits::ObligationCtxt;
23-
use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause};
23+
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::type_op_ascribe_user_type_with_span;
24+
use rustc_trait_selection::traits::query::type_op::prove_predicate::type_op_prove_predicate_with_cause;
2425
use tracing::{debug, instrument};
2526

2627
use crate::MirBorrowckCtxt;

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
260260

261261
// Indicates that local is set to a new value. The `layout` and `projection` are used to
262262
// calculate the offset.
263-
pub(crate) fn debug_new_val_to_local(
263+
fn debug_new_val_to_local(
264264
&self,
265265
bx: &mut Bx,
266266
local: mir::Local,
@@ -297,7 +297,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
297297
}
298298
}
299299

300-
pub(crate) fn debug_poison_to_local(&self, bx: &mut Bx, local: mir::Local) {
300+
fn debug_poison_to_local(&self, bx: &mut Bx, local: mir::Local) {
301301
let ty = self.monomorphize(self.mir.local_decls[local].ty);
302302
let layout = bx.cx().layout_of(ty);
303303
let to_backend_ty = bx.cx().immediate_backend_type(layout);
@@ -692,6 +692,55 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
692692
Some((per_local, constants))
693693
}
694694

695+
pub(crate) fn codegen_stmt_debuginfo(
696+
&mut self,
697+
bx: &mut Bx,
698+
debuginfo: &mir::StmtDebugInfo<'tcx>,
699+
) {
700+
match debuginfo {
701+
mir::StmtDebugInfo::AssignRef(dest, place) => {
702+
let local_ref = match self.locals[place.local] {
703+
// For an rvalue like `&(_1.1)`, when `BackendRepr` is `BackendRepr::Memory`, we allocate a block of memory to this place.
704+
// The place is an indirect pointer, we can refer to it directly.
705+
LocalRef::Place(place_ref) => Some((place_ref, place.projection.as_slice())),
706+
// For an rvalue like `&((*_1).1)`, we are calculating the address of `_1.1`.
707+
// The deref projection is no-op here.
708+
LocalRef::Operand(operand_ref) if place.is_indirect_first_projection() => {
709+
Some((operand_ref.deref(bx.cx()), &place.projection[1..]))
710+
}
711+
// For an rvalue like `&1`, when `BackendRepr` is `BackendRepr::Scalar`,
712+
// we cannot get the address.
713+
// N.B. `non_ssa_locals` returns that this is an SSA local.
714+
LocalRef::Operand(_) => None,
715+
LocalRef::UnsizedPlace(_) | LocalRef::PendingOperand => None,
716+
}
717+
.filter(|(_, projection)| {
718+
// Drop unsupported projections.
719+
projection.iter().all(|p| p.can_use_in_debuginfo())
720+
});
721+
if let Some((base, projection)) = local_ref {
722+
self.debug_new_val_to_local(bx, *dest, base, projection);
723+
} else {
724+
// If the address cannot be calculated, use poison to indicate that the value has been optimized out.
725+
self.debug_poison_to_local(bx, *dest);
726+
}
727+
}
728+
mir::StmtDebugInfo::InvalidAssign(local) => {
729+
self.debug_poison_to_local(bx, *local);
730+
}
731+
}
732+
}
733+
734+
pub(crate) fn codegen_stmt_debuginfos(
735+
&mut self,
736+
bx: &mut Bx,
737+
debuginfos: &[mir::StmtDebugInfo<'tcx>],
738+
) {
739+
for debuginfo in debuginfos {
740+
self.codegen_stmt_debuginfo(bx, debuginfo);
741+
}
742+
}
743+
695744
/// Creates the function-specific debug context.
696745
///
697746
/// Returns the FunctionDebugContext for the function which holds state needed

compiler/rustc_codegen_ssa/src/mir/statement.rs

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_middle::mir::{self, NonDivergingIntrinsic, StmtDebugInfo};
1+
use rustc_middle::mir::{self, NonDivergingIntrinsic};
22
use rustc_middle::{bug, span_bug, ty};
33
use tracing::instrument;
44

@@ -121,49 +121,4 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
121121
| mir::StatementKind::Nop => {}
122122
}
123123
}
124-
125-
pub(crate) fn codegen_stmt_debuginfo(&mut self, bx: &mut Bx, debuginfo: &StmtDebugInfo<'tcx>) {
126-
match debuginfo {
127-
StmtDebugInfo::AssignRef(dest, place) => {
128-
let local_ref = match self.locals[place.local] {
129-
// For an rvalue like `&(_1.1)`, when `BackendRepr` is `BackendRepr::Memory`, we allocate a block of memory to this place.
130-
// The place is an indirect pointer, we can refer to it directly.
131-
LocalRef::Place(place_ref) => Some((place_ref, place.projection.as_slice())),
132-
// For an rvalue like `&((*_1).1)`, we are calculating the address of `_1.1`.
133-
// The deref projection is no-op here.
134-
LocalRef::Operand(operand_ref) if place.is_indirect_first_projection() => {
135-
Some((operand_ref.deref(bx.cx()), &place.projection[1..]))
136-
}
137-
// For an rvalue like `&1`, when `BackendRepr` is `BackendRepr::Scalar`,
138-
// we cannot get the address.
139-
// N.B. `non_ssa_locals` returns that this is an SSA local.
140-
LocalRef::Operand(_) => None,
141-
LocalRef::UnsizedPlace(_) | LocalRef::PendingOperand => None,
142-
}
143-
.filter(|(_, projection)| {
144-
// Drop unsupported projections.
145-
projection.iter().all(|p| p.can_use_in_debuginfo())
146-
});
147-
if let Some((base, projection)) = local_ref {
148-
self.debug_new_val_to_local(bx, *dest, base, projection);
149-
} else {
150-
// If the address cannot be calculated, use poison to indicate that the value has been optimized out.
151-
self.debug_poison_to_local(bx, *dest);
152-
}
153-
}
154-
StmtDebugInfo::InvalidAssign(local) => {
155-
self.debug_poison_to_local(bx, *local);
156-
}
157-
}
158-
}
159-
160-
pub(crate) fn codegen_stmt_debuginfos(
161-
&mut self,
162-
bx: &mut Bx,
163-
debuginfos: &[StmtDebugInfo<'tcx>],
164-
) {
165-
for debuginfo in debuginfos {
166-
self.codegen_stmt_debuginfo(bx, debuginfo);
167-
}
168-
}
169124
}

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ declare_features! (
663663
/// Allows `mut ref` and `mut ref mut` identifier patterns.
664664
(incomplete, mut_ref, "1.79.0", Some(123076)),
665665
/// Allows `mut(crate) field: Type` restrictions.
666-
(incomplete, mut_restriction, "1.98.0", Some(105077)),
666+
(unstable, mut_restriction, "CURRENT_RUSTC_VERSION", Some(105077)),
667667
/// Allows using `#[naked]` on `extern "Rust"` functions.
668668
(unstable, naked_functions_rustic_abi, "1.88.0", Some(138997)),
669669
/// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions.

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,12 @@ fn lower_variant<'tcx>(
835835
did: f.def_id.to_def_id(),
836836
name: f.ident.name,
837837
vis: tcx.visibility(f.def_id),
838+
mut_restriction: match f.mut_restriction.kind {
839+
hir::RestrictionKind::Unrestricted => ty::RestrictionKind::Unrestricted,
840+
hir::RestrictionKind::Restricted(path) => {
841+
ty::RestrictionKind::Restricted(path.res, f.mut_restriction.span)
842+
}
843+
},
838844
safety: f.safety,
839845
value: f.default.map(|v| v.def_id.to_def_id()),
840846
})
@@ -926,19 +932,16 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
926932
false,
927933
is_auto == hir::IsAuto::Yes,
928934
safety,
929-
if let hir::RestrictionKind::Restricted(path) = impl_restriction.kind {
930-
ty::trait_def::ImplRestrictionKind::Restricted(path.res, impl_restriction.span)
931-
} else {
932-
ty::trait_def::ImplRestrictionKind::Unrestricted
935+
match impl_restriction.kind {
936+
hir::RestrictionKind::Restricted(path) => {
937+
ty::RestrictionKind::Restricted(path.res, impl_restriction.span)
938+
}
939+
hir::RestrictionKind::Unrestricted => ty::RestrictionKind::Unrestricted,
933940
},
934941
),
935-
hir::ItemKind::TraitAlias(constness, ..) => (
936-
constness,
937-
true,
938-
false,
939-
hir::Safety::Safe,
940-
ty::trait_def::ImplRestrictionKind::Unrestricted,
941-
),
942+
hir::ItemKind::TraitAlias(constness, ..) => {
943+
(constness, true, false, hir::Safety::Safe, ty::RestrictionKind::Unrestricted)
944+
}
942945
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
943946
};
944947

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use rustc_hir::diagnostic_items::DiagnosticItems;
2424
use rustc_index::Idx;
2525
use rustc_middle::middle::lib_features::LibFeatures;
2626
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
27-
use rustc_middle::ty::Visibility;
2827
use rustc_middle::ty::codec::TyDecoder;
28+
use rustc_middle::ty::{RestrictionKind, Visibility};
2929
use rustc_middle::{bug, implement_ty_decoder};
3030
use rustc_proc_macro::bridge::client::Client as ProcMacroClient;
3131
use rustc_serialize::opaque::MemDecoder;
@@ -1145,6 +1145,7 @@ impl CrateMetadata {
11451145
did,
11461146
name: self.item_name(did.index),
11471147
vis: self.get_visibility(tcx, did.index),
1148+
mut_restriction: self.get_mut_restriction(tcx, did.index),
11481149
safety: self.get_safety(did.index),
11491150
value: self.get_default_field(tcx, did.index),
11501151
})
@@ -1207,6 +1208,15 @@ impl CrateMetadata {
12071208
.map_id(|index| ModId::new_unchecked(self.local_def_id(index)))
12081209
}
12091210

1211+
fn get_mut_restriction(&self, tcx: TyCtxt<'_>, id: DefIndex) -> RestrictionKind {
1212+
self.root
1213+
.tables
1214+
.mut_restriction
1215+
.get(self, id)
1216+
.unwrap_or_else(|| self.missing("mut_restriction", id))
1217+
.decode((self, tcx))
1218+
}
1219+
12101220
fn get_safety(&self, id: DefIndex) -> Safety {
12111221
self.root.tables.safety.get(self, id)
12121222
}

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,14 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
501501
}
502502

503503
if let Some(def_id) = child.res.opt_def_id() {
504+
let mut fallback = false;
505+
504506
if child.ident.name == kw::Underscore {
505-
fallback_map.push((def_id, parent));
506-
return;
507+
fallback = true;
507508
}
508509

509510
if tcx.is_doc_hidden(parent) {
510-
fallback_map.push((def_id, parent));
511-
return;
511+
fallback = true;
512512
}
513513

514514
// If the re-export itself is `#[doc(hidden)]`, deprioritize it.
@@ -519,20 +519,30 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
519519
.and_then(|r| r.id())
520520
.is_some_and(|id| tcx.is_doc_hidden(id))
521521
{
522-
fallback_map.push((def_id, parent));
523-
return;
522+
fallback = true;
524523
}
525524

526525
match visible_parent_map.entry(def_id) {
527526
Entry::Occupied(mut entry) => {
528-
// If `child` is defined in crate `cnum`, ensure
529-
// that it is mapped to a parent in `cnum`.
530-
if def_id.is_local() && entry.get().is_local() {
531-
entry.insert(parent);
527+
if !fallback {
528+
// If `child` is defined in crate `cnum`, ensure
529+
// that it is mapped to a parent in `cnum`.
530+
if def_id.is_local() && entry.get().is_local() {
531+
entry.insert(parent);
532+
}
532533
}
533534
}
534535
Entry::Vacant(entry) => {
535-
entry.insert(parent);
536+
if fallback {
537+
// We do all of the same steps to fallback entries as to
538+
// preferred entries, except for recording them in a separate map.
539+
// It is important to not return early in the fallback cases to
540+
// ensure that we extend the BFS to the children of fallback items.
541+
fallback_map.push((def_id, parent));
542+
} else {
543+
entry.insert(parent);
544+
}
545+
536546
if child.res.module_like_def_id().is_some() {
537547
bfs_queue.push_back(def_id);
538548
}

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16981698

16991699
for field in &variant.fields {
17001700
self.tables.safety.set(field.did.index, field.safety);
1701+
record!(
1702+
self.tables.mut_restriction[field.did] <- field.mut_restriction
1703+
);
17011704
}
17021705

17031706
if let Some((CtorKind::Fn, ctor_def_id)) = variant.ctor {

0 commit comments

Comments
 (0)