diff options
| author | Ralf Jung <post@ralfj.de> | 2020-05-30 23:08:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-30 23:08:46 +0200 |
| commit | 40fb1913e79bc2507c2eca1a458a3338db585de2 (patch) | |
| tree | 1ecc99bd74c50f4942cc94d489092fbc4e30ea57 | |
| parent | fadfcb644e3e549b5b080260d4ca4ea2696e7007 (diff) | |
| parent | 68bf8d2487103f90c0427701cf2247d758de9d13 (diff) | |
| download | rust-40fb1913e79bc2507c2eca1a458a3338db585de2.tar.gz rust-40fb1913e79bc2507c2eca1a458a3338db585de2.zip | |
Rollup merge of #72637 - euclio:env-hygiene, r=davidtwco
expand `env!` with def-site context Similar to #66349. Fixes rust-lang/rust-clippy#5619.
| -rw-r--r-- | src/librustc_builtin_macros/env.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/extenv/extenv-not-defined-custom.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/extenv/extenv-not-defined-default.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/extenv/issue-55897.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/macros/macros-nonfatal-errors.stderr | 2 |
5 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc_builtin_macros/env.rs b/src/librustc_builtin_macros/env.rs index 21e1889513b..d769ebb1f55 100644 --- a/src/librustc_builtin_macros/env.rs +++ b/src/librustc_builtin_macros/env.rs @@ -77,6 +77,7 @@ pub fn expand_env<'cx>( return DummyResult::any(sp); } + let sp = cx.with_def_site_ctxt(sp); let e = match env::var(&*var.as_str()) { Err(_) => { cx.span_err(sp, &msg.as_str()); diff --git a/src/test/ui/extenv/extenv-not-defined-custom.stderr b/src/test/ui/extenv/extenv-not-defined-custom.stderr index 523982dd019..56415fd1f0d 100644 --- a/src/test/ui/extenv/extenv-not-defined-custom.stderr +++ b/src/test/ui/extenv/extenv-not-defined-custom.stderr @@ -3,6 +3,8 @@ error: my error message | LL | fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/extenv/extenv-not-defined-default.stderr b/src/test/ui/extenv/extenv-not-defined-default.stderr index 4bfe330f592..1a9332c4f1c 100644 --- a/src/test/ui/extenv/extenv-not-defined-default.stderr +++ b/src/test/ui/extenv/extenv-not-defined-default.stderr @@ -3,6 +3,8 @@ error: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined | LL | env!("__HOPEFULLY_NOT_DEFINED__"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/extenv/issue-55897.stderr b/src/test/ui/extenv/issue-55897.stderr index c57a467cdba..b62f06e33e5 100644 --- a/src/test/ui/extenv/issue-55897.stderr +++ b/src/test/ui/extenv/issue-55897.stderr @@ -3,6 +3,8 @@ error: environment variable `NON_EXISTENT` not defined | LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: suffixes on a string literal are invalid --> $DIR/issue-55897.rs:16:22 diff --git a/src/test/ui/macros/macros-nonfatal-errors.stderr b/src/test/ui/macros/macros-nonfatal-errors.stderr index 6ef757a55b8..42954ebcdc1 100644 --- a/src/test/ui/macros/macros-nonfatal-errors.stderr +++ b/src/test/ui/macros/macros-nonfatal-errors.stderr @@ -47,6 +47,8 @@ error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined | LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: format argument must be a string literal --> $DIR/macros-nonfatal-errors.rs:23:13 |
