Fix lifetime error to print 'a instead of &'a#14317
Conversation
src/librustc/util/ppaux.rs
Outdated
There was a problem hiding this comment.
.to_strbuf() here is unnecessary allocation.
|
Do we really want to print |
|
@kballard: I think it would indeed be better to only print it on errors relating to lifetimes. The only reason I didn’t do so was because I thought it would be slightly more complex to implement, and I wanted to see others’ opinion on this. Regarding naming, originally in my code I made it print something like |
|
Something like |
|
I agree that these error messages have predominately taken a step backwards. If this is fixing a problem where the compiler says it found |
|
@alexcrichton I’m not sure I understand what you mean by “the same string as the lifetime”. As I’m still finding my way around the compiler code, I’m struggling to locate the actual code relating to the lifetime errors so that I can specialise the display of anonymous lifetimes for them only. Given that the naming of anonymous lifetimes isn’t actually part of #10291 (it only properly concerns a confusing |
|
In the compiler message where it says that it found It'd be fine to leave out |
'a instead of '&'a'a instead of &'a
|
I’ve updated the PR to remove the code about anonymous lifetimes. (I also fixed a typo in the title/commit message.) |
|
Would it be possible to add a test for this as well? (testing the error message) |
This changes certain error messages about lifetimes so that they display lifetimes without an `&`. Fixes rust-lang#10291.
|
I’ve added a test, and it passes locally, but I’m not sure if it’s extensive enough. Should that be good enough? |
This changes certain error messages about lifetimes so that they display lifetimes without an `&`. Fixes #10291.
…-lang#14317) It is not possible to write a declarative macro, that produces an attribute w/o an item attached to it. This means that the `check_item` will already insert the span in the map, if it came from an expansion. So additionally checking if the macro came from an expansion doesn't add anything here. So the `check_attribute` function, and with that the problematic `attr.span()` call can be completely removed. Fixes rust-lang/rust-clippy#14303 r? @y21 cc @jdonszelmann changelog: Fix ICE in [`macro_use_import`] lint
This changes certain error messages about lifetimes so that they display lifetimes without an
&.Fixes #10291.