-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
give_expl_lifetime_param is silently dropping other formal lifetime params #13058
Comments
(after further experimentation, I suspect the true issue here is that somewhere in the code there is an attempt to substitute |
And it is an ICE if we do try to follow the lifetime hint: ...
fn check<'r, I: Iterator<uint>, T: Itble<'r, uint, I>>(cont: &'r T) -> bool
{
// error: internal compiler error: cannot relate bound region: ReScope(83) <= ReEarlyBound(79, 0, r)
let cont_iter = cont.iter();
...
} |
It looks like I forgot to traverse type parameter bound when rebuilding the function declaration. On the other hand, because of the ICE, it's unclear to me what the right error message should be when a type parameter bound is involved. My thought is that the implementation is kept as is until the ICE gets fixed. Meanwhile, if we see that a type parameter bound is involved, we would do one of the following:
or
|
@ktt3ja do you already have a patch that traverses the type parameter bound? You might as well share that so that we can try applying it, e.g. if i just hypothetically happen to be working on fixing the aforementioned ICE. |
@pnkfelix: Not yet, but I'm working on it. |
@pnkfelix: With PR #13112, this is the output for your example: test.rs:22:1: 32:2 note: consider using an explicit lifetime parameter as shown: fn check<'a, I: Iterator<uint>, T: Itble<'a, uint, I>>(cont: &'a T) -> bool
test.rs:22 fn check<'r, I: Iterator<uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool
test.rs:23 {
test.rs:24 let cont_iter = cont.iter();
test.rs:25 let result = cont_iter.fold(Some(0u16), |state, val| {
test.rs:26 state.map_or(None, |mask| {
test.rs:27 let bit = 1 << val;
...
test.rs:24:21: 24:32 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
test.rs:24 let cont_iter = cont.iter();
^~~~~~~~~~~ |
Add a new configuration settings to set env vars when running cargo, rustc, etc. commands: cargo.extraEnv and checkOnSave.extraEnv It can be extremely useful to be able to set environment variables when rust-analyzer is running various cargo or rustc commands (such as `cargo check`, `cargo --print cfg` or `cargo metadata`): users may want to set custom `RUSTFLAGS`, change `PATH` to use a custom toolchain or set a different `CARGO_HOME`. There is the existing `server.extraEnv` setting that allows env vars to be set when the rust-analyzer server is launched, but using this as the recommended mechanism to also configure cargo/rust has some drawbacks: - It convolutes configuring the rust-analyzer server with configuring cargo/rustc (one may want to change the `PATH` for cargo/rustc without affecting the rust-analyzer server). - The name `server.extraEnv` doesn't indicate that cargo/rustc will be affected but renaming it to `cargo.extraEnv` doesn't indicate that the rust-analyzer server would be affected. - To make the setting useful, it needs to be dynamically reloaded without requiring that the entire extension is reloaded. It might be possible to do this, but it would require the client communicating to the server what the overwritten env vars were at first launch, which isn't easy to do. This change adds two new configuration settings: `cargo.extraEnv` and `checkOnSave.extraEnv` that can be used to change the environment for the rust-analyzer server after launch (thus affecting any process that rust-analyzer invokes) and the `cargo check` command respectively. `cargo.extraEnv` supports dynamic changes by keeping track of the pre-change values of environment variables, thus it can undo changes made previously before applying the new configuration (and then requesting a workspace reload).
(See also #13057 for the non-deterministic behavior of
give_expl_lifetime_param
.)For the input file below, the invocation of rustc that prompts with the "consider using an explicit lifetime parameter" hint is providing an erroneous signature. The reason the provided signature is erroneous is because there is a formal lifetime parameter
'r
that is bound in the generics and also used in the trait bounds of the generics, but the suggested signature drops the formal'r
parameter (while adding'a
) but leaves the existing reference to'r
.Input file (demo.rs):
Transcript:
The text was updated successfully, but these errors were encountered: