]> git.lizzy.rs Git - rust.git/commitdiff
expand `env!` with def-site context
authorAndy Russell <arussell123@gmail.com>
Tue, 26 May 2020 23:45:30 +0000 (19:45 -0400)
committerAndy Russell <arussell123@gmail.com>
Wed, 27 May 2020 01:49:55 +0000 (21:49 -0400)
src/librustc_builtin_macros/env.rs
src/test/ui/extenv/extenv-not-defined-custom.stderr
src/test/ui/extenv/extenv-not-defined-default.stderr
src/test/ui/extenv/issue-55897.stderr
src/test/ui/macros/macros-nonfatal-errors.stderr

index 21e1889513b01457049ba6287c2e25fa9c117a23..d769ebb1f5520d621ef27b299eccee1217607d49 100644 (file)
@@ -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());
index 523982dd0196b099d353ec0d74e007ee9691c213..56415fd1f0dd0ef4cd262f0f1d440cdd3557b5ad 100644 (file)
@@ -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
 
index 4bfe330f59235a9a7b6e599818721ff080be8e8a..1a9332c4f1c9fd6e880457cc13ba18e2788cb960 100644 (file)
@@ -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
 
index c57a467cdba568f17c5dab1a1da5ab1610fab15b..b62f06e33e531ccbf230c6f21d8c12d5e20e6791 100644 (file)
@@ -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
index 6ef757a55b8fb82d2b569ad12684cba406da1151..42954ebcdc1cd4df6e4cdf7f70804773b13ecfca 100644 (file)
@@ -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