mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 19:43:24 +00:00
resolve merge of NameAndSpan and ExpnInfo rust-lang/rust#51726
This commit is contained in:
parent
535c168791
commit
203ad28021
@ -558,7 +558,7 @@ fn in_attributes_expansion(expr: &Expr) -> bool {
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.map_or(false, |info| matches!(info.callee.format, ExpnFormat::MacroAttribute(_)))
|
||||
.map_or(false, |info| matches!(info.format, ExpnFormat::MacroAttribute(_)))
|
||||
}
|
||||
|
||||
/// Test whether `def` is a variable defined outside a macro.
|
||||
|
@ -57,7 +57,7 @@ pub fn in_constant(cx: &LateContext, id: NodeId) -> bool {
|
||||
/// Returns true if this `expn_info` was expanded by any macro.
|
||||
pub fn in_macro(span: Span) -> bool {
|
||||
span.ctxt().outer().expn_info().map_or(false, |info| {
|
||||
match info.callee.format {
|
||||
match info.format {
|
||||
// don't treat range expressions desugared to structs as "in_macro"
|
||||
ExpnFormat::CompilerDesugaring(kind) => kind != CompilerDesugaringKind::DotFill,
|
||||
_ => true,
|
||||
@ -68,7 +68,7 @@ pub fn in_macro(span: Span) -> bool {
|
||||
/// Returns true if `expn_info` was expanded by range expressions.
|
||||
pub fn is_range_expression(span: Span) -> bool {
|
||||
span.ctxt().outer().expn_info().map_or(false, |info| {
|
||||
match info.callee.format {
|
||||
match info.format {
|
||||
ExpnFormat::CompilerDesugaring(CompilerDesugaringKind::DotFill) => true,
|
||||
_ => false,
|
||||
}
|
||||
@ -84,12 +84,12 @@ pub fn in_external_macro<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool {
|
||||
/// this after other checks have already happened.
|
||||
fn in_macro_ext<'a, T: LintContext<'a>>(cx: &T, info: &ExpnInfo) -> bool {
|
||||
// no ExpnInfo = no macro
|
||||
if let ExpnFormat::MacroAttribute(..) = info.callee.format {
|
||||
if let ExpnFormat::MacroAttribute(..) = info.format {
|
||||
// these are all plugins
|
||||
return true;
|
||||
}
|
||||
// no span for the callee = external macro
|
||||
info.callee.span.map_or(true, |span| {
|
||||
info.def_site.map_or(true, |span| {
|
||||
// no snippet = external macro or compiler-builtin expansion
|
||||
cx.sess()
|
||||
.codemap()
|
||||
@ -768,7 +768,7 @@ pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
|
||||
let span_name_span = span.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.map(|ei| (ei.callee.name(), ei.call_site));
|
||||
.map(|ei| (ei.format.name(), ei.call_site));
|
||||
|
||||
match span_name_span {
|
||||
Some((mac_name, new_span)) if mac_name == name => return Some(new_span),
|
||||
@ -791,7 +791,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
|
||||
let span_name_span = span.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.map(|ei| (ei.callee.name(), ei.call_site));
|
||||
.map(|ei| (ei.format.name(), ei.call_site));
|
||||
|
||||
match span_name_span {
|
||||
Some((mac_name, new_span)) if mac_name == name => Some(new_span),
|
||||
|
Loading…
Reference in New Issue
Block a user