Skip to content

Commit

Permalink
Unrolled build for rust-lang#117592
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#117592 - thomcc:env-span-wrong, r=davidtwco

Use the correct span when emitting the `env!` result

The span used for the `env!` resut changed in 1.73, due to rust-lang@75df62d (from rust-lang#114014).

This prevents [a lint in `plrustc`](https://github.com/tcdi/plrust/blob/main/plrustc/plrustc/src/lints/builtin_macros.rs#L54-L60)[^1] from working well, because the resulting span is not inside the  region where the lint is `#[deny()]`ed.

[^1]: Perhaps worth noting that the `env_macro` diagnostic item comes from [the std fork used with PL/Rust](https://github.com/tcdi/postgrestd/blob/rust-1.73.0/library/core/src/macros/mod.rs#L944).

Unfortunately, I have no idea how to write a test for this since I don't think we can have a custom lint in a test. A suggestion was made to use a custom proc macro for it, but that seems pretty involved (frankly, I might not have time to do it).

r? ``@davidtwco`` (since they're the author of the PR with the regression)

P.S. We generally try to avoid bothering upstream about PL/Rust-specific stuff (we don't want to nag), but this seems like an actual bug, since the other similar macros, such as `option_env` use the other span (and are lintable as a result).
  • Loading branch information
rust-timer committed Nov 6, 2023
2 parents 6bf2fb3 + 86fca87 commit 07a8ba1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn expand_env<'cx>(

return DummyResult::any(sp);
}
Some(value) => cx.expr_str(sp, value),
Some(value) => cx.expr_str(span, value),
};
MacEager::expr(e)
}
Expand Down

0 comments on commit 07a8ba1

Please sign in to comment.