diff options
| -rw-r--r-- | compiler/rustc_builtin_macros/src/env.rs | 2 | ||||
| -rw-r--r-- | tests/ui/macros/builtin-env-issue-114010.rs | 6 | ||||
| -rw-r--r-- | tests/ui/macros/builtin-env-issue-114010.stderr | 11 |
3 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs index bcff475f626..30d74ba593c 100644 --- a/compiler/rustc_builtin_macros/src/env.rs +++ b/compiler/rustc_builtin_macros/src/env.rs @@ -84,7 +84,7 @@ pub fn expand_env<'cx>( // Use the string literal in the code in the diagnostic to avoid confusing diagnostics, // e.g. when the literal contains escape sequences. let ast::ExprKind::Lit(ast::token::Lit { - kind: ast::token::LitKind::Str, + kind: ast::token::LitKind::Str | ast::token::LitKind::StrRaw(..), symbol: original_var, .. }) = &var_expr.kind diff --git a/tests/ui/macros/builtin-env-issue-114010.rs b/tests/ui/macros/builtin-env-issue-114010.rs new file mode 100644 index 00000000000..eb97c767fa2 --- /dev/null +++ b/tests/ui/macros/builtin-env-issue-114010.rs @@ -0,0 +1,6 @@ +// unset-rustc-env:oopsie + +env![r#"oopsie"#]; +//~^ ERROR environment variable `oopsie` not defined at compile time + +fn main() {} diff --git a/tests/ui/macros/builtin-env-issue-114010.stderr b/tests/ui/macros/builtin-env-issue-114010.stderr new file mode 100644 index 00000000000..7934ce1b790 --- /dev/null +++ b/tests/ui/macros/builtin-env-issue-114010.stderr @@ -0,0 +1,11 @@ +error: environment variable `oopsie` not defined at compile time + --> $DIR/builtin-env-issue-114010.rs:3:1 + | +LL | env![r#"oopsie"#]; + | ^^^^^^^^^^^^^^^^^ + | + = help: use `std::env::var("oopsie")` to read the variable at run time + = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + |
