Skip to content

Commit f3d2eee

Browse files
committed
Auto merge of #158268 - JonathanBrouwer:rollup-gqPk01p, r=JonathanBrouwer
Rollup of 8 pull requests Successful merges: - #158242 (Fix linking for wasm with crate metadata included) - #157978 (Avoid `&raw` recovery ICE after trailing comma) - #158119 (Refactor `proc_macro_decls_static`) - #158171 (rustdoc: Avoid ICE on unevaluated `type const` projections in array lengths) - #158172 (update `asm_experimental_reg` comments) - #158230 (Include `Item::stability` info in rustdoc JSON.) - #158258 (Use an unexpanded span for actually written down opt out params) - #158262 (Change compiler leads in triagebot.toml)
2 parents cddcbec + 3809a10 commit f3d2eee

37 files changed

Lines changed: 753 additions & 109 deletions

File tree

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,13 @@ pub(crate) fn exported_symbols(
18171817
exported_symbols_for_non_proc_macro(tcx, crate_type)
18181818
};
18191819

1820-
if crate_type == CrateType::Dylib || crate_type == CrateType::ProcMacro {
1820+
// Preserve the metadata symbol to ensure the metadata section doesn't get removed by the
1821+
// linker. On wasm however the metadata is put in a custom section, to which symbols can't
1822+
// refer, so there is no metadata symbol there. Luckily custom sections are always preserved by
1823+
// the linker.
1824+
if (crate_type == CrateType::Dylib || crate_type == CrateType::ProcMacro)
1825+
&& !tcx.sess.target.is_like_wasm
1826+
{
18211827
let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx);
18221828
symbols.push((metadata_symbol_name, SymbolExportKind::Data));
18231829
}

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4570,6 +4570,7 @@ impl<'hir> Item<'hir> {
45704570
HirId::make_owner(self.owner_id.def_id)
45714571
}
45724572

4573+
#[inline]
45734574
pub fn item_id(&self) -> ItemId {
45744575
ItemId { owner_id: self.owner_id }
45754576
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ use crate::hir_ty_lowering::{
2525
#[derive(Debug, Default)]
2626
struct CollectedBound {
2727
/// `Trait`
28-
positive: bool,
28+
positive: Option<Span>,
2929
/// `?Trait`
30-
maybe: bool,
30+
maybe: Option<Span>,
3131
/// `!Trait`
32-
negative: bool,
32+
negative: Option<Span>,
3333
}
3434

3535
impl CollectedBound {
3636
/// Returns `true` if any of `Trait`, `?Trait` or `!Trait` were encountered.
3737
fn any(&self) -> bool {
38-
self.positive || self.maybe || self.negative
38+
self.positive.is_some() || self.maybe.is_some() || self.negative.is_some()
3939
}
4040
}
4141

@@ -96,9 +96,9 @@ fn collect_bounds<'a, 'tcx>(
9696
}
9797

9898
match ptr.modifiers.polarity {
99-
hir::BoundPolarity::Maybe(_) => collect_into.maybe = true,
100-
hir::BoundPolarity::Negative(_) => collect_into.negative = true,
101-
hir::BoundPolarity::Positive => collect_into.positive = true,
99+
hir::BoundPolarity::Maybe(_) => collect_into.maybe = Some(ptr.span),
100+
hir::BoundPolarity::Negative(_) => collect_into.negative = Some(ptr.span),
101+
hir::BoundPolarity::Positive => collect_into.positive = Some(ptr.span),
102102
}
103103
});
104104
collect_into
@@ -180,10 +180,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
180180
ImpliedBoundsContext::TyParam(..) | ImpliedBoundsContext::AssociatedTypeOrImplTrait => {
181181
}
182182
}
183-
184183
let collected = collect_sizedness_bounds(tcx, hir_bounds, context, span);
185-
if (collected.sized.maybe || collected.sized.negative)
186-
&& !collected.sized.positive
184+
if let Some(span) = collected.sized.maybe.or(collected.sized.negative)
185+
&& collected.sized.positive.is_none()
187186
&& !collected.meta_sized.any()
188187
&& !collected.pointee_sized.any()
189188
{

compiler/rustc_interface/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub mod diagnostics;
1010
pub mod interface;
1111
mod limits;
1212
pub mod passes;
13-
mod proc_macro_decls;
1413
mod queries;
1514
pub mod util;
1615

compiler/rustc_interface/src/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use rustc_trait_selection::{solve, traits};
4949
use tracing::{info, instrument};
5050

5151
use crate::interface::Compiler;
52-
use crate::{diagnostics, limits, proc_macro_decls, util};
52+
use crate::{diagnostics, limits, util};
5353

5454
pub fn parse<'a>(sess: &'a Session) -> ast::Crate {
5555
let mut krate = sess
@@ -897,9 +897,9 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
897897
providers.queries.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).2;
898898
providers.queries.early_lint_checks = early_lint_checks;
899899
providers.queries.env_var_os = env_var_os;
900+
providers.queries.proc_macro_decls_static = |tcx, _| tcx.hir_crate_items(()).proc_macro_decls();
900901
rustc_ast_lowering::provide(&mut providers.queries);
901902
limits::provide(&mut providers.queries);
902-
proc_macro_decls::provide(&mut providers.queries);
903903
rustc_expand::provide(&mut providers.queries);
904904
rustc_const_eval::provide(providers);
905905
rustc_middle::hir::provide(&mut providers.queries);

compiler/rustc_interface/src/proc_macro_decls.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

compiler/rustc_middle/src/hir/map.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,8 +1275,10 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
12751275
opaques,
12761276
nested_bodies,
12771277
eiis,
1278+
proc_macro_decls,
12781279
..
12791280
} = collector;
1281+
12801282
ModuleItems {
12811283
add_root: false,
12821284
submodules: submodules.into_boxed_slice(),
@@ -1288,6 +1290,7 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
12881290
opaques: opaques.into_boxed_slice(),
12891291
nested_bodies: nested_bodies.into_boxed_slice(),
12901292
eiis: eiis.into_boxed_slice(),
1293+
proc_macro_decls,
12911294
}
12921295
}
12931296

@@ -1310,6 +1313,7 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
13101313
opaques,
13111314
nested_bodies,
13121315
eiis,
1316+
proc_macro_decls,
13131317
..
13141318
} = collector;
13151319

@@ -1324,40 +1328,32 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
13241328
opaques: opaques.into_boxed_slice(),
13251329
nested_bodies: nested_bodies.into_boxed_slice(),
13261330
eiis: eiis.into_boxed_slice(),
1331+
proc_macro_decls,
13271332
}
13281333
}
13291334

13301335
struct ItemCollector<'tcx> {
13311336
// When true, it collects all items in the create,
13321337
// otherwise it collects items in some module.
1338+
// Converting this to generic const didn't lead to significant perf improvements
1339+
// (see <https://github.com/rust-lang/rust/pull/158119#issuecomment-4751513679>).
13331340
crate_collector: bool,
13341341
tcx: TyCtxt<'tcx>,
1335-
submodules: Vec<OwnerId>,
1336-
items: Vec<ItemId>,
1337-
trait_items: Vec<TraitItemId>,
1338-
impl_items: Vec<ImplItemId>,
1339-
foreign_items: Vec<ForeignItemId>,
1340-
body_owners: Vec<LocalDefId>,
1341-
opaques: Vec<LocalDefId>,
1342-
nested_bodies: Vec<LocalDefId>,
1343-
eiis: Vec<LocalDefId>,
1342+
submodules: Vec<OwnerId> = vec![],
1343+
items: Vec<ItemId> = vec![],
1344+
trait_items: Vec<TraitItemId> = vec![],
1345+
impl_items: Vec<ImplItemId> = vec![],
1346+
foreign_items: Vec<ForeignItemId> = vec![],
1347+
body_owners: Vec<LocalDefId> = vec![],
1348+
opaques: Vec<LocalDefId> = vec![],
1349+
nested_bodies: Vec<LocalDefId> = vec![],
1350+
eiis: Vec<LocalDefId> = vec![],
1351+
proc_macro_decls: Option<LocalDefId> = None,
13441352
}
13451353

13461354
impl<'tcx> ItemCollector<'tcx> {
13471355
fn new(tcx: TyCtxt<'tcx>, crate_collector: bool) -> ItemCollector<'tcx> {
1348-
ItemCollector {
1349-
crate_collector,
1350-
tcx,
1351-
submodules: Vec::default(),
1352-
items: Vec::default(),
1353-
trait_items: Vec::default(),
1354-
impl_items: Vec::default(),
1355-
foreign_items: Vec::default(),
1356-
body_owners: Vec::default(),
1357-
opaques: Vec::default(),
1358-
nested_bodies: Vec::default(),
1359-
eiis: Vec::default(),
1360-
}
1356+
ItemCollector { crate_collector, tcx, .. }
13611357
}
13621358
}
13631359

@@ -1373,7 +1369,16 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
13731369
self.body_owners.push(item.owner_id.def_id);
13741370
}
13751371

1376-
self.items.push(item.item_id());
1372+
let item_id = item.item_id();
1373+
1374+
if self.crate_collector
1375+
&& self.proc_macro_decls.is_none()
1376+
&& find_attr!(self.tcx, item_id.hir_id(), RustcProcMacroDecls)
1377+
{
1378+
self.proc_macro_decls = Some(item_id.owner_id.def_id);
1379+
}
1380+
1381+
self.items.push(item_id);
13771382

13781383
if let ItemKind::Static(..) | ItemKind::Fn { .. } | ItemKind::Macro(..) = &item.kind
13791384
&& item.eii

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ pub struct ModuleItems {
3939

4040
/// Statics and functions with an `EiiImpls` or `EiiExternTarget` attribute
4141
eiis: Box<[LocalDefId]>,
42+
43+
// only filled with hir_crate_items, not with hir_module_items
44+
proc_macro_decls: Option<LocalDefId>,
4245
}
4346

4447
impl ModuleItems {
@@ -56,6 +59,11 @@ impl ModuleItems {
5659
self.trait_items.iter().copied()
5760
}
5861

62+
#[inline]
63+
pub fn proc_macro_decls(&self) -> Option<LocalDefId> {
64+
self.proc_macro_decls
65+
}
66+
5967
pub fn eiis(&self) -> impl Iterator<Item = LocalDefId> {
6068
self.eiis.iter().copied()
6169
}

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,8 +1304,10 @@ impl<'a> Parser<'a> {
13041304
let err_span = self.prev_token.span.to(self.token.span);
13051305
let mut args = thin_vec![self.mk_expr_err(err_span, guar)];
13061306
while !self.token.kind.is_close_delim_or_eof() {
1307-
if self.eat(exp!(Comma)) && !self.token.kind.is_close_delim_or_eof() {
1308-
args.push(self.mk_expr_err(self.prev_token.span.shrink_to_hi(), guar));
1307+
if self.eat(exp!(Comma)) {
1308+
if !self.token.kind.is_close_delim_or_eof() {
1309+
args.push(self.mk_expr_err(self.prev_token.span.shrink_to_hi(), guar));
1310+
}
13091311
} else {
13101312
self.parse_token_tree();
13111313
}

src/doc/unstable-book/src/language-features/asm-experimental-reg.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `asm_experimental_arch`
1+
# `asm_experimental_reg`
22

33
The tracking issue for this feature is: [#133416]
44

0 commit comments

Comments
 (0)