Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7e4c9ee

Browse files
committed
Auto merge of rust-lang#90151 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backports * Don't emit a warning for empty rmeta files. rust-lang#90072 * Erase late-bound regions before computing vtable debuginfo name. rust-lang#90050 * Fix wrong niche calculation when 2+ niches are placed at the start rust-lang#90040 * Revert rust-lang#86011 to fix an incorrect bound check rust-lang#90025 * Fix macro_rules! duplication when reexported in the same module rust-lang#89867 * Bump cargo to include rust-lang/cargo#9979 - Fix fetching git repos after a force push. r? `@Mark-Simulacrum`
2 parents d464727 + 88e4e0e commit 7e4c9ee

30 files changed

+167
-84
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,14 +480,11 @@ pub fn compute_debuginfo_vtable_name<'tcx>(
480480
}
481481

482482
if let Some(trait_ref) = trait_ref {
483-
push_item_name(tcx, trait_ref.skip_binder().def_id, true, &mut vtable_name);
483+
let trait_ref =
484+
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), trait_ref);
485+
push_item_name(tcx, trait_ref.def_id, true, &mut vtable_name);
484486
visited.clear();
485-
push_generic_params_internal(
486-
tcx,
487-
trait_ref.skip_binder().substs,
488-
&mut vtable_name,
489-
&mut visited,
490-
);
487+
push_generic_params_internal(tcx, trait_ref.substs, &mut vtable_name, &mut visited);
491488
} else {
492489
vtable_name.push_str("_");
493490
}

compiler/rustc_metadata/src/locator.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,15 @@ impl<'a> CrateLocator<'a> {
529529
let mut err_data: Option<Vec<PathBuf>> = None;
530530
for (lib, kind) in m {
531531
info!("{} reading metadata from: {}", flavor, lib.display());
532+
if flavor == CrateFlavor::Rmeta && lib.metadata().map_or(false, |m| m.len() == 0) {
533+
// Empty files will cause get_metadata_section to fail. Rmeta
534+
// files can be empty, for example with binaries (which can
535+
// often appear with `cargo check` when checking a library as
536+
// a unittest). We don't want to emit a user-visible warning
537+
// in this case as it is not a real problem.
538+
debug!("skipping empty file");
539+
continue;
540+
}
532541
let (hash, metadata) =
533542
match get_metadata_section(self.target, flavor, &lib, self.metadata_loader) {
534543
Ok(blob) => {

compiler/rustc_target/src/abi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ impl Niche {
11171117
// In practice this means that enums with `count > 1` are unlikely to claim niche zero, since they have to fit perfectly.
11181118
// If niche zero is already reserved, the selection of bounds are of little interest.
11191119
let move_start = |v: WrappingRange| {
1120-
let start = v.start.wrapping_sub(1) & max_value;
1120+
let start = v.start.wrapping_sub(count) & max_value;
11211121
Some((start, Scalar { value, valid_range: v.with_start(start) }))
11221122
};
11231123
let move_end = |v: WrappingRange| {

compiler/rustc_typeck/src/bounds.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ impl<'tcx> Bounds<'tcx> {
6464
})
6565
});
6666

67-
self.region_bounds
68-
.iter()
69-
.map(|&(region_bound, span)| {
67+
sized_predicate
68+
.into_iter()
69+
.chain(self.region_bounds.iter().map(|&(region_bound, span)| {
7070
(
7171
region_bound
7272
.map_bound(|region_bound| ty::OutlivesPredicate(param_ty, region_bound))
7373
.to_predicate(tcx),
7474
span,
7575
)
76-
})
76+
}))
7777
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
7878
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
7979
(predicate, span)
@@ -83,7 +83,6 @@ impl<'tcx> Bounds<'tcx> {
8383
.iter()
8484
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
8585
)
86-
.chain(sized_predicate.into_iter())
8786
.collect()
8887
}
8988
}

src/librustdoc/visit_ast.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,21 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
8787
// the rexport defines the path that a user will actually see. Accordingly,
8888
// we add the rexport as an item here, and then skip over the original
8989
// definition in `visit_item()` below.
90+
//
91+
// We also skip `#[macro_export] macro_rules!` that have already been inserted,
92+
// it can happen if within the same module a `#[macro_export] macro_rules!`
93+
// is declared but also a reexport of itself producing two exports of the same
94+
// macro in the same module.
95+
let mut inserted = FxHashSet::default();
9096
for export in self.cx.tcx.module_exports(CRATE_DEF_ID).unwrap_or(&[]) {
9197
if let Res::Def(DefKind::Macro(_), def_id) = export.res {
9298
if let Some(local_def_id) = def_id.as_local() {
9399
if self.cx.tcx.has_attr(def_id, sym::macro_export) {
94-
let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
95-
let item = self.cx.tcx.hir().expect_item(hir_id);
96-
top_level_module.items.push((item, None));
100+
if inserted.insert(def_id) {
101+
let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
102+
let item = self.cx.tcx.hir().expect_item(hir_id);
103+
top_level_module.items.push((item, None));
104+
}
97105
}
98106
}
99107
}

src/test/codegen/debug-vtable.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
// MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, _>::vtable$"
1919
// CHECK: !DISubrange(count: 3
2020

21+
// NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::bar::{closure#0} as core::ops::function::FnOnce<(core::option::Option<&dyn core::ops::function::Fn<(), Output=()>>)>>::{vtable}"
22+
// MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::bar::closure$0, core::ops::function::FnOnce<tuple$<enum$<core::option::Option<ref$<dyn$<core::ops::function::Fn<tuple$<>,assoc$<Output,tuple$<> > > > > >, {{.*}}, {{.*}}, Some> > > >::vtable$"
23+
2124
#![crate_type = "lib"]
2225

2326
pub struct Foo;
@@ -45,3 +48,10 @@ pub fn foo(x: &Foo) -> (u32, (u64, i8), &dyn Send) {
4548
let z: &dyn SomeTraitWithGenerics<u64, i8> = x;
4649
(y.method1(), z.method1(), x as &dyn Send)
4750
}
51+
52+
// Constructing the debuginfo name for the FnOnce vtable below initially caused an ICE on MSVC
53+
// because the trait type contains a late bound region that needed to be erased before the type
54+
// layout for the niche enum `Option<&dyn Fn()>` could be computed.
55+
pub fn bar() -> Box<dyn FnOnce(Option<&dyn Fn()>)> {
56+
Box::new(|_x: Option<&dyn Fn()>| {})
57+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// edition:2018
2+
3+
#![no_core]
4+
#![feature(no_core)]
5+
6+
// @count macro.json "$.index[*][?(@.name=='macro')].inner.items[*]" 2
7+
8+
// @set repro_id = macro.json "$.index[*][?(@.name=='repro')].id"
9+
// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id
10+
#[macro_export]
11+
macro_rules! repro {
12+
() => {};
13+
}
14+
15+
// @set repro2_id = macro.json "$.index[*][?(@.inner.name=='repro2')].id"
16+
// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro2_id
17+
pub use crate::repro as repro2;

src/test/rustdoc/issue-89852.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// edition:2018
2+
3+
#![no_core]
4+
#![feature(no_core)]
5+
6+
// @matches 'issue_89852/sidebar-items.js' '"repro"'
7+
// @!matches 'issue_89852/sidebar-items.js' '"repro".*"repro"'
8+
9+
#[macro_export]
10+
macro_rules! repro {
11+
() => {};
12+
}
13+
14+
pub use crate::repro as repro2;

src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: required by a bound in `std::hash::Hash::hash`
1111
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
1212
|
1313
LL | fn hash<H: Hasher>(&self, state: &mut H);
14-
| ^^^^^^ required by this bound in `std::hash::Hash::hash`
14+
| ^ required by this bound in `std::hash::Hash::hash`
1515
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
1616

1717
error: aborting due to previous error

src/test/ui/derives/derives-span-Hash-enum.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: required by a bound in `std::hash::Hash::hash`
1111
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
1212
|
1313
LL | fn hash<H: Hasher>(&self, state: &mut H);
14-
| ^^^^^^ required by this bound in `std::hash::Hash::hash`
14+
| ^ required by this bound in `std::hash::Hash::hash`
1515
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
1616

1717
error: aborting due to previous error

0 commit comments

Comments
 (0)