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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
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
letmut 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
&mutself,
12871287
rib_index:usize,
12881288
rib_ident:Ident,
1289-
mutres: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-
ifletConstantHasGenerics::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-
ifletRes::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-
ifletSome(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+
ifletConstantHasGenerics::No(cause) = trivial
1443+
&& !matches!(res,Res::SelfTyAlias{ .. })
1444+
{
1445+
ifletSome(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-
returnRes::Err;
1458+
}
1459+
};
1460+
let _:ErrorGuaranteed = self.report_error(span, error);
14791461
}
1462+
1463+
returnRes::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
ifletSome(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
staticRISCV_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+
iflet 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+
iflet 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
pubfnnote_two_crate_versions(
24472459
&self,
2448-
did:DefId,
2460+
krate:CrateNum,
24492461
sp:implInto<MultiSpan>,
24502462
err:&mutDiag<'_>,
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)