Open ehuss opened 3 years ago
The regression of "Example 1" was introduced between 1.51.0 and 1.52.0. The bisect report gave me three rollup PRs. The bug can be reproduced after this rollup and the suspect may be #82655.
I am not familiar with this part, so if anyone want to address it, just take it. (Or even better mentor me 😆, thanks)
This example attempts to make modifications to the standard library (if you have the source component installed).
pub fn bug_report<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
if true {
writeln!(w, "`;?` here ->")?;
} else {
writeln!(w, "but not here")
}
Ok(())
}
JSON:
Suggests to edit lib/rustlib/src/rust/library/core/src/macros/mod.rs
rustc 1.79.0-nightly (88c2f4f5f 2024-04-02)
binary: rustc
commit-hash: 88c2f4f5f50ace5ddc7655ea311435104d3659bd
commit-date: 2024-04-02
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.2
In some situations, rustc may provide a diagnostic suggestion in an external crate, which in general it shouldn't do. These external crates may be in cargo's registry cache, which the user should not be modifying. For example,
cargo fix
may stomp on changes outside of the package (which is a separate issue https://github.com/rust-lang/cargo/issues/9857). Usually rustc is good about avoiding this, so I'm not sure what is wrong in these situations.In general, I expect rustc to not provide suggestions to modify dependencies.
The crater run found several instances of this, each for different underlying reasons (all dealing with macros).
Example 1 — unused tt
Example dependency:
Example local crate:
Resulting suggestion:
A key point of this example is that the macro uses
tt
instead ofident
.ident
will not issue an unused warning.Found in the 2021 crater run for:
Example 2 — Weird $body suggestion
The following makes a suggestion to remove unnecessary braces, but the suggestion doesn't actually remove any braces.
Suggestion:
Found in the 2021 crater run for:
Example 3 — Hidden JSON suggestion
In this example, the human-readable text doesn't mention the dependency, but the JSON includes a MachineApplicable suggestion.
This emits two duplicate diagnostics in human form:
Buried in the JSON output is a machine-applicable change which modifies diesel:
Found in the 2021 crater run for:
Meta
rustc --version --verbose
: