diff options
| author | Michael Goulet <michael@errs.io> | 2023-03-13 18:54:05 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-03-21 15:38:51 +0000 |
| commit | 2eb1c08e433aadf2362a65f2ef1387670a6d34cf (patch) | |
| tree | 1d8465f4d80adbbe4a44dd72eedc3361bd2b8f7c /compiler/rustc_passes | |
| parent | a01b4cc9f375f1b95fa8195daeea938d3d9c4c34 (diff) | |
| download | rust-2eb1c08e433aadf2362a65f2ef1387670a6d34cf.tar.gz rust-2eb1c08e433aadf2362a65f2ef1387670a6d34cf.zip | |
Use local key in providers
Diffstat (limited to 'compiler/rustc_passes')
| -rw-r--r-- | compiler/rustc_passes/src/check_const.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/dead.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/debugger_visualizer.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/diagnostic_items.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/layout_test.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/liveness.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/naked_functions.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/stability.rs | 12 |
8 files changed, 14 insertions, 26 deletions
diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index 526b829bf67..30dd3e4d016 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -104,9 +104,7 @@ impl<'tcx> CheckConstVisitor<'tcx> { // If this crate is not using stability attributes, or this function is not claiming to be a // stable `const fn`, that is all that is required. - if !tcx.features().staged_api - || tcx.has_attr(def_id.to_def_id(), sym::rustc_const_unstable) - { + if !tcx.features().staged_api || tcx.has_attr(def_id, sym::rustc_const_unstable) { return true; } diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index ec1e1d0054b..75ce446e6b4 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -469,9 +469,9 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { fn has_lang_attr(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { - tcx.has_attr(def_id.to_def_id(), sym::lang) + tcx.has_attr(def_id, sym::lang) // Stable attribute for #[lang = "panic_impl"] - || tcx.has_attr(def_id.to_def_id(), sym::panic_handler) + || tcx.has_attr(def_id, sym::panic_handler) } fn has_allow_dead_code(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { diff --git a/compiler/rustc_passes/src/debugger_visualizer.rs b/compiler/rustc_passes/src/debugger_visualizer.rs index aeacbaa67cb..9c7a3605d08 100644 --- a/compiler/rustc_passes/src/debugger_visualizer.rs +++ b/compiler/rustc_passes/src/debugger_visualizer.rs @@ -4,11 +4,9 @@ use hir::CRATE_HIR_ID; use rustc_data_structures::fx::FxHashSet; use rustc_expand::base::resolve_path; use rustc_hir as hir; -use rustc_hir::def_id::CrateNum; use rustc_hir::HirId; use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; -use rustc_span::def_id::LOCAL_CRATE; use rustc_span::{sym, DebuggerVisualizerFile, DebuggerVisualizerType}; use std::sync::Arc; @@ -69,9 +67,7 @@ fn check_for_debugger_visualizer( } /// Traverses and collects the debugger visualizers for a specific crate. -fn debugger_visualizers(tcx: TyCtxt<'_>, cnum: CrateNum) -> Vec<DebuggerVisualizerFile> { - assert_eq!(cnum, LOCAL_CRATE); - +fn debugger_visualizers(tcx: TyCtxt<'_>, (): ()) -> Vec<DebuggerVisualizerFile> { // Initialize the collector. let mut debugger_visualizers = FxHashSet::default(); diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs index 110eb210df9..b74fad66c0f 100644 --- a/compiler/rustc_passes/src/diagnostic_items.rs +++ b/compiler/rustc_passes/src/diagnostic_items.rs @@ -14,7 +14,7 @@ use rustc_hir::diagnostic_items::DiagnosticItems; use rustc_hir::OwnerId; use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; -use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; +use rustc_span::def_id::{DefId, LOCAL_CRATE}; use rustc_span::symbol::{sym, Symbol}; use crate::errors::DuplicateDiagnosticItemInCrate; @@ -62,9 +62,7 @@ fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> { } /// Traverse and collect the diagnostic items in the current -fn diagnostic_items(tcx: TyCtxt<'_>, cnum: CrateNum) -> DiagnosticItems { - assert_eq!(cnum, LOCAL_CRATE); - +fn diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems { // Initialize the collector. let mut diagnostic_items = DiagnosticItems::default(); diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs index 047b9b525e8..5a1ae808e66 100644 --- a/compiler/rustc_passes/src/layout_test.rs +++ b/compiler/rustc_passes/src/layout_test.rs @@ -18,7 +18,7 @@ pub fn test_layout(tcx: TyCtxt<'_>) { tcx.def_kind(id.owner_id), DefKind::TyAlias | DefKind::Enum | DefKind::Struct | DefKind::Union ) { - for attr in tcx.get_attrs(id.owner_id.to_def_id(), sym::rustc_layout) { + for attr in tcx.get_attrs(id.owner_id, sym::rustc_layout) { dump_layout_of(tcx, id.owner_id.def_id, attr); } } diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 36324e6f8da..a8471ce3b6f 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -146,7 +146,7 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: DefId) { // Don't run unused pass for #[derive()] let parent = tcx.local_parent(local_def_id); if let DefKind::Impl { .. } = tcx.def_kind(parent) - && tcx.has_attr(parent.to_def_id(), sym::automatically_derived) + && tcx.has_attr(parent, sym::automatically_derived) { return; } diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index f07a64c7c3c..c398467f03e 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -30,7 +30,7 @@ fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { continue; } - let naked = tcx.has_attr(def_id.to_def_id(), sym::naked); + let naked = tcx.has_attr(def_id, sym::naked); if !naked { continue; } @@ -59,7 +59,7 @@ fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { /// Check that the function isn't inlined. fn check_inline(tcx: TyCtxt<'_>, def_id: LocalDefId) { - let attrs = tcx.get_attrs(def_id.to_def_id(), sym::inline); + let attrs = tcx.get_attrs(def_id, sym::inline); for attr in attrs { tcx.sess.emit_err(CannotInlineNakedFunction { span: attr.span }); } diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index d5cc64a5402..6d0cfea00d1 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -691,14 +691,10 @@ pub(crate) fn provide(providers: &mut Providers) { check_mod_unstable_api_usage, stability_index, stability_implications: |tcx, _| tcx.stability().implications.clone(), - lookup_stability: |tcx, id| tcx.stability().local_stability(id.expect_local()), - lookup_const_stability: |tcx, id| tcx.stability().local_const_stability(id.expect_local()), - lookup_default_body_stability: |tcx, id| { - tcx.stability().local_default_body_stability(id.expect_local()) - }, - lookup_deprecation_entry: |tcx, id| { - tcx.stability().local_deprecation_entry(id.expect_local()) - }, + lookup_stability: |tcx, id| tcx.stability().local_stability(id), + lookup_const_stability: |tcx, id| tcx.stability().local_const_stability(id), + lookup_default_body_stability: |tcx, id| tcx.stability().local_default_body_stability(id), + lookup_deprecation_entry: |tcx, id| tcx.stability().local_deprecation_entry(id), ..*providers }; } |
