Use local key in providers
This commit is contained in:
parent
a01b4cc9f3
commit
2eb1c08e43
65 changed files with 458 additions and 395 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue