Skip to content

Commit 9de454e

Browse files
committed
fix nit and compiler error
1 parent dfc3e96 commit 9de454e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/libsyntax/ext/expand.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -532,34 +532,35 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
532532
let path = &mac.node.path;
533533

534534
let ident = ident.unwrap_or_else(|| keywords::Invalid.ident());
535-
let validate_and_set_expn_info = |self_: &mut Self, // arg instead of capture
536-
def_site_span,
535+
let validate_and_set_expn_info = |this: &mut Self, // arg instead of capture
536+
def_site_span: Option<Span>,
537537
allow_internal_unstable,
538538
allow_internal_unsafe,
539539
// can't infer this type
540540
unstable_feature: Option<(Symbol, u32)>| {
541541

542542
// feature-gate the macro invocation
543543
if let Some((feature, issue)) = unstable_feature {
544-
let crate_span = self_.cx.current_expansion.crate_span.unwrap();
544+
let crate_span = this.cx.current_expansion.crate_span.unwrap();
545545
// don't stability-check macros in the same crate
546-
if !crate_span.contains(def_site_span)
547-
&& !span.allows_unstable() && self_.cx.ecfg.features.map_or(true, |feats| {
546+
// (the only time this is null is for syntax extensions registered as macros)
547+
if def_site_span.map_or(false, |def_span| !crate_span.contains(def_span))
548+
&& !span.allows_unstable() && this.cx.ecfg.features.map_or(true, |feats| {
548549
// macro features will count as lib features
549550
!feats.declared_lib_features.iter().any(|&(feat, _)| feat == feature)
550551
}) {
551552
let explain = format!("macro {}! is unstable", path);
552-
emit_feature_err(self_.cx.parse_sess, &*feature.as_str(), span,
553+
emit_feature_err(this.cx.parse_sess, &*feature.as_str(), span,
553554
GateIssue::Library(Some(issue)), &explain);
554-
self_.cx.trace_macros_diag();
555+
this.cx.trace_macros_diag();
555556
return Err(kind.dummy(span));
556557
}
557558
}
558559

559560
if ident.name != keywords::Invalid.name() {
560561
let msg = format!("macro {}! expects no ident argument, given '{}'", path, ident);
561-
self_.cx.span_err(path.span, &msg);
562-
self_.cx.trace_macros_diag();
562+
this.cx.span_err(path.span, &msg);
563+
this.cx.trace_macros_diag();
563564
return Err(kind.dummy(span));
564565
}
565566
mark.set_expn_info(ExpnInfo {

0 commit comments

Comments
 (0)