rust/src
Matthias Krüger e3dbcdf753
Rollup merge of #148004 - Muscraft:only-single-line-item-attributes, r=estebank
fix: Only special case single line item attribute suggestions

`rustc` currently special cases suggestions to add [`#[derive(_)]\n` and other attributes](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L2288C36-L2288C72)), to add more context to the suggestions.

> // The suggestion adds an entire line of code, ending on a newline, so we'll also
> // print the *following* line, to provide context of what we're advising people to
> // do. Otherwise you would only see contextless code that can be confused for
> // already existing code, despite the colors and UI elements.
> // We special case `#[derive(_)]\n` and other attribute suggestions, because those
> // are the ones where context is most useful.

This special case is a bit broad at the moment and applies to suggestions just to add an attribute, as well as suggestions that contain an attribute and other code, i.e.
```rust
#[derive(Clone)]
```
and
```rust
#[cfg(not(test))]
impl Default for NewWithCfg {
    fn default() -> Self {
        Self::new()
    }
}
```

In the latter case, adding a line for context after the suggestion doesn't provide much benefit. Example:
![temp](https://github.com/user-attachments/assets/6859b400-aa99-4c1b-9eb0-0cd67ae35bf9)

This PR makes it so that this special case only applies to suggestions that just add an attribute and nothing else. This will also make `rustc`'s output match `annotate-snippets`.
2025-11-03 21:20:22 +01:00
..
bootstrap Auto merge of #148446 - GuillaumeGomez:rollup-lxwlqol, r=GuillaumeGomez 2025-11-03 16:29:59 +00:00
build_helper Include additional hashes in src/stage0 2025-09-27 08:43:22 -04:00
ci Auto merge of #148420 - Zalathar:rollup-1rrbzk7, r=Zalathar 2025-11-03 02:52:00 +00:00
doc Auto merge of #148412 - matthiaskrgr:rollup-59a302x, r=matthiaskrgr 2025-11-02 23:12:25 +00:00
etc Rollup merge of #148395 - Kobzol:generalize-branch-references, r=marcoieni 2025-11-02 20:21:03 +01:00
gcc@4e995bd73c Update GCC submodule 2025-08-26 18:09:42 +02:00
librustdoc Rollup merge of #148268 - notriddle:emit-scraped-examples, r=GuillaumeGomez 2025-11-03 17:20:37 +01:00
llvm-project@4f74b76fb6 Update LLVM to 21.1.3 2025-10-09 18:23:56 +08:00
rustc-std-workspace Generalize branch references to HEAD 2025-11-02 11:15:55 +01:00
rustdoc-json-types Add new doc(attribute = "...") attribute 2025-08-28 15:56:29 +02:00
tools Rollup merge of #148004 - Muscraft:only-single-line-item-attributes, r=estebank 2025-11-03 21:20:22 +01:00
README.md
stage0 Bump stage0 to 1.92.0-beta.1 2025-10-28 13:35:43 -07:00
version Bump the version number to 1.93.0 2025-10-24 11:12:06 -07:00

This directory contains some source code for the Rust project, including:

  • The bootstrapping build system
  • Various submodules for tools, like cargo, tidy, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.