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

cargo clippy --fix with unnecessary_return inside unsafe block with semicolon after the block results in broken code #9503

Closed
Shadlock0133 opened this issue Sep 20, 2022 · 1 comment · Fixed by #9497
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@Shadlock0133
Copy link

Summary

Additional problems were that, because of amount of generated warnings, message about broken code got scrolled outside console's buffer. Maybe there should be extra, short message about broken code at the end?

"Changes reverted because of broken code, full notice at the top."

Also, actual error was without colors, and in the middle of all warnings, making it hard to notice. Maybe don't emit warnings in that case? (with flag to turn them back on: --show-warnings-on-broken-code?)

Reproducer

Currently this:

unsafe fn thing() -> i32 { ... }
fn foo() -> i32 {
    unsafe { return thing() };
}

will get --fixed into:

fn foo() -> i32 {
    unsafe { thing() };
}

Version

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-pc-windows-msvc
release: 1.63.0
LLVM version: 14.0.5

Additional Labels

@rustbot label +I-suggestion-causes-error

@Shadlock0133 Shadlock0133 added the C-bug Category: Clippy is not doing the correct thing label Sep 20, 2022
@rustbot rustbot added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Sep 20, 2022
@kraktus
Copy link
Contributor

kraktus commented Sep 21, 2022

should be fixed by #9497

kraktus added a commit to kraktus/rust-clippy that referenced this issue Sep 22, 2022
kraktus added a commit to kraktus/rust-clippy that referenced this issue Sep 22, 2022
Mark-Simulacrum pushed a commit to kraktus/rust-clippy that referenced this issue Sep 27, 2022
@bors bors closed this as completed in 47c9145 Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants