Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ dependencies = [
"semver",
"serde",
"serde_json",
"tempfile",
"tracing",
"tracing-subscriber",
"unified-diff",
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
kind,
vis_span,
span: self.lower_span(i.span),
has_delayed_lints: !self.delayed_lints.is_empty(),
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
};
self.arena.alloc(item)
Expand Down Expand Up @@ -700,7 +699,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
kind,
vis_span,
span: this.lower_span(use_tree.span()),
has_delayed_lints: !this.delayed_lints.is_empty(),
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
};
hir::OwnerNode::Item(this.arena.alloc(item))
Expand Down Expand Up @@ -788,7 +786,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
kind,
vis_span: self.lower_span(i.vis.span),
span: self.lower_span(i.span),
has_delayed_lints: !self.delayed_lints.is_empty(),
};
self.arena.alloc(item)
}
Expand Down Expand Up @@ -1087,7 +1084,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
kind,
span: self.lower_span(i.span),
defaultness,
has_delayed_lints: !self.delayed_lints.is_empty(),
};
self.arena.alloc(item)
}
Expand Down Expand Up @@ -1304,7 +1300,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
impl_kind,
kind,
span,
has_delayed_lints: !self.delayed_lints.is_empty(),
};
self.arena.alloc(item)
}
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3280,7 +3280,6 @@ pub struct TraitItem<'hir> {
pub kind: TraitItemKind<'hir>,
pub span: Span,
pub defaultness: Defaultness,
pub has_delayed_lints: bool,
}

macro_rules! expect_methods_self_kind {
Expand Down Expand Up @@ -3384,7 +3383,6 @@ pub struct ImplItem<'hir> {
pub kind: ImplItemKind<'hir>,
pub impl_kind: ImplItemImplKind,
pub span: Span,
pub has_delayed_lints: bool,
}

#[derive(Debug, Clone, Copy, StableHash)]
Expand Down Expand Up @@ -4560,7 +4558,6 @@ pub struct Item<'hir> {
pub kind: ItemKind<'hir>,
pub span: Span,
pub vis_span: Span,
pub has_delayed_lints: bool,
/// hint to speed up collection: true if the item is a static or function and has
/// either an `EiiImpls` or `EiiExternTarget` attribute
pub eii: bool,
Expand Down Expand Up @@ -4955,7 +4952,6 @@ pub struct ForeignItem<'hir> {
pub owner_id: OwnerId,
pub span: Span,
pub vis_span: Span,
pub has_delayed_lints: bool,
}

impl ForeignItem<'_> {
Expand Down Expand Up @@ -5467,7 +5463,7 @@ mod size_asserts {
static_assert_size!(Expr<'_>, 64);
static_assert_size!(ExprKind<'_>, 48);
static_assert_size!(FnDecl<'_>, 40);
static_assert_size!(ForeignItem<'_>, 96);
static_assert_size!(ForeignItem<'_>, 88);
static_assert_size!(ForeignItemKind<'_>, 56);
static_assert_size!(GenericArg<'_>, 16);
static_assert_size!(GenericBound<'_>, 64);
Expand Down
26 changes: 5 additions & 21 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) ->
}

pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::Result {
let Item { owner_id: _, kind, span: _, vis_span: _, has_delayed_lints: _, eii: _ } = item;
let Item { owner_id: _, kind, span: _, vis_span: _, eii: _ } = item;
try_visit!(visitor.visit_id(item.hir_id()));
match *kind {
ItemKind::ExternCrate(orig_name, ident) => {
Expand Down Expand Up @@ -660,8 +660,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
visitor: &mut V,
foreign_item: &'v ForeignItem<'v>,
) -> V::Result {
let ForeignItem { ident, kind, owner_id: _, span: _, vis_span: _, has_delayed_lints: _ } =
foreign_item;
let ForeignItem { ident, kind, owner_id: _, span: _, vis_span: _ } = foreign_item;
try_visit!(visitor.visit_id(foreign_item.hir_id()));
try_visit!(visitor.visit_ident(*ident));

Expand Down Expand Up @@ -1258,15 +1257,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(
visitor: &mut V,
trait_item: &'v TraitItem<'v>,
) -> V::Result {
let TraitItem {
ident,
generics,
ref defaultness,
ref kind,
span,
owner_id: _,
has_delayed_lints: _,
} = *trait_item;
let TraitItem { ident, generics, ref defaultness, ref kind, span, owner_id: _ } = *trait_item;
let hir_id = trait_item.hir_id();
try_visit!(visitor.visit_ident(ident));
try_visit!(visitor.visit_generics(&generics));
Expand Down Expand Up @@ -1308,15 +1299,8 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(
visitor: &mut V,
impl_item: &'v ImplItem<'v>,
) -> V::Result {
let ImplItem {
owner_id: _,
ident,
ref generics,
ref impl_kind,
ref kind,
span: _,
has_delayed_lints: _,
} = *impl_item;
let ImplItem { owner_id: _, ident, ref generics, ref impl_kind, ref kind, span: _ } =
*impl_item;

try_visit!(visitor.visit_ident(ident));
try_visit!(visitor.visit_generics(generics));
Expand Down
26 changes: 2 additions & 24 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn configure_and_expand(
if cfg!(windows) {
old_path = env::var_os("PATH").unwrap_or(old_path);
let mut new_path = Vec::from_iter(
sess.host_filesearch().search_paths(PathKind::All).map(|p| p.dir.clone()),
sess.host_filesearch().search_paths(PathKind::Native).map(|p| p.dir.clone()),
);
for path in env::split_paths(&old_path) {
if !new_path.contains(&path) {
Expand Down Expand Up @@ -1065,7 +1065,7 @@ impl<'a, 'tcx> Diagnostic<'a, ()> for DiagCallback<'tcx> {
}

pub fn emit_delayed_lints(tcx: TyCtxt<'_>) {
for owner_id in tcx.hir_crate_items(()).delayed_lint_items() {
for owner_id in tcx.hir_crate_items(()).owners() {
if let Some(delayed_lints) = tcx.opt_ast_lowering_delayed_lints(owner_id) {
for lint in delayed_lints.steal() {
tcx.emit_node_span_lint(
Expand Down Expand Up @@ -1131,28 +1131,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
});

sess.time("emit_ast_lowering_delayed_lints", || {
// Sanity check in debug mode that all lints are really noticed and we really will emit
// them all in the loop right below.
//
// During ast lowering, when creating items, foreign items, trait items and impl items,
// we store in them whether they have any lints in their owner node that should be
// picked up by `hir_crate_items`. However, theoretically code can run between that
// boolean being inserted into the item and the owner node being created. We don't want
// any new lints to be emitted there (you have to really try to manage that but still),
// but this check is there to catch that.
#[cfg(debug_assertions)]
{
let hir_items = tcx.hir_crate_items(());
for owner_id in hir_items.owners() {
if let Some(delayed_lints) = tcx.opt_ast_lowering_delayed_lints(owner_id)
&& !delayed_lints.borrow().is_empty()
{
// Assert that delayed_lint_items also picked up this item to have lints.
assert!(hir_items.delayed_lint_items().any(|i| i == owner_id));
}
}
}

emit_delayed_lints(tcx);
});

Expand Down
25 changes: 0 additions & 25 deletions compiler/rustc_middle/src/hir/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,6 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
body_owners: body_owners.into_boxed_slice(),
opaques: opaques.into_boxed_slice(),
nested_bodies: nested_bodies.into_boxed_slice(),
delayed_lint_items: Box::new([]),
eiis: eiis.into_boxed_slice(),
}
}
Expand All @@ -1310,19 +1309,10 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
body_owners,
opaques,
nested_bodies,
mut delayed_lint_items,
eiis,
..
} = collector;

// The crate could have delayed lints too, but would not be picked up by the visitor.
// The `delayed_lint_items` list is smart - it only contains items which we know from
// earlier passes is guaranteed to contain lints. It's a little harder to determine that
// for sure here, so we simply always add the crate to the list. If it has no lints,
// we'll discover that later. The cost of this should be low, there's only one crate
// after all compared to the many items we have we wouldn't want to iterate over later.
delayed_lint_items.push(CRATE_OWNER_ID);

ModuleItems {
add_root: true,
submodules: submodules.into_boxed_slice(),
Expand All @@ -1333,7 +1323,6 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
body_owners: body_owners.into_boxed_slice(),
opaques: opaques.into_boxed_slice(),
nested_bodies: nested_bodies.into_boxed_slice(),
delayed_lint_items: delayed_lint_items.into_boxed_slice(),
eiis: eiis.into_boxed_slice(),
}
}
Expand All @@ -1351,7 +1340,6 @@ struct ItemCollector<'tcx> {
body_owners: Vec<LocalDefId>,
opaques: Vec<LocalDefId>,
nested_bodies: Vec<LocalDefId>,
delayed_lint_items: Vec<OwnerId>,
eiis: Vec<LocalDefId>,
}

Expand All @@ -1368,7 +1356,6 @@ impl<'tcx> ItemCollector<'tcx> {
body_owners: Vec::default(),
opaques: Vec::default(),
nested_bodies: Vec::default(),
delayed_lint_items: Vec::default(),
eiis: Vec::default(),
}
}
Expand All @@ -1387,9 +1374,6 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
}

self.items.push(item.item_id());
if self.crate_collector && item.has_delayed_lints {
self.delayed_lint_items.push(item.item_id().owner_id);
}

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

fn visit_foreign_item(&mut self, item: &'hir ForeignItem<'hir>) {
self.foreign_items.push(item.foreign_item_id());
if self.crate_collector && item.has_delayed_lints {
self.delayed_lint_items.push(item.foreign_item_id().owner_id);
}
intravisit::walk_foreign_item(self, item)
}

Expand Down Expand Up @@ -1447,9 +1428,6 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
}

self.trait_items.push(item.trait_item_id());
if self.crate_collector && item.has_delayed_lints {
self.delayed_lint_items.push(item.trait_item_id().owner_id);
}

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

self.impl_items.push(item.impl_item_id());
if self.crate_collector && item.has_delayed_lints {
self.delayed_lint_items.push(item.impl_item_id().owner_id);
}

intravisit::walk_impl_item(self, item)
}
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_middle/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ pub struct ModuleItems {
opaques: Box<[LocalDefId]>,
body_owners: Box<[LocalDefId]>,
nested_bodies: Box<[LocalDefId]>,
// only filled with hir_crate_items, not with hir_module_items
delayed_lint_items: Box<[OwnerId]>,

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

pub fn delayed_lint_items(&self) -> impl Iterator<Item = OwnerId> {
self.delayed_lint_items.iter().copied()
}

pub fn eiis(&self) -> impl Iterator<Item = LocalDefId> {
self.eiis.iter().copied()
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/context/impl_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{debug_assert_matches, fmt};

use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
use rustc_hir::def::{CtorKind, DefKind};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::LangItem;
use rustc_span::{DUMMY_SP, Span, Symbol};
Expand Down Expand Up @@ -437,7 +437,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
fn fn_is_const(self, def_id: DefId) -> bool {
debug_assert_matches!(
self.def_kind(def_id),
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(CtorOf::Struct, CtorKind::Fn)
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn)
);
self.is_conditionally_const(def_id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ fn collect_user_names(body: &Body<'_>) -> FxIndexMap<Local, Symbol> {
for var_debug_info in &body.var_debug_info {
if let mir::VarDebugInfoContents::Place(place) = &var_debug_info.value
&& let Some(local) = place.local_or_deref_local()
&& !body.local_decls[local].from_compiler_desugaring()
{
names.entry(local).or_insert(var_debug_info.name);
}
Expand Down
5 changes: 2 additions & 3 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default-run = "bootstrap"

[features]
build-metrics = ["dep:sysinfo", "build_helper/metrics"]
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:chrono", "dep:tempfile"]
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:chrono"]

[lib]
path = "src/lib.rs"
Expand Down Expand Up @@ -55,6 +55,7 @@ termcolor = "1.4"
toml = "0.5"
walkdir = "2.4"
xz2 = "0.1"
tempfile = "3.15.0"

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

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

[dev-dependencies]
pretty_assertions = "1.4"
tempfile = "3.15.0"
insta = "1.43"

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