Uh oh!
There was an error while loading. Please reload this page.
Set CompilerDesugaring expn_info for all desugared expressions - #39766
Set CompilerDesugaring expn_info for all desugared expressions#39766sinkuu wants to merge 3 commits into
Conversation
sinkuu
commented
Feb 15, 2017
It looks like the highfive bot has missed this PR. Can anyone review this? |
bors
commented
Feb 25, 2017
☔ The latest upstream changes (presumably #40091) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @Manishearth noone seems to want to take this, and it's clippy related ;) |
alexcrichton
commented
Feb 27, 2017
cc @rust-lang/compiler |
eddyb
commented
Feb 27, 2017
r? @jseyfried |
Manishearth
commented
Feb 27, 2017
I would avoid giving sole r+ on PRs that affect clippy |
nrc
commented
Feb 28, 2017
I think we should not do this - we have avoided it in the past. I have tried to keep a strong distinction in the compiler around generated code - in particular lowered code is not generated code. The contract is basically that if the user should recognise that the code is generated (i.e., they used a macro or other form of codegen) then the span should have an expn_info and error messages should be explicit about the expansion. Tools can recognise that the source code does not reflect the compiler's representation and can 'correct' that via the expansion stack. OTOH, code that the user cannot recognise as generated (e.g., I'm not sure how best to help Clippy here. I suspect it should be using a higher level API to the compiler's info, but not sure how that should work in general. |
eddyb
commented
Feb 28, 2017
@nrc For precise spans we need to do this though, however I agree users shouldn't be able to see it. |
nrc
commented
Feb 28, 2017
@eddyb yeah, long term I think we should consider changes - I do envision lowering being reflected in the spans, but distinct from other kinds of generated code (this might just be a flag, but ideally we'd have some way of handling the 'macro definition'). |
@nrc FWIW we already create such spans - we have to, for |
nrc
commented
Feb 28, 2017
@eddyb I'm not sure what you mean by "such spans" - if we did this for lowered expressions then this PR would be redundant, no? I'm not sure how the stability checking works though. |
eddyb
commented
Feb 28, 2017
@nrc We only do it when have to for stability, look for calls to the |
nikomatsakis
commented
Mar 2, 2017
There was a problem hiding this comment.
I definitely think we should not be writing this to the output.
There was a problem hiding this comment.
These lines are required by compiletest, but not shown in rustc output (see the second commit).
eddyb
commented
Mar 2, 2017
@nikomatsakis We already have that distinction, we use it for creating |
nikomatsakis
commented
Mar 2, 2017
@eddyb so ... what are we arguing about exactly? I must be confused. |
eddyb
commented
Mar 2, 2017
@nikomatsakis I am saying we're already using this in some cases, and I'm pretty sure we agree we need unique spans in the future, so I'm in favor of making this change with no user-visible output. |
nikomatsakis
commented
Mar 2, 2017
@eddyb ok I agree with you :) |
nrc
commented
Mar 2, 2017
So I assume the |
eddyb
commented
Mar 2, 2017
I'm not sure how that makes sense? save-analysis doesn't look at HIR spans, does it? |
nrc
commented
Mar 2, 2017
save-analysis certainly looks at HIR nodes (we have to in order to get type check info). We also look at spans from deep inside nodes. I'm not sure if we actually look at spans from HIR nodes because of that, so you are right that it is probably not as bad as I thought. However, it is certainly possible that we do look at some HIR span somewhere, so if we move to doing the span stuff everywhere, then I'd like to make sure we don't break any save-analysis stuff. |
eddyb
commented
Mar 2, 2017
@nrc You should auto-generate a corpus of tests (from run-pass tests or something), IMO. |
nrc
commented
Mar 7, 2017
@eddyb yeah, tests for save-analysis have been on my mind for like the last 6 months. Someday I'll implement them |
bors
commented
Mar 14, 2017
☔ The latest upstream changes (presumably #39921) made this pull request unmergeable. Please resolve the merge conflicts. |
oli-obk
commented
Mar 14, 2017
So what action is required here? |
nrc
commented
Mar 15, 2017
@oli-obk@sinkuu I think this PR needs changing so that the changes are not user-visible (see @nikomatsakis's comments). There is apparently a distinction that can be made between lowered and generated code and that should be used (I was under the impression we couldn't directly do this, but perhaps I don't understand exactly what is meant here) - the stuff in this PR should use that. Finally, we should establish that this does not break save-analysis. To do that, fine the two run-make save-analysis tests. Each should emit a JSON or CSV file when run. Compare the files before and after applying this PR, they should be identical. If the post-PR file is smaller, then there are issues that need addressing. |
oli-obk
commented
Mar 24, 2017
nrc
commented
Mar 27, 2017
@sinkuu did you get a chance to compare the save-analysis output? |
nrc
commented
Mar 27, 2017
I think desugarings should not be user-visible in JSON output either - the expectation is that JSON errors are shown to users fairly directly by tools. I wouldn't expect an IDE (for example) to show the user the macro expansion of a desugared language feature. |
carols10cents
commented
Apr 14, 2017
☔️ merge conflicts! |
arielb1
commented
Apr 25, 2017
🕸 We haven't seen activity on this PR for 2 weeks 🕸, so we're closing it to reduce our backlog. Feel free to reopen if you still want to work on it. |
This PR adds
CompilerDesugaringexpn_info for all compiler desugared expressions. This will ease writing lints which need to exclude them (for example https://github.com/Manishearth/rust-clippy/pull/1513).However, it will add
in this macro invocationnote for every error on syntax-sugar span, which is unhelpful. The 2nd commit removes them.