From a83c35692fa5fc65ec9860599501f1a5a5e98214 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 19 Aug 2019 23:44:57 +0300 Subject: [PATCH] expand: Do not do questionable span adjustment before eagerly expanding an expression Maybe it made sense when it was introduced, but now it's doing something incorrect. --- src/libsyntax/ext/base.rs | 5 +---- src/test/ui/hygiene/eager-from-opaque.rs | 4 +++- src/test/ui/hygiene/eager-from-opaque.stderr | 11 ----------- 3 files changed, 4 insertions(+), 16 deletions(-) delete mode 100644 src/test/ui/hygiene/eager-from-opaque.stderr diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b0a4a6af9839c..376df4062b116 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -908,12 +908,9 @@ impl<'a> ExtCtxt<'a> { /// compilation on error, merely emits a non-fatal error and returns `None`. pub fn expr_to_spanned_string<'a>( cx: &'a mut ExtCtxt<'_>, - mut expr: P, + expr: P, err_msg: &str, ) -> Result<(Symbol, ast::StrStyle, Span), Option>> { - // Update `expr.span`'s ctxt now in case expr is an `include!` macro invocation. - expr.span = expr.span.apply_mark(cx.current_expansion.id); - // Perform eager expansion on the expression. // We want to be able to handle e.g., `concat!("foo", "bar")`. let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr(); diff --git a/src/test/ui/hygiene/eager-from-opaque.rs b/src/test/ui/hygiene/eager-from-opaque.rs index 57925d626b9d1..6f3215dd697f3 100644 --- a/src/test/ui/hygiene/eager-from-opaque.rs +++ b/src/test/ui/hygiene/eager-from-opaque.rs @@ -1,6 +1,8 @@ // Opaque macro can eagerly expand its input without breaking its resolution. // Regression test for issue #63685. +// check-pass + macro_rules! foo { () => { "foo" @@ -9,7 +11,7 @@ macro_rules! foo { macro_rules! bar { () => { - foo!() //~ ERROR cannot find macro `foo!` in this scope + foo!() }; } diff --git a/src/test/ui/hygiene/eager-from-opaque.stderr b/src/test/ui/hygiene/eager-from-opaque.stderr deleted file mode 100644 index f696e6caff7ca..0000000000000 --- a/src/test/ui/hygiene/eager-from-opaque.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: cannot find macro `foo!` in this scope - --> $DIR/eager-from-opaque.rs:12:9 - | -LL | foo!() - | ^^^ -... -LL | format_args!(bar!()); - | ------ in this macro invocation - -error: aborting due to previous error -