mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 09:27:25 +00:00
Make use of new outer_expn_info()
function
This commit is contained in:
parent
f3087c37bf
commit
f67c3e4b2a
7 changed files with 12 additions and 25 deletions
|
@ -594,8 +594,7 @@ fn is_used(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
|
|||
fn in_attributes_expansion(expr: &Expr) -> bool {
|
||||
expr.span
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.outer_expn_info()
|
||||
.map_or(false, |info| matches!(info.format, ExpnFormat::MacroAttribute(_)))
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented {
|
|||
|
||||
fn get_outer_span(expr: &Expr) -> Span {
|
||||
if_chain! {
|
||||
if let Some(first) = expr.span.ctxt().outer().expn_info();
|
||||
if let Some(second) = first.call_site.ctxt().outer().expn_info();
|
||||
if let Some(first) = expr.span.ctxt().outer_expn_info();
|
||||
if let Some(second) = first.call_site.ctxt().outer_expn_info();
|
||||
then {
|
||||
second.call_site
|
||||
} else {
|
||||
|
|
|
@ -148,8 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ranges {
|
|||
then {
|
||||
let span = expr.span
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.outer_expn_info()
|
||||
.map_or(expr.span, |info| info.call_site);
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
|
|
|
@ -272,7 +272,7 @@ fn attr_is_cfg(attr: &ast::Attribute) -> bool {
|
|||
|
||||
// get the def site
|
||||
fn get_def(span: Span) -> Option<Span> {
|
||||
span.ctxt().outer().expn_info().and_then(|info| info.def_site)
|
||||
span.ctxt().outer_expn_info().and_then(|info| info.def_site)
|
||||
}
|
||||
|
||||
// is this expr a `()` unit?
|
||||
|
|
|
@ -156,8 +156,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
|
|||
// actual span that invoked `declare_tool_lint!`:
|
||||
let lint_span = lint_span
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.outer_expn_info()
|
||||
.map(|ei| ei.call_site)
|
||||
.expect("unable to get call_site");
|
||||
|
||||
|
|
|
@ -94,12 +94,12 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool {
|
|||
|
||||
/// Returns `true` if this `expn_info` was expanded by any macro or desugaring
|
||||
pub fn in_macro_or_desugar(span: Span) -> bool {
|
||||
span.ctxt().outer().expn_info().is_some()
|
||||
span.ctxt().outer_expn_info().is_some()
|
||||
}
|
||||
|
||||
/// Returns `true` if this `expn_info` was expanded by any macro.
|
||||
pub fn in_macro(span: Span) -> bool {
|
||||
if let Some(info) = span.ctxt().outer().expn_info() {
|
||||
if let Some(info) = span.ctxt().outer_expn_info() {
|
||||
if let ExpnFormat::CompilerDesugaring(..) = info.format {
|
||||
false
|
||||
} else {
|
||||
|
@ -691,11 +691,7 @@ pub fn is_adjusted(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
|
|||
/// See also `is_direct_expn_of`.
|
||||
pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
|
||||
loop {
|
||||
let span_name_span = span
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.map(|ei| (ei.format.name(), ei.call_site));
|
||||
let span_name_span = span.ctxt().outer_expn_info().map(|ei| (ei.format.name(), ei.call_site));
|
||||
|
||||
match span_name_span {
|
||||
Some((mac_name, new_span)) if mac_name.as_str() == name => return Some(new_span),
|
||||
|
@ -715,11 +711,7 @@ pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
|
|||
/// `bar!` by
|
||||
/// `is_direct_expn_of`.
|
||||
pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
|
||||
let span_name_span = span
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.map(|ei| (ei.format.name(), ei.call_site));
|
||||
let span_name_span = span.ctxt().outer_expn_info().map(|ei| (ei.format.name(), ei.call_site));
|
||||
|
||||
match span_name_span {
|
||||
Some((mac_name, new_span)) if mac_name.as_str() == name => Some(new_span),
|
||||
|
|
|
@ -49,13 +49,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessVec {
|
|||
// report the error around the `vec!` not inside `<std macros>:`
|
||||
let span = arg.span
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.outer_expn_info()
|
||||
.map(|info| info.call_site)
|
||||
.expect("unable to get call_site")
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.outer_expn_info()
|
||||
.map(|info| info.call_site)
|
||||
.expect("unable to get call_site");
|
||||
check_vec_macro(cx, &vec_args, span);
|
||||
|
|
Loading…
Reference in a new issue