Skip to content

Commit

Permalink
Rollup merge of #117592 - thomcc:env-span-wrong, r=davidtwco
Browse files Browse the repository at this point in the history
Use the correct span when emitting the `env!` result

The span used for the `env!` resut changed in 1.73, due to 75df62d (from #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
matthiaskrgr authored Nov 6, 2023
2 parents f9b6446 + 86fca87 commit 60dca87
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 60dca87

Please sign in to comment.