Skip to content

Commit c06a7eb

Browse files
committed
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 <[email protected]>
1 parent ced592a commit c06a7eb

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

compiler/rustc_builtin_macros/src/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn expand_env<'cx>(
8484
// Use the string literal in the code in the diagnostic to avoid confusing diagnostics,
8585
// e.g. when the literal contains escape sequences.
8686
let ast::ExprKind::Lit(ast::token::Lit {
87-
kind: ast::token::LitKind::Str,
87+
kind: ast::token::LitKind::Str | ast::token::LitKind::StrRaw(..),
8888
symbol: original_var,
8989
..
9090
}) = &var_expr.kind
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// unset-rustc-env:oopsie
2+
3+
env![r#"oopsie"#];
4+
//~^ ERROR environment variable `oopsie` not defined at compile time
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: environment variable `oopsie` not defined at compile time
2+
--> $DIR/builtin-env-issue-114010.rs:3:1
3+
|
4+
LL | env![r#"oopsie"#];
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= help: use `std::env::var("oopsie")` to read the variable at run time
8+
= note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
9+
10+
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)