Rename NestedMetaItem to MetaItemInner
This commit is contained in:
parent
d0507302fc
commit
2226f16945
@ -1,15 +1,15 @@
|
|||||||
use super::{ALLOW_ATTRIBUTES_WITHOUT_REASON, Attribute};
|
use super::{ALLOW_ATTRIBUTES_WITHOUT_REASON, Attribute};
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::is_from_proc_macro;
|
use clippy_utils::is_from_proc_macro;
|
||||||
use rustc_ast::{MetaItemKind, NestedMetaItem};
|
use rustc_ast::{MetaItemInner, MetaItemKind};
|
||||||
use rustc_lint::{LateContext, LintContext};
|
use rustc_lint::{LateContext, LintContext};
|
||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
|
||||||
pub(super) fn check<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMetaItem], attr: &'cx Attribute) {
|
pub(super) fn check<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[MetaItemInner], attr: &'cx Attribute) {
|
||||||
// Check if the reason is present
|
// Check if the reason is present
|
||||||
if let Some(item) = items.last().and_then(NestedMetaItem::meta_item)
|
if let Some(item) = items.last().and_then(MetaItemInner::meta_item)
|
||||||
&& let MetaItemKind::NameValue(_) = &item.kind
|
&& let MetaItemKind::NameValue(_) = &item.kind
|
||||||
&& item.path == sym::reason
|
&& item.path == sym::reason
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use super::BLANKET_CLIPPY_RESTRICTION_LINTS;
|
use super::BLANKET_CLIPPY_RESTRICTION_LINTS;
|
||||||
use super::utils::extract_clippy_lint;
|
use super::utils::extract_clippy_lint;
|
||||||
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
|
||||||
use rustc_ast::NestedMetaItem;
|
use rustc_ast::MetaItemInner;
|
||||||
use rustc_lint::{LateContext, Level, LintContext};
|
use rustc_lint::{LateContext, Level, LintContext};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{DUMMY_SP, sym};
|
use rustc_span::{DUMMY_SP, sym};
|
||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'_>, name: Symbol, items: &[NestedMetaItem]) {
|
pub(super) fn check(cx: &LateContext<'_>, name: Symbol, items: &[MetaItemInner]) {
|
||||||
for lint in items {
|
for lint in items {
|
||||||
if let Some(lint_name) = extract_clippy_lint(lint) {
|
if let Some(lint_name) = extract_clippy_lint(lint) {
|
||||||
if lint_name.as_str() == "restriction" && name != sym::allow {
|
if lint_name.as_str() == "restriction" && name != sym::allow {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
use clippy_config::Conf;
|
use clippy_config::Conf;
|
||||||
use clippy_config::msrvs::{self, Msrv};
|
use clippy_config::msrvs::{self, Msrv};
|
||||||
use rustc_ast::{Attribute, MetaItemKind, NestedMetaItem};
|
use rustc_ast::{Attribute, MetaItemInner, MetaItemKind};
|
||||||
use rustc_hir::{ImplItem, Item, ItemKind, TraitItem};
|
use rustc_hir::{ImplItem, Item, ItemKind, TraitItem};
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
|
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
@ -456,7 +456,7 @@ fn check_attribute(&mut self, cx: &LateContext<'tcx>, attr: &'tcx Attribute) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for item in items {
|
for item in items {
|
||||||
if let NestedMetaItem::MetaItem(mi) = &item
|
if let MetaItemInner::MetaItem(mi) = &item
|
||||||
&& let MetaItemKind::NameValue(lit) = &mi.kind
|
&& let MetaItemKind::NameValue(lit) = &mi.kind
|
||||||
&& mi.has_name(sym::since)
|
&& mi.has_name(sym::since)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::{Attribute, NON_MINIMAL_CFG};
|
use super::{Attribute, NON_MINIMAL_CFG};
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::SpanRangeExt;
|
use clippy_utils::source::SpanRangeExt;
|
||||||
use rustc_ast::{MetaItemKind, NestedMetaItem};
|
use rustc_ast::{MetaItemInner, MetaItemKind};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_lint::EarlyContext;
|
use rustc_lint::EarlyContext;
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
@ -14,9 +14,9 @@ pub(super) fn check(cx: &EarlyContext<'_>, attr: &Attribute) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_nested_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
|
fn check_nested_cfg(cx: &EarlyContext<'_>, items: &[MetaItemInner]) {
|
||||||
for item in items {
|
for item in items {
|
||||||
if let NestedMetaItem::MetaItem(meta) = item {
|
if let MetaItemInner::MetaItem(meta) = item {
|
||||||
if !meta.has_name(sym::any) && !meta.has_name(sym::all) {
|
if !meta.has_name(sym::any) && !meta.has_name(sym::all) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
use super::{Attribute, USELESS_ATTRIBUTE};
|
use super::{Attribute, USELESS_ATTRIBUTE};
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::{SpanRangeExt, first_line_of_span};
|
use clippy_utils::source::{SpanRangeExt, first_line_of_span};
|
||||||
use rustc_ast::NestedMetaItem;
|
use rustc_ast::MetaItemInner;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Item, ItemKind};
|
use rustc_hir::{Item, ItemKind};
|
||||||
use rustc_lint::{LateContext, LintContext};
|
use rustc_lint::{LateContext, LintContext};
|
||||||
@ -21,7 +21,7 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute])
|
|||||||
for lint in lint_list {
|
for lint in lint_list {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ItemKind::Use(..) => {
|
ItemKind::Use(..) => {
|
||||||
if let NestedMetaItem::MetaItem(meta_item) = lint
|
if let MetaItemInner::MetaItem(meta_item) = lint
|
||||||
&& meta_item.is_word()
|
&& meta_item.is_word()
|
||||||
&& let Some(ident) = meta_item.ident()
|
&& let Some(ident) = meta_item.ident()
|
||||||
&& matches!(
|
&& matches!(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use clippy_utils::macros::{is_panic, macro_backtrace};
|
use clippy_utils::macros::{is_panic, macro_backtrace};
|
||||||
use rustc_ast::{AttrId, NestedMetaItem};
|
use rustc_ast::{AttrId, MetaItemInner};
|
||||||
use rustc_hir::{
|
use rustc_hir::{
|
||||||
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
|
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
|
||||||
};
|
};
|
||||||
@ -8,8 +8,8 @@
|
|||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
|
||||||
pub(super) fn is_word(nmi: &NestedMetaItem, expected: Symbol) -> bool {
|
pub(super) fn is_word(nmi: &MetaItemInner, expected: Symbol) -> bool {
|
||||||
if let NestedMetaItem::MetaItem(mi) = &nmi {
|
if let MetaItemInner::MetaItem(mi) = &nmi {
|
||||||
mi.is_word() && mi.has_name(expected)
|
mi.is_word() && mi.has_name(expected)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@ -74,7 +74,7 @@ fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the lint name if it is clippy lint.
|
/// Returns the lint name if it is clippy lint.
|
||||||
pub(super) fn extract_clippy_lint(lint: &NestedMetaItem) -> Option<Symbol> {
|
pub(super) fn extract_clippy_lint(lint: &MetaItemInner) -> Option<Symbol> {
|
||||||
if let Some(meta_item) = lint.meta_item()
|
if let Some(meta_item) = lint.meta_item()
|
||||||
&& meta_item.path.segments.len() > 1
|
&& meta_item.path.segments.len() > 1
|
||||||
&& let tool_name = meta_item.path.segments[0].ident
|
&& let tool_name = meta_item.path.segments[0].ident
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use rustc_ast::NestedMetaItem;
|
use rustc_ast::MetaItemInner;
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||||
use rustc_session::declare_lint_pass;
|
use rustc_session::declare_lint_pass;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &rustc_ast::Attribute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contains_not_test(list: Option<&[NestedMetaItem]>, not: bool) -> bool {
|
fn contains_not_test(list: Option<&[MetaItemInner]>, not: bool) -> bool {
|
||||||
list.is_some_and(|list| {
|
list.is_some_and(|list| {
|
||||||
list.iter().any(|item| {
|
list.iter().any(|item| {
|
||||||
item.ident().is_some_and(|ident| match ident.name {
|
item.ident().is_some_and(|ident| match ident.name {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
path_to_local_id, span_contains_cfg, span_find_starting_semi,
|
path_to_local_id, span_contains_cfg, span_find_starting_semi,
|
||||||
};
|
};
|
||||||
use core::ops::ControlFlow;
|
use core::ops::ControlFlow;
|
||||||
use rustc_ast::NestedMetaItem;
|
use rustc_ast::MetaItemInner;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::LangItem::ResultErr;
|
use rustc_hir::LangItem::ResultErr;
|
||||||
use rustc_hir::intravisit::FnKind;
|
use rustc_hir::intravisit::FnKind;
|
||||||
@ -421,7 +421,7 @@ fn check_final_expr<'tcx>(
|
|||||||
if matches!(Level::from_attr(attr), Some(Level::Expect(_)))
|
if matches!(Level::from_attr(attr), Some(Level::Expect(_)))
|
||||||
&& let metas = attr.meta_item_list()
|
&& let metas = attr.meta_item_list()
|
||||||
&& let Some(lst) = metas
|
&& let Some(lst) = metas
|
||||||
&& let [NestedMetaItem::MetaItem(meta_item), ..] = lst.as_slice()
|
&& let [MetaItemInner::MetaItem(meta_item), ..] = lst.as_slice()
|
||||||
&& let [tool, lint_name] = meta_item.path.segments.as_slice()
|
&& let [tool, lint_name] = meta_item.path.segments.as_slice()
|
||||||
&& tool.ident.name == sym::clippy
|
&& tool.ident.name == sym::clippy
|
||||||
&& matches!(
|
&& matches!(
|
||||||
|
Loading…
Reference in New Issue
Block a user