builtin_macros: expect raw strings too

`expr_to_string` allows raw strings through so this code should be
expected to handle those.

Signed-off-by: David Wood <david@davidtw.co>
This commit is contained in:
David Wood 2023-07-24 15:04:29 +01:00
parent ced592a99b
commit c06a7eb2a6
No known key found for this signature in database
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,6 @@
// unset-rustc-env:oopsie
env![r#"oopsie"#];
//~^ ERROR environment variable `oopsie` not defined at compile time
fn main() {}

View File

@ -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