mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
expand env!
with def-site context
This commit is contained in:
parent
5239f5c57b
commit
68bf8d2487
@ -77,6 +77,7 @@ pub fn expand_env<'cx>(
|
|||||||
return DummyResult::any(sp);
|
return DummyResult::any(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sp = cx.with_def_site_ctxt(sp);
|
||||||
let e = match env::var(&*var.as_str()) {
|
let e = match env::var(&*var.as_str()) {
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
cx.span_err(sp, &msg.as_str());
|
cx.span_err(sp, &msg.as_str());
|
||||||
|
@ -3,6 +3,8 @@ error: my error message
|
|||||||
|
|
|
|
||||||
LL | fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ error: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined
|
|||||||
|
|
|
|
||||||
LL | env!("__HOPEFULLY_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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ error: environment variable `NON_EXISTENT` not defined
|
|||||||
|
|
|
|
||||||
LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
|
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
|
error: suffixes on a string literal are invalid
|
||||||
--> $DIR/issue-55897.rs:16:22
|
--> $DIR/issue-55897.rs:16:22
|
||||||
|
@ -47,6 +47,8 @@ error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined
|
|||||||
|
|
|
|
||||||
LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST");
|
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
|
error: format argument must be a string literal
|
||||||
--> $DIR/macros-nonfatal-errors.rs:23:13
|
--> $DIR/macros-nonfatal-errors.rs:23:13
|
||||||
|
Loading…
Reference in New Issue
Block a user