Skip to content

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

Closed
@Shadlock0133

Description

@Shadlock0133

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions