Make use of new outer_expn_info() function
This commit is contained in:
@@ -594,8 +594,7 @@ fn is_used(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
|
|||||||
fn in_attributes_expansion(expr: &Expr) -> bool {
|
fn in_attributes_expansion(expr: &Expr) -> bool {
|
||||||
expr.span
|
expr.span
|
||||||
.ctxt()
|
.ctxt()
|
||||||
.outer()
|
.outer_expn_info()
|
||||||
.expn_info()
|
|
||||||
.map_or(false, |info| matches!(info.format, ExpnFormat::MacroAttribute(_)))
|
.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 {
|
fn get_outer_span(expr: &Expr) -> Span {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let Some(first) = expr.span.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();
|
if let Some(second) = first.call_site.ctxt().outer_expn_info();
|
||||||
then {
|
then {
|
||||||
second.call_site
|
second.call_site
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ranges {
|
|||||||
then {
|
then {
|
||||||
let span = expr.span
|
let span = expr.span
|
||||||
.ctxt()
|
.ctxt()
|
||||||
.outer()
|
.outer_expn_info()
|
||||||
.expn_info()
|
|
||||||
.map_or(expr.span, |info| info.call_site);
|
.map_or(expr.span, |info| info.call_site);
|
||||||
span_lint_and_then(
|
span_lint_and_then(
|
||||||
cx,
|
cx,
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ fn attr_is_cfg(attr: &ast::Attribute) -> bool {
|
|||||||
|
|
||||||
// get the def site
|
// get the def site
|
||||||
fn get_def(span: Span) -> Option<Span> {
|
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?
|
// is this expr a `()` unit?
|
||||||
|
|||||||
@@ -156,8 +156,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
|
|||||||
// actual span that invoked `declare_tool_lint!`:
|
// actual span that invoked `declare_tool_lint!`:
|
||||||
let lint_span = lint_span
|
let lint_span = lint_span
|
||||||
.ctxt()
|
.ctxt()
|
||||||
.outer()
|
.outer_expn_info()
|
||||||
.expn_info()
|
|
||||||
.map(|ei| ei.call_site)
|
.map(|ei| ei.call_site)
|
||||||
.expect("unable to get 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
|
/// Returns `true` if this `expn_info` was expanded by any macro or desugaring
|
||||||
pub fn in_macro_or_desugar(span: Span) -> bool {
|
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.
|
/// Returns `true` if this `expn_info` was expanded by any macro.
|
||||||
pub fn in_macro(span: Span) -> bool {
|
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 {
|
if let ExpnFormat::CompilerDesugaring(..) = info.format {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
@@ -691,11 +691,7 @@ pub fn is_adjusted(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
|
|||||||
/// See also `is_direct_expn_of`.
|
/// See also `is_direct_expn_of`.
|
||||||
pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
|
pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
|
||||||
loop {
|
loop {
|
||||||
let span_name_span = span
|
let span_name_span = span.ctxt().outer_expn_info().map(|ei| (ei.format.name(), ei.call_site));
|
||||||
.ctxt()
|
|
||||||
.outer()
|
|
||||||
.expn_info()
|
|
||||||
.map(|ei| (ei.format.name(), ei.call_site));
|
|
||||||
|
|
||||||
match span_name_span {
|
match span_name_span {
|
||||||
Some((mac_name, new_span)) if mac_name.as_str() == name => return Some(new_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
|
/// `bar!` by
|
||||||
/// `is_direct_expn_of`.
|
/// `is_direct_expn_of`.
|
||||||
pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
|
pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
|
||||||
let span_name_span = span
|
let span_name_span = span.ctxt().outer_expn_info().map(|ei| (ei.format.name(), ei.call_site));
|
||||||
.ctxt()
|
|
||||||
.outer()
|
|
||||||
.expn_info()
|
|
||||||
.map(|ei| (ei.format.name(), ei.call_site));
|
|
||||||
|
|
||||||
match span_name_span {
|
match span_name_span {
|
||||||
Some((mac_name, new_span)) if mac_name.as_str() == name => Some(new_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>:`
|
// report the error around the `vec!` not inside `<std macros>:`
|
||||||
let span = arg.span
|
let span = arg.span
|
||||||
.ctxt()
|
.ctxt()
|
||||||
.outer()
|
.outer_expn_info()
|
||||||
.expn_info()
|
|
||||||
.map(|info| info.call_site)
|
.map(|info| info.call_site)
|
||||||
.expect("unable to get call_site")
|
.expect("unable to get call_site")
|
||||||
.ctxt()
|
.ctxt()
|
||||||
.outer()
|
.outer_expn_info()
|
||||||
.expn_info()
|
|
||||||
.map(|info| info.call_site)
|
.map(|info| info.call_site)
|
||||||
.expect("unable to get call_site");
|
.expect("unable to get call_site");
|
||||||
check_vec_macro(cx, &vec_args, span);
|
check_vec_macro(cx, &vec_args, span);
|
||||||
|
|||||||
Reference in New Issue
Block a user