Move methods from Map
to TyCtxt
, part 4.
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
This commit is contained in:
parent
281af35cc3
commit
256c27e748
115 changed files with 269 additions and 321 deletions
|
@ -419,7 +419,7 @@ impl MissingDoc {
|
|||
return;
|
||||
}
|
||||
|
||||
let attrs = cx.tcx.hir().attrs(cx.tcx.local_def_id_to_hir_id(def_id));
|
||||
let attrs = cx.tcx.hir_attrs(cx.tcx.local_def_id_to_hir_id(def_id));
|
||||
let has_doc = attrs.iter().any(has_doc);
|
||||
if !has_doc {
|
||||
cx.emit_span_lint(
|
||||
|
@ -997,7 +997,7 @@ declare_lint_pass!(InvalidNoMangleItems => [NO_MANGLE_CONST_ITEMS, NO_MANGLE_GEN
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
let attrs = cx.tcx.hir().attrs(it.hir_id());
|
||||
let attrs = cx.tcx.hir_attrs(it.hir_id());
|
||||
let check_no_mangle_on_generic_fn = |no_mangle_attr: &hir::Attribute,
|
||||
impl_generics: Option<&hir::Generics<'_>>,
|
||||
generics: &hir::Generics<'_>,
|
||||
|
@ -1050,7 +1050,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||
for it in *items {
|
||||
if let hir::AssocItemKind::Fn { .. } = it.kind {
|
||||
if let Some(no_mangle_attr) =
|
||||
attr::find_by_name(cx.tcx.hir().attrs(it.id.hir_id()), sym::no_mangle)
|
||||
attr::find_by_name(cx.tcx.hir_attrs(it.id.hir_id()), sym::no_mangle)
|
||||
{
|
||||
check_no_mangle_on_generic_fn(
|
||||
no_mangle_attr,
|
||||
|
|
|
@ -38,7 +38,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
|
|||
}
|
||||
LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
|
||||
// We are an `eval_always` query, so looking at the attribute's `AttrId` is ok.
|
||||
let attr_id = tcx.hir().attrs(hir_id)[attr_index as usize].id();
|
||||
let attr_id = tcx.hir_attrs(hir_id)[attr_index as usize].id();
|
||||
|
||||
(attr_id, lint_index)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
|
|||
where
|
||||
F: FnOnce(&mut Self),
|
||||
{
|
||||
let attrs = self.context.tcx.hir().attrs(id);
|
||||
let attrs = self.context.tcx.hir_attrs(id);
|
||||
let prev = self.context.last_node_with_lint_attrs;
|
||||
self.context.last_node_with_lint_attrs = id;
|
||||
debug!("late context: enter_attrs({:?})", attrs);
|
||||
|
|
|
@ -342,8 +342,8 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
|
|||
let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name {
|
||||
Some(Ident::from_str(name))
|
||||
} else {
|
||||
ast::attr::find_by_name(cx.tcx.hir().attrs(hir::CRATE_HIR_ID), sym::crate_name)
|
||||
.and_then(|attr| {
|
||||
ast::attr::find_by_name(cx.tcx.hir_attrs(hir::CRATE_HIR_ID), sym::crate_name).and_then(
|
||||
|attr| {
|
||||
if let Attribute::Unparsed(n) = attr
|
||||
&& let AttrItem { args: AttrArgs::Eq { eq_span: _, expr: lit }, .. } =
|
||||
n.as_ref()
|
||||
|
@ -371,7 +371,8 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
|
|||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
};
|
||||
|
||||
if let Some(ident) = &crate_ident {
|
||||
|
@ -500,7 +501,7 @@ impl NonUpperCaseGlobals {
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
let attrs = cx.tcx.hir().attrs(it.hir_id());
|
||||
let attrs = cx.tcx.hir_attrs(it.hir_id());
|
||||
match it.kind {
|
||||
hir::ItemKind::Static(..) if !ast::attr::contains_name(attrs, sym::no_mangle) => {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident);
|
||||
|
|
|
@ -1589,7 +1589,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDeclarations {
|
||||
fn check_foreign_item(&mut self, cx: &LateContext<'tcx>, it: &hir::ForeignItem<'tcx>) {
|
||||
let mut vis = ImproperCTypesVisitor { cx, mode: CItemKind::Declaration };
|
||||
let abi = cx.tcx.hir().get_foreign_abi(it.hir_id());
|
||||
let abi = cx.tcx.hir_get_foreign_abi(it.hir_id());
|
||||
|
||||
match it.kind {
|
||||
hir::ForeignItemKind::Fn(sig, _, _) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue