Skip to content
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

Display function path in unsafety violations - E0133 #96294

Merged
merged 3 commits into from
Apr 26, 2022

Conversation

Emilgardis
Copy link
Contributor

@Emilgardis Emilgardis commented Apr 21, 2022

adds DefId to UnsafetyViolationDetails

this enables consumers to access the function definition that was reported to be unsafe and also changes the output for some E0133 diagnostics

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 21, 2022
@rust-highfive
Copy link
Collaborator

r? @estebank

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2022
@Emilgardis
Copy link
Contributor Author

see (small) zulip discussion

@estebank
Copy link
Contributor

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned estebank Apr 22, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Apr 22, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2022
@bors
Copy link
Contributor

bors commented Apr 22, 2022

⌛ Trying commit 434eb13 with merge 165df72f4556d54e1da1587e70ee8fe7448df49b...

@bors
Copy link
Contributor

bors commented Apr 22, 2022

☀️ Try build successful - checks-actions
Build commit: 165df72f4556d54e1da1587e70ee8fe7448df49b (165df72f4556d54e1da1587e70ee8fe7448df49b)

@rust-timer
Copy link
Collaborator

Queued 165df72f4556d54e1da1587e70ee8fe7448df49b with parent 1158ade, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (165df72f4556d54e1da1587e70ee8fe7448df49b): comparison url.

Summary:

  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: no relevant changes found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 1 0 0 0 1
mean2 1.8% N/A N/A N/A 1.8%
max 1.8% N/A N/A N/A 1.8%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Apr 23, 2022

The perf regression is just the usual syn noise

"call to unsafe function",
CallToUnsafeFunction(did) => (
if let Some(did) = did {
Cow::from(format!("call to unsafe function `{}`", tcx.def_path_str(*did)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure I like this wording

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 23, 2022

You need to update some more //~ ERROR annotations

@Emilgardis Emilgardis force-pushed the def_id-in-unsafetyviolationdetails branch from 2c3c140 to 5644d19 Compare April 23, 2022 19:39
@Emilgardis
Copy link
Contributor Author

Emilgardis commented Apr 23, 2022

Done, I hope.

https://rustc-dev-guide.rust-lang.org/tests/ui.html#cfg-revisions needs to be updated also.

Was thinking about dropping the is unsafe part in the UI tests to make it match in both revisions, but I think this makes more sense.

also, if to be merged, the title should probably be changed

@oli-obk
Copy link
Contributor

oli-obk commented Apr 23, 2022

Ah interesting. The thir unsafety check is what we are moving to, so it may be that some day in the future you may lose all the information you're looking for.

I'm not sure we even have a way of extracting the information you want from THIR.

So for now, this will work, and we'll adjust the thir diagnostics to match, but I'm not sure how to give you what you need in the longer term.

@Emilgardis Emilgardis force-pushed the def_id-in-unsafetyviolationdetails branch from 5644d19 to aeab071 Compare April 24, 2022 12:43
@Emilgardis
Copy link
Contributor Author

fixed the inconsistency between thir and mir, with the added benefit that thir will display a nicer path.

Comment on lines 20 to 21
//[mir]~^ ERROR call to unsafe function `std::thread::__FastLocalKeyInner::<T>::get` is unsafe
//[thir]~^^ ERROR call to unsafe function `__FastLocalKeyInner::<T>::get` is unsafe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the difference between mir and thir now.

sidenote: I don't understand why def_path_str decides to remove std::thread here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That usually happens when there are imports for these modules. Anyway, seems fine to me for now.

@Emilgardis Emilgardis changed the title add DefId to UnsafetyViolationDetails add DefId to unsafety violations and display function path in E0133 Apr 24, 2022
@Emilgardis Emilgardis changed the title add DefId to unsafety violations and display function path in E0133 Display function path in unsafety violations - E0133 Apr 24, 2022
@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 24, 2022
@Emilgardis
Copy link
Contributor Author

I don't know how to solve this but to remove stderr checking

@rust-log-analyzer

This comment has been minimized.

@Emilgardis Emilgardis force-pushed the def_id-in-unsafetyviolationdetails branch from d0be897 to f71597c Compare April 25, 2022 09:30
@Emilgardis
Copy link
Contributor Author

fixed with some normalization :D

@oli-obk
Copy link
Contributor

oli-obk commented Apr 25, 2022

Ah perfect, you found it!

@bors r+

@bors
Copy link
Contributor

bors commented Apr 25, 2022

📌 Commit f71597c has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 25, 2022
@bors
Copy link
Contributor

bors commented Apr 25, 2022

⌛ Testing commit f71597c with merge ec8619d...

@bors
Copy link
Contributor

bors commented Apr 26, 2022

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing ec8619d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 26, 2022
@bors bors merged commit ec8619d into rust-lang:master Apr 26, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 26, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ec8619d): comparison url.

Summary:

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: no relevant changes found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 44 0 0 0 44
mean2 1.3% N/A N/A N/A 1.3%
max 2.9% N/A N/A N/A 2.9%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot added the perf-regression Performance regression. label Apr 26, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Apr 26, 2022

Oh oh, that perf change was unexpected. It's solely in incremental, rereading the source to find out what happened

@oli-obk
Copy link
Contributor

oli-obk commented Apr 26, 2022

@Emilgardis do you still need the def ids in the result of unsafety_check_result? You mentioned working on the THIR now, if that's the case, I'll revert the changes outside of THIR. We'll get the better diagnostics again once we fully move to THIR.

@rylev
Copy link
Member

rylev commented Apr 26, 2022

@oli-obk @Emilgardis Do you expect to be able to address the perf regressions here? It seems they were introduced by a code that's not fundamental to this change since previous perf runs didn't report these regressions. If you're not able to get to it soon, can you please open an issue for this so that it doesn't get lost? Once you do that, we can mark this as triaged.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 26, 2022

Yes, I just need feedback to see if the easy solution can be done first, if not, i'll look into alternative routes.

@Emilgardis
Copy link
Contributor Author

@Emilgardis do you still need the def ids in the result of unsafety_check_result? You mentioned working on the THIR now, if that's the case, I'll revert the changes outside of THIR. We'll get the better diagnostics again once we fully move to THIR.

Go ahead, not needed

@oli-obk
Copy link
Contributor

oli-obk commented Apr 26, 2022

@rustbot label: +perf-regression-triaged

#96425 should address the perf regression

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Apr 26, 2022
@Emilgardis Emilgardis deleted the def_id-in-unsafetyviolationdetails branch April 26, 2022 17:14
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2022
…safety_checking, r=compiler-errors

Fix incremental perf regression unsafety checking

Perf regression introduced in rust-lang#96294

We will simply avoid emitting the name of the unsafe function in MIR unsafeck, since we're moving to THIR unsafeck anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants