Skip to content

Commit ff64732

Browse files
committed
Auto merge of #158212 - JonathanBrouwer:rollup-s7MPo5g, r=JonathanBrouwer
Rollup of 4 pull requests Successful merges: - #155439 (Enable Cargo's new build-dir layout) - #157942 (Do not use desugared local names in tail_expr_drop_order diagnostics) - #158193 (Remove `has_delayed_lints` optimization) - #158204 (More general assert in Interner const fn check)
2 parents 40f92b3 + 6e58171 commit ff64732

53 files changed

Lines changed: 811 additions & 593 deletions

Some content is hidden

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

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ dependencies = [
905905
"semver",
906906
"serde",
907907
"serde_json",
908+
"tempfile",
908909
"tracing",
909910
"tracing-subscriber",
910911
"unified-diff",

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
227227
kind,
228228
vis_span,
229229
span: self.lower_span(i.span),
230-
has_delayed_lints: !self.delayed_lints.is_empty(),
231230
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
232231
};
233232
self.arena.alloc(item)
@@ -700,7 +699,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
700699
kind,
701700
vis_span,
702701
span: this.lower_span(use_tree.span()),
703-
has_delayed_lints: !this.delayed_lints.is_empty(),
704702
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
705703
};
706704
hir::OwnerNode::Item(this.arena.alloc(item))
@@ -788,7 +786,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
788786
kind,
789787
vis_span: self.lower_span(i.vis.span),
790788
span: self.lower_span(i.span),
791-
has_delayed_lints: !self.delayed_lints.is_empty(),
792789
};
793790
self.arena.alloc(item)
794791
}
@@ -1087,7 +1084,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
10871084
kind,
10881085
span: self.lower_span(i.span),
10891086
defaultness,
1090-
has_delayed_lints: !self.delayed_lints.is_empty(),
10911087
};
10921088
self.arena.alloc(item)
10931089
}
@@ -1304,7 +1300,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
13041300
impl_kind,
13051301
kind,
13061302
span,
1307-
has_delayed_lints: !self.delayed_lints.is_empty(),
13081303
};
13091304
self.arena.alloc(item)
13101305
}

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,7 +3280,6 @@ pub struct TraitItem<'hir> {
32803280
pub kind: TraitItemKind<'hir>,
32813281
pub span: Span,
32823282
pub defaultness: Defaultness,
3283-
pub has_delayed_lints: bool,
32843283
}
32853284

32863285
macro_rules! expect_methods_self_kind {
@@ -3384,7 +3383,6 @@ pub struct ImplItem<'hir> {
33843383
pub kind: ImplItemKind<'hir>,
33853384
pub impl_kind: ImplItemImplKind,
33863385
pub span: Span,
3387-
pub has_delayed_lints: bool,
33883386
}
33893387

33903388
#[derive(Debug, Clone, Copy, StableHash)]
@@ -4560,7 +4558,6 @@ pub struct Item<'hir> {
45604558
pub kind: ItemKind<'hir>,
45614559
pub span: Span,
45624560
pub vis_span: Span,
4563-
pub has_delayed_lints: bool,
45644561
/// hint to speed up collection: true if the item is a static or function and has
45654562
/// either an `EiiImpls` or `EiiExternTarget` attribute
45664563
pub eii: bool,
@@ -4955,7 +4952,6 @@ pub struct ForeignItem<'hir> {
49554952
pub owner_id: OwnerId,
49564953
pub span: Span,
49574954
pub vis_span: Span,
4958-
pub has_delayed_lints: bool,
49594955
}
49604956

49614957
impl ForeignItem<'_> {
@@ -5467,7 +5463,7 @@ mod size_asserts {
54675463
static_assert_size!(Expr<'_>, 64);
54685464
static_assert_size!(ExprKind<'_>, 48);
54695465
static_assert_size!(FnDecl<'_>, 40);
5470-
static_assert_size!(ForeignItem<'_>, 96);
5466+
static_assert_size!(ForeignItem<'_>, 88);
54715467
static_assert_size!(ForeignItemKind<'_>, 56);
54725468
static_assert_size!(GenericArg<'_>, 16);
54735469
static_assert_size!(GenericBound<'_>, 64);

compiler/rustc_hir/src/intravisit.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) ->
530530
}
531531

532532
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::Result {
533-
let Item { owner_id: _, kind, span: _, vis_span: _, has_delayed_lints: _, eii: _ } = item;
533+
let Item { owner_id: _, kind, span: _, vis_span: _, eii: _ } = item;
534534
try_visit!(visitor.visit_id(item.hir_id()));
535535
match *kind {
536536
ItemKind::ExternCrate(orig_name, ident) => {
@@ -660,8 +660,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
660660
visitor: &mut V,
661661
foreign_item: &'v ForeignItem<'v>,
662662
) -> V::Result {
663-
let ForeignItem { ident, kind, owner_id: _, span: _, vis_span: _, has_delayed_lints: _ } =
664-
foreign_item;
663+
let ForeignItem { ident, kind, owner_id: _, span: _, vis_span: _ } = foreign_item;
665664
try_visit!(visitor.visit_id(foreign_item.hir_id()));
666665
try_visit!(visitor.visit_ident(*ident));
667666

@@ -1258,15 +1257,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(
12581257
visitor: &mut V,
12591258
trait_item: &'v TraitItem<'v>,
12601259
) -> V::Result {
1261-
let TraitItem {
1262-
ident,
1263-
generics,
1264-
ref defaultness,
1265-
ref kind,
1266-
span,
1267-
owner_id: _,
1268-
has_delayed_lints: _,
1269-
} = *trait_item;
1260+
let TraitItem { ident, generics, ref defaultness, ref kind, span, owner_id: _ } = *trait_item;
12701261
let hir_id = trait_item.hir_id();
12711262
try_visit!(visitor.visit_ident(ident));
12721263
try_visit!(visitor.visit_generics(&generics));
@@ -1308,15 +1299,8 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(
13081299
visitor: &mut V,
13091300
impl_item: &'v ImplItem<'v>,
13101301
) -> V::Result {
1311-
let ImplItem {
1312-
owner_id: _,
1313-
ident,
1314-
ref generics,
1315-
ref impl_kind,
1316-
ref kind,
1317-
span: _,
1318-
has_delayed_lints: _,
1319-
} = *impl_item;
1302+
let ImplItem { owner_id: _, ident, ref generics, ref impl_kind, ref kind, span: _ } =
1303+
*impl_item;
13201304

13211305
try_visit!(visitor.visit_ident(ident));
13221306
try_visit!(visitor.visit_generics(generics));

compiler/rustc_interface/src/passes.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn configure_and_expand(
181181
if cfg!(windows) {
182182
old_path = env::var_os("PATH").unwrap_or(old_path);
183183
let mut new_path = Vec::from_iter(
184-
sess.host_filesearch().search_paths(PathKind::All).map(|p| p.dir.clone()),
184+
sess.host_filesearch().search_paths(PathKind::Native).map(|p| p.dir.clone()),
185185
);
186186
for path in env::split_paths(&old_path) {
187187
if !new_path.contains(&path) {
@@ -1065,7 +1065,7 @@ impl<'a, 'tcx> Diagnostic<'a, ()> for DiagCallback<'tcx> {
10651065
}
10661066

10671067
pub fn emit_delayed_lints(tcx: TyCtxt<'_>) {
1068-
for owner_id in tcx.hir_crate_items(()).delayed_lint_items() {
1068+
for owner_id in tcx.hir_crate_items(()).owners() {
10691069
if let Some(delayed_lints) = tcx.opt_ast_lowering_delayed_lints(owner_id) {
10701070
for lint in delayed_lints.steal() {
10711071
tcx.emit_node_span_lint(
@@ -1131,28 +1131,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
11311131
});
11321132

11331133
sess.time("emit_ast_lowering_delayed_lints", || {
1134-
// Sanity check in debug mode that all lints are really noticed and we really will emit
1135-
// them all in the loop right below.
1136-
//
1137-
// During ast lowering, when creating items, foreign items, trait items and impl items,
1138-
// we store in them whether they have any lints in their owner node that should be
1139-
// picked up by `hir_crate_items`. However, theoretically code can run between that
1140-
// boolean being inserted into the item and the owner node being created. We don't want
1141-
// any new lints to be emitted there (you have to really try to manage that but still),
1142-
// but this check is there to catch that.
1143-
#[cfg(debug_assertions)]
1144-
{
1145-
let hir_items = tcx.hir_crate_items(());
1146-
for owner_id in hir_items.owners() {
1147-
if let Some(delayed_lints) = tcx.opt_ast_lowering_delayed_lints(owner_id)
1148-
&& !delayed_lints.borrow().is_empty()
1149-
{
1150-
// Assert that delayed_lint_items also picked up this item to have lints.
1151-
assert!(hir_items.delayed_lint_items().any(|i| i == owner_id));
1152-
}
1153-
}
1154-
}
1155-
11561134
emit_delayed_lints(tcx);
11571135
});
11581136

compiler/rustc_middle/src/hir/map.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,6 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
12871287
body_owners: body_owners.into_boxed_slice(),
12881288
opaques: opaques.into_boxed_slice(),
12891289
nested_bodies: nested_bodies.into_boxed_slice(),
1290-
delayed_lint_items: Box::new([]),
12911290
eiis: eiis.into_boxed_slice(),
12921291
}
12931292
}
@@ -1310,19 +1309,10 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
13101309
body_owners,
13111310
opaques,
13121311
nested_bodies,
1313-
mut delayed_lint_items,
13141312
eiis,
13151313
..
13161314
} = collector;
13171315

1318-
// The crate could have delayed lints too, but would not be picked up by the visitor.
1319-
// The `delayed_lint_items` list is smart - it only contains items which we know from
1320-
// earlier passes is guaranteed to contain lints. It's a little harder to determine that
1321-
// for sure here, so we simply always add the crate to the list. If it has no lints,
1322-
// we'll discover that later. The cost of this should be low, there's only one crate
1323-
// after all compared to the many items we have we wouldn't want to iterate over later.
1324-
delayed_lint_items.push(CRATE_OWNER_ID);
1325-
13261316
ModuleItems {
13271317
add_root: true,
13281318
submodules: submodules.into_boxed_slice(),
@@ -1333,7 +1323,6 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
13331323
body_owners: body_owners.into_boxed_slice(),
13341324
opaques: opaques.into_boxed_slice(),
13351325
nested_bodies: nested_bodies.into_boxed_slice(),
1336-
delayed_lint_items: delayed_lint_items.into_boxed_slice(),
13371326
eiis: eiis.into_boxed_slice(),
13381327
}
13391328
}
@@ -1351,7 +1340,6 @@ struct ItemCollector<'tcx> {
13511340
body_owners: Vec<LocalDefId>,
13521341
opaques: Vec<LocalDefId>,
13531342
nested_bodies: Vec<LocalDefId>,
1354-
delayed_lint_items: Vec<OwnerId>,
13551343
eiis: Vec<LocalDefId>,
13561344
}
13571345

@@ -1368,7 +1356,6 @@ impl<'tcx> ItemCollector<'tcx> {
13681356
body_owners: Vec::default(),
13691357
opaques: Vec::default(),
13701358
nested_bodies: Vec::default(),
1371-
delayed_lint_items: Vec::default(),
13721359
eiis: Vec::default(),
13731360
}
13741361
}
@@ -1387,9 +1374,6 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
13871374
}
13881375

13891376
self.items.push(item.item_id());
1390-
if self.crate_collector && item.has_delayed_lints {
1391-
self.delayed_lint_items.push(item.item_id().owner_id);
1392-
}
13931377

13941378
if let ItemKind::Static(..) | ItemKind::Fn { .. } | ItemKind::Macro(..) = &item.kind
13951379
&& item.eii
@@ -1411,9 +1395,6 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
14111395

14121396
fn visit_foreign_item(&mut self, item: &'hir ForeignItem<'hir>) {
14131397
self.foreign_items.push(item.foreign_item_id());
1414-
if self.crate_collector && item.has_delayed_lints {
1415-
self.delayed_lint_items.push(item.foreign_item_id().owner_id);
1416-
}
14171398
intravisit::walk_foreign_item(self, item)
14181399
}
14191400

@@ -1447,9 +1428,6 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
14471428
}
14481429

14491430
self.trait_items.push(item.trait_item_id());
1450-
if self.crate_collector && item.has_delayed_lints {
1451-
self.delayed_lint_items.push(item.trait_item_id().owner_id);
1452-
}
14531431

14541432
intravisit::walk_trait_item(self, item)
14551433
}
@@ -1460,9 +1438,6 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
14601438
}
14611439

14621440
self.impl_items.push(item.impl_item_id());
1463-
if self.crate_collector && item.has_delayed_lints {
1464-
self.delayed_lint_items.push(item.impl_item_id().owner_id);
1465-
}
14661441

14671442
intravisit::walk_impl_item(self, item)
14681443
}

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ pub struct ModuleItems {
3636
opaques: Box<[LocalDefId]>,
3737
body_owners: Box<[LocalDefId]>,
3838
nested_bodies: Box<[LocalDefId]>,
39-
// only filled with hir_crate_items, not with hir_module_items
40-
delayed_lint_items: Box<[OwnerId]>,
4139

4240
/// Statics and functions with an `EiiImpls` or `EiiExternTarget` attribute
4341
eiis: Box<[LocalDefId]>,
@@ -58,10 +56,6 @@ impl ModuleItems {
5856
self.trait_items.iter().copied()
5957
}
6058

61-
pub fn delayed_lint_items(&self) -> impl Iterator<Item = OwnerId> {
62-
self.delayed_lint_items.iter().copied()
63-
}
64-
6559
pub fn eiis(&self) -> impl Iterator<Item = LocalDefId> {
6660
self.eiis.iter().copied()
6761
}

compiler/rustc_middle/src/ty/context/impl_interner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{debug_assert_matches, fmt};
55

66
use rustc_errors::ErrorGuaranteed;
77
use rustc_hir as hir;
8-
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
8+
use rustc_hir::def::{CtorKind, DefKind};
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_hir::lang_items::LangItem;
1111
use rustc_span::{DUMMY_SP, Span, Symbol};
@@ -437,7 +437,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
437437
fn fn_is_const(self, def_id: DefId) -> bool {
438438
debug_assert_matches!(
439439
self.def_kind(def_id),
440-
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(CtorOf::Struct, CtorKind::Fn)
440+
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn)
441441
);
442442
self.is_conditionally_const(def_id)
443443
}

compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ fn collect_user_names(body: &Body<'_>) -> FxIndexMap<Local, Symbol> {
466466
for var_debug_info in &body.var_debug_info {
467467
if let mir::VarDebugInfoContents::Place(place) = &var_debug_info.value
468468
&& let Some(local) = place.local_or_deref_local()
469+
&& !body.local_decls[local].from_compiler_desugaring()
469470
{
470471
names.entry(local).or_insert(var_debug_info.name);
471472
}

src/bootstrap/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default-run = "bootstrap"
77

88
[features]
99
build-metrics = ["dep:sysinfo", "build_helper/metrics"]
10-
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:chrono", "dep:tempfile"]
10+
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:chrono"]
1111

1212
[lib]
1313
path = "src/lib.rs"
@@ -55,6 +55,7 @@ termcolor = "1.4"
5555
toml = "0.5"
5656
walkdir = "2.4"
5757
xz2 = "0.1"
58+
tempfile = "3.15.0"
5859

5960
# Dependencies needed by the build-metrics feature
6061
sysinfo = { version = "0.39.2", default-features = false, optional = true, features = ["system"] }
@@ -64,7 +65,6 @@ chrono = { version = "0.4", default-features = false, optional = true, features
6465
tracing = { version = "0.1", optional = true, features = ["attributes"] }
6566
tracing-chrome = { version = "0.7", optional = true }
6667
tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter", "fmt", "registry", "std"] }
67-
tempfile = { version = "3.15.0", optional = true }
6868

6969
[target.'cfg(windows)'.dependencies.junction]
7070
version = "1.3.0"
@@ -83,7 +83,6 @@ features = [
8383

8484
[dev-dependencies]
8585
pretty_assertions = "1.4"
86-
tempfile = "3.15.0"
8786
insta = "1.43"
8887

8988
# We care a lot about bootstrap's compile times, so don't include debuginfo for

0 commit comments

Comments
 (0)