Skip to content

Commit bd26cf7

Browse files
author
The Miri Cronjob Bot
committed
Merge ref 'f57b9e6f565a' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: f57b9e6 Filtered ref: dd835ad11d6c5cea520a087bb620e3643e2dbf0f Upstream diff: e8f3cfc...f57b9e6 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 9302232 + f57b9e6 commit bd26cf7

92 files changed

Lines changed: 9351 additions & 7452 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.

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,12 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {
330330
let mut e_flags: u32 = 0x0;
331331

332332
// Check if compression is enabled
333-
// `unstable_target_features` is used here because "zca" is gated behind riscv_target_feature.
334-
if sess.unstable_target_features.contains(&sym::zca) {
333+
if sess.target_features.contains(&sym::zca) {
335334
e_flags |= elf::EF_RISCV_RVC;
336335
}
337336

338337
// Check if RVTSO is enabled
339-
// `unstable_target_features` is used here because "ztso" is gated behind riscv_target_feature.
340-
if sess.unstable_target_features.contains(&sym::ztso) {
338+
if sess.target_features.contains(&sym::ztso) {
341339
e_flags |= elf::EF_RISCV_TSO;
342340
}
343341

compiler/rustc_hir/src/def.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -563,29 +563,6 @@ pub enum Res<Id = hir::HirId> {
563563
/// to get the underlying type.
564564
alias_to: DefId,
565565

566-
/// Whether the `Self` type is disallowed from mentioning generics (i.e. when used in an
567-
/// anonymous constant).
568-
///
569-
/// HACK(min_const_generics): self types also have an optional requirement to **not**
570-
/// mention any generic parameters to allow the following with `min_const_generics`:
571-
/// ```
572-
/// # struct Foo;
573-
/// impl Foo { fn test() -> [u8; size_of::<Self>()] { todo!() } }
574-
///
575-
/// struct Bar([u8; baz::<Self>()]);
576-
/// const fn baz<T>() -> usize { 10 }
577-
/// ```
578-
/// We do however allow `Self` in repeat expression even if it is generic to not break code
579-
/// which already works on stable while causing the `const_evaluatable_unchecked` future
580-
/// compat lint:
581-
/// ```
582-
/// fn foo<T>() {
583-
/// let _bar = [1_u8; size_of::<*mut T>()];
584-
/// }
585-
/// ```
586-
// FIXME(generic_const_exprs): Remove this bodge once that feature is stable.
587-
forbid_generic: bool,
588-
589566
/// Is this within an `impl Foo for bar`?
590567
is_trait_impl: bool,
591568
},
@@ -910,8 +887,8 @@ impl<Id> Res<Id> {
910887
Res::PrimTy(id) => Res::PrimTy(id),
911888
Res::Local(id) => Res::Local(map(id)),
912889
Res::SelfTyParam { trait_ } => Res::SelfTyParam { trait_ },
913-
Res::SelfTyAlias { alias_to, forbid_generic, is_trait_impl } => {
914-
Res::SelfTyAlias { alias_to, forbid_generic, is_trait_impl }
890+
Res::SelfTyAlias { alias_to, is_trait_impl } => {
891+
Res::SelfTyAlias { alias_to, is_trait_impl }
915892
}
916893
Res::ToolMod => Res::ToolMod,
917894
Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),
@@ -926,8 +903,8 @@ impl<Id> Res<Id> {
926903
Res::PrimTy(id) => Res::PrimTy(id),
927904
Res::Local(id) => Res::Local(map(id)?),
928905
Res::SelfTyParam { trait_ } => Res::SelfTyParam { trait_ },
929-
Res::SelfTyAlias { alias_to, forbid_generic, is_trait_impl } => {
930-
Res::SelfTyAlias { alias_to, forbid_generic, is_trait_impl }
906+
Res::SelfTyAlias { alias_to, is_trait_impl } => {
907+
Res::SelfTyAlias { alias_to, is_trait_impl }
931908
}
932909
Res::ToolMod => Res::ToolMod,
933910
Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
21492149
);
21502150
self.check_param_uses_if_mcg(tcx.types.self_param, span, false)
21512151
}
2152-
Res::SelfTyAlias { alias_to: def_id, forbid_generic: _, .. } => {
2152+
Res::SelfTyAlias { alias_to: def_id, .. } => {
21532153
// `Self` in impl (we know the concrete type).
21542154
assert_eq!(opt_self_ty, None);
21552155
// Try to evaluate any array length constants.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,15 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
559559
.filter_map(|(cnum, data)| data.used().then_some(cnum)),
560560
)
561561
},
562+
duplicate_crate_names: |tcx, c: CrateNum| {
563+
let name = tcx.crate_name(c);
564+
tcx.arena.alloc_from_iter(
565+
tcx.crates(())
566+
.into_iter()
567+
.filter(|k| tcx.crate_name(**k) == name && **k != c)
568+
.map(|c| *c),
569+
)
570+
},
562571
..providers.queries
563572
};
564573
provide_extern(&mut providers.extern_queries);

compiler/rustc_middle/src/query/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,7 @@ rustc_queries! {
23342334
eval_always
23352335
desc { "fetching all foreign CrateNum instances" }
23362336
}
2337+
23372338
// Crates that are loaded non-speculatively (not for diagnostics or doc links).
23382339
// FIXME: This is currently only used for collecting lang items, but should be used instead of
23392340
// `crates` in most other cases too.
@@ -2342,6 +2343,14 @@ rustc_queries! {
23422343
desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }
23432344
}
23442345

2346+
/// All crates that share the same name as crate `c`.
2347+
///
2348+
/// This normally occurs when multiple versions of the same dependency are present in the
2349+
/// dependency tree.
2350+
query duplicate_crate_names(c: CrateNum) -> &'tcx [CrateNum] {
2351+
desc { "fetching `CrateNum`s with same name as `{c:?}`" }
2352+
}
2353+
23452354
/// A list of all traits in a crate, used by rustdoc and error reporting.
23462355
query traits(_: CrateNum) -> &'tcx [DefId] {
23472356
desc { "fetching all traits in a crate" }

compiler/rustc_resolve/src/ident.rs

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
12861286
&mut self,
12871287
rib_index: usize,
12881288
rib_ident: Ident,
1289-
mut res: Res,
1289+
res: Res,
12901290
finalize: Option<Span>,
12911291
original_rib_ident_def: Ident,
12921292
all_ribs: &[Rib<'ra>],
@@ -1439,44 +1439,28 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14391439
}
14401440

14411441
RibKind::ConstantItem(trivial, _) => {
1442-
if let ConstantHasGenerics::No(cause) = trivial {
1443-
// HACK(min_const_generics): If we encounter `Self` in an anonymous
1444-
// constant we can't easily tell if it's generic at this stage, so
1445-
// we instead remember this and then enforce the self type to be
1446-
// concrete later on.
1447-
if let Res::SelfTyAlias {
1448-
alias_to: def,
1449-
forbid_generic: _,
1450-
is_trait_impl,
1451-
} = res
1452-
{
1453-
res = Res::SelfTyAlias {
1454-
alias_to: def,
1455-
forbid_generic: true,
1456-
is_trait_impl,
1457-
}
1458-
} else {
1459-
if let Some(span) = finalize {
1460-
let error = match cause {
1461-
NoConstantGenericsReason::IsEnumDiscriminant => {
1462-
ResolutionError::ParamInEnumDiscriminant {
1463-
name: rib_ident.name,
1464-
param_kind: ParamKindInEnumDiscriminant::Type,
1465-
}
1442+
if let ConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res, Res::SelfTyAlias { .. })
1444+
{
1445+
if let Some(span) = finalize {
1446+
let error = match cause {
1447+
NoConstantGenericsReason::IsEnumDiscriminant => {
1448+
ResolutionError::ParamInEnumDiscriminant {
1449+
name: rib_ident.name,
1450+
param_kind: ParamKindInEnumDiscriminant::Type,
14661451
}
1467-
NoConstantGenericsReason::NonTrivialConstArg => {
1468-
ResolutionError::ParamInNonTrivialAnonConst {
1469-
name: rib_ident.name,
1470-
param_kind:
1471-
ParamKindInNonTrivialAnonConst::Type,
1472-
}
1452+
}
1453+
NoConstantGenericsReason::NonTrivialConstArg => {
1454+
ResolutionError::ParamInNonTrivialAnonConst {
1455+
name: rib_ident.name,
1456+
param_kind: ParamKindInNonTrivialAnonConst::Type,
14731457
}
1474-
};
1475-
let _: ErrorGuaranteed = self.report_error(span, error);
1476-
}
1477-
1478-
return Res::Err;
1458+
}
1459+
};
1460+
let _: ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
return Res::Err;
14801464
}
14811465

14821466
continue;

compiler/rustc_resolve/src/late.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,11 +2655,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
26552655
|this| {
26562656
let item_def_id = this.r.local_def_id(item.id).to_def_id();
26572657
this.with_self_rib(
2658-
Res::SelfTyAlias {
2659-
alias_to: item_def_id,
2660-
forbid_generic: false,
2661-
is_trait_impl: false,
2662-
},
2658+
Res::SelfTyAlias { alias_to: item_def_id, is_trait_impl: false },
26632659
|this| {
26642660
visit::walk_item(this, item);
26652661
},
@@ -3368,8 +3364,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
33683364
let item_def_id = item_def_id.to_def_id();
33693365
let res = Res::SelfTyAlias {
33703366
alias_to: item_def_id,
3371-
forbid_generic: false,
3372-
is_trait_impl: trait_id.is_some()
3367+
is_trait_impl: trait_id.is_some(),
33733368
};
33743369
this.with_self_rib(res, |this| {
33753370
if let Some(of_trait) = of_trait {

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,8 @@ symbols! {
17881788
ptr_slice_from_raw_parts_mut,
17891789
ptr_swap,
17901790
ptr_swap_nonoverlapping,
1791+
ptr_without_provenance,
1792+
ptr_without_provenance_mut,
17911793
ptr_write,
17921794
ptr_write_bytes,
17931795
ptr_write_unaligned,

compiler/rustc_target/src/target_features.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
588588
static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
589589
// tidy-alphabetical-start
590590
("a", Stable, &["zaamo", "zalrsc"]),
591-
("b", Unstable(sym::riscv_target_feature), &["zba", "zbb", "zbs"]),
591+
("b", Stable, &["zba", "zbb", "zbs"]),
592592
("c", Stable, &["zca"]),
593593
("d", Unstable(sym::riscv_target_feature), &["f"]),
594594
("e", Unstable(sym::riscv_target_feature), &[]),
@@ -646,24 +646,24 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
646646
("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
647647
("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
648648
("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
649-
("za64rs", Unstable(sym::riscv_target_feature), &["za128rs"]), // Za64rs ⊃ Za128rs
650-
("za128rs", Unstable(sym::riscv_target_feature), &[]),
651-
("zaamo", Unstable(sym::riscv_target_feature), &[]),
652-
("zabha", Unstable(sym::riscv_target_feature), &["zaamo"]),
653-
("zacas", Unstable(sym::riscv_target_feature), &["zaamo"]),
654-
("zalrsc", Unstable(sym::riscv_target_feature), &[]),
655-
("zama16b", Unstable(sym::riscv_target_feature), &[]),
656-
("zawrs", Unstable(sym::riscv_target_feature), &[]),
649+
("za64rs", Stable, &["za128rs"]), // Za64rs ⊃ Za128rs
650+
("za128rs", Stable, &[]),
651+
("zaamo", Stable, &[]),
652+
("zabha", Stable, &["zaamo"]),
653+
("zacas", Stable, &["zaamo"]),
654+
("zalrsc", Stable, &[]),
655+
("zama16b", Stable, &[]),
656+
("zawrs", Stable, &[]),
657657
("zba", Stable, &[]),
658658
("zbb", Stable, &[]),
659659
("zbc", Stable, &["zbkc"]), // Zbc ⊃ Zbkc
660660
("zbkb", Stable, &[]),
661661
("zbkc", Stable, &[]),
662662
("zbkx", Stable, &[]),
663663
("zbs", Stable, &[]),
664-
("zca", Unstable(sym::riscv_target_feature), &[]),
665-
("zcb", Unstable(sym::riscv_target_feature), &["zca"]),
666-
("zcmop", Unstable(sym::riscv_target_feature), &["zca"]),
664+
("zca", Stable, &[]),
665+
("zcb", Stable, &["zca"]),
666+
("zcmop", Stable, &["zca"]),
667667
("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
668668
("zfa", Unstable(sym::riscv_target_feature), &["f"]),
669669
("zfbfmin", Unstable(sym::riscv_target_feature), &["f"]), // and a subset of Zfhmin
@@ -672,22 +672,22 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
672672
("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
673673
("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
674674
("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
675-
("zic64b", Unstable(sym::riscv_target_feature), &[]),
676-
("zicbom", Unstable(sym::riscv_target_feature), &[]),
677-
("zicbop", Unstable(sym::riscv_target_feature), &[]),
678-
("zicboz", Unstable(sym::riscv_target_feature), &[]),
679-
("ziccamoa", Unstable(sym::riscv_target_feature), &[]),
680-
("ziccif", Unstable(sym::riscv_target_feature), &[]),
681-
("zicclsm", Unstable(sym::riscv_target_feature), &[]),
682-
("ziccrse", Unstable(sym::riscv_target_feature), &[]),
683-
("zicntr", Unstable(sym::riscv_target_feature), &["zicsr"]),
684-
("zicond", Unstable(sym::riscv_target_feature), &[]),
685-
("zicsr", Unstable(sym::riscv_target_feature), &[]),
686-
("zifencei", Unstable(sym::riscv_target_feature), &[]),
687-
("zihintntl", Unstable(sym::riscv_target_feature), &[]),
688-
("zihintpause", Unstable(sym::riscv_target_feature), &[]),
689-
("zihpm", Unstable(sym::riscv_target_feature), &["zicsr"]),
690-
("zimop", Unstable(sym::riscv_target_feature), &[]),
675+
("zic64b", Stable, &[]),
676+
("zicbom", Stable, &[]),
677+
("zicbop", Stable, &[]),
678+
("zicboz", Stable, &[]),
679+
("ziccamoa", Stable, &[]),
680+
("ziccif", Stable, &[]),
681+
("zicclsm", Stable, &[]),
682+
("ziccrse", Stable, &[]),
683+
("zicntr", Stable, &["zicsr"]),
684+
("zicond", Stable, &[]),
685+
("zicsr", Stable, &[]),
686+
("zifencei", Stable, &[]),
687+
("zihintntl", Stable, &[]),
688+
("zihintpause", Stable, &[]),
689+
("zihpm", Stable, &["zicsr"]),
690+
("zimop", Stable, &[]),
691691
("zk", Stable, &["zkn", "zkr", "zkt"]),
692692
("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
693693
("zknd", Stable, &["zkne_or_zknd"]),
@@ -699,7 +699,7 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
699699
("zksed", Stable, &[]),
700700
("zksh", Stable, &[]),
701701
("zkt", Stable, &[]),
702-
("ztso", Unstable(sym::riscv_target_feature), &[]),
702+
("ztso", Stable, &[]),
703703
("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]), // Zvbb ⊃ Zvkb
704704
("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
705705
("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use rustc_middle::ty::{
3333
TypeVisitableExt, Upcast,
3434
};
3535
use rustc_middle::{bug, span_bug};
36+
use rustc_span::def_id::CrateNum;
3637
use rustc_span::{BytePos, DUMMY_SP, STDLIB_STABLE_CRATES, Span, Symbol, sym};
3738
use tracing::{debug, instrument};
3839

@@ -1287,10 +1288,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
12871288
self.tcx.def_span(def.did()),
12881289
format!("`{self_ty}` needs to implement `From<{ty}>`"),
12891290
);
1290-
err.span_note(
1291-
self.tcx.def_span(found.did()),
1292-
format!("alternatively, `{ty}` needs to implement `Into<{self_ty}>`"),
1293-
);
12941291
}
12951292
(ty::Adt(def, _), None) if def.did().is_local() => {
12961293
let trait_path = self.tcx.short_string(
@@ -2172,6 +2169,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21722169
self.suggest_function_pointers_impl(None, &exp_found, err);
21732170
}
21742171

2172+
if let ty::Adt(def, _) = trait_pred.self_ty().skip_binder().peel_refs().kind()
2173+
&& let crates = self.tcx.duplicate_crate_names(def.did().krate)
2174+
&& !crates.is_empty()
2175+
{
2176+
self.note_two_crate_versions(def.did().krate, MultiSpan::new(), err);
2177+
err.help("you can use `cargo tree` to explore your dependency tree");
2178+
}
21752179
true
21762180
})
21772181
}) {
@@ -2282,6 +2286,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
22822286
}
22832287
));
22842288
}
2289+
2290+
if let ty::Adt(def, _) = trait_pred.self_ty().skip_binder().peel_refs().kind()
2291+
&& let crates = self.tcx.duplicate_crate_names(def.did().krate)
2292+
&& !crates.is_empty()
2293+
{
2294+
self.note_two_crate_versions(def.did().krate, MultiSpan::new(), err);
2295+
err.help("you can use `cargo tree` to explore your dependency tree");
2296+
}
22852297
true
22862298
};
22872299

@@ -2445,11 +2457,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
24452457

24462458
pub fn note_two_crate_versions(
24472459
&self,
2448-
did: DefId,
2460+
krate: CrateNum,
24492461
sp: impl Into<MultiSpan>,
24502462
err: &mut Diag<'_>,
24512463
) {
2452-
let crate_name = self.tcx.crate_name(did.krate);
2464+
let crate_name = self.tcx.crate_name(krate);
24532465
let crate_msg = format!(
24542466
"there are multiple different versions of crate `{crate_name}` in the dependency graph"
24552467
);
@@ -2514,7 +2526,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
25142526

25152527
for (similar_item, _) in similar_items {
25162528
err.span_help(self.tcx.def_span(similar_item), "item with same name found");
2517-
self.note_two_crate_versions(similar_item, MultiSpan::new(), err);
2529+
self.note_two_crate_versions(similar_item.krate, MultiSpan::new(), err);
25182530
}
25192531
}
25202532

0 commit comments

Comments
 (0)