-
Notifications
You must be signed in to change notification settings - Fork 13.3k
large_assignments
: Unactionable diagnostics with -Zinline-mir
#121672
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
Comments
heh. we used to have a marker in spans that signaled that something got inlined. That was a bit funky though, so we removed it (#111950). You can check the source scopes nowadays to see if https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.SourceScopeData.html#structfield.inlined has been set. If it is set, don't emit the lint on that span, but instead emit it on the span within that option |
@rustbot claim |
report call site of inlined scopes for large assignment lints Addressed issue: rust-lang#121672 Tracking issue: rust-lang#83518 r? `@oli-obk` I tried to follow your comment about what to do [here](rust-lang#121672 (comment)). However, I'm totally unfamiliar with the code so far (this is my first contribution touching compiler code), so I apologize in advance if I did something stupid 😅 In particular, I'm not sure I use the _correct_ source scope to look for inline data, as there is a whole `IndexVec` of them. My changes definitely did something, as can be seen by the added ui test. However, the result is not as anticipated in the issue: ``` LL | let cell = std::cell::UnsafeCell::new(data); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here ``` instead of ``` LL | let cell = std::cell::UnsafeCell::new(data); | ^^^^ value moved from here ``` raising my suspicion that maybe I got the wrong source scope.
Rollup merge of rust-lang#139551 - jogru0:121672, r=oli-obk report call site of inlined scopes for large assignment lints Addressed issue: rust-lang#121672 Tracking issue: rust-lang#83518 r? `@oli-obk` I tried to follow your comment about what to do [here](rust-lang#121672 (comment)). However, I'm totally unfamiliar with the code so far (this is my first contribution touching compiler code), so I apologize in advance if I did something stupid 😅 In particular, I'm not sure I use the _correct_ source scope to look for inline data, as there is a whole `IndexVec` of them. My changes definitely did something, as can be seen by the added ui test. However, the result is not as anticipated in the issue: ``` LL | let cell = std::cell::UnsafeCell::new(data); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here ``` instead of ``` LL | let cell = std::cell::UnsafeCell::new(data); | ^^^^ value moved from here ``` raising my suspicion that maybe I got the wrong source scope.
report call site of inlined scopes for large assignment lints Addressed issue: #121672 Tracking issue: #83518 r? `@oli-obk` I tried to follow your comment about what to do [here](rust-lang/rust#121672 (comment)). However, I'm totally unfamiliar with the code so far (this is my first contribution touching compiler code), so I apologize in advance if I did something stupid 😅 In particular, I'm not sure I use the _correct_ source scope to look for inline data, as there is a whole `IndexVec` of them. My changes definitely did something, as can be seen by the added ui test. However, the result is not as anticipated in the issue: ``` LL | let cell = std::cell::UnsafeCell::new(data); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here ``` instead of ``` LL | let cell = std::cell::UnsafeCell::new(data); | ^^^^ value moved from here ``` raising my suspicion that maybe I got the wrong source scope.
#139551 made progress on this issue, it now shows
but still not the expected
@oli-obk You mentioned here that we might want to adjust something so we don't loose the argument span when inlining happens. If that's something that might make sense for me to look into and you could give me some directions/mentoring for that, I'm happy to try it. However, that's certainly not something I know how to do on my own, so if this topic would be too involved for that, I can also just unassign this issue from me and let someone more experienced take over. |
In https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_transform/src/inline.rs#L1081 we are ignoring the You could try this on its own to get your hands dirty with the To fix the actual issue you were encountering we'll have to go to where the args from But looking at that now, I don't think this is actually resolvable here. The spans and locals should all already be correct, but the later mir-optimizations remove those locals without adjusting debug information, so the local with the right span is erased and only the locals that were inlined are left. I do not know where this happens, but if you want to do some exploration, you can use |
Thanks for the detailed explanation, really appreciated it. I tried to look into it a bit, but unfortunately, I think this is a bit too advanced for me. So I'll unassign myself for now so someone else can take over who is able to work on this more effectively. @rustbot release-assignment |
Tracking issue #83518.
Doing
cargo build --release
will activate-Zinline-mir
under the hood (through-Copt-level=3
). But it makeslarge_assignments
diagnostics unhelpful, because it can make diagnostics point to library code that the user can't change.How to reproduce
src/main.rs
# One of: cargo +nightly build --release cargo +nightly rustc -- -Zmir-opt-level=1 -Zinline-mir
Actual
Expected
Remarks
The expected diagnostics is given with these commands. Note how
-Zinline-mir
is deactivated in both cases:# One of: cargo +nightly build cargo +nightly rustc -- -Zmir-opt-level=1
The above test case is ui-testified here.
CC E-mentor @oli-obk who maybe have an idea on how to fix this? (I currently don't.)
The text was updated successfully, but these errors were encountered: