rust/src
bors b1d2f2c64c Auto merge of #140717 - mejrs:diagnostic_lints, r=oli-obk
Split up the `unknown_or_malformed_diagnostic_attributes` lint

This splits up the lint into the following lint group:
- `unknown_diagnostic_attributes` - triggers if the attribute is unknown to the current compiler
- `misplaced_diagnostic_attributes` - triggers if the attribute exists but it is not placed on the item kind it's meant for
- `malformed_diagnostic_attributes` - triggers if the attribute's syntax or options are invalid
- `malformed_diagnostic_format_literals` - triggers if the format string literal is invalid, for example if it has unpaired curly braces or invalid parameters
- this pr doesn't create it, but future lints for things like deprecations can also go here.

This PR does not start emitting lints in places that previously did not.

## Motivation

I want to have finer control over what `unknown_or_malformed_diagnostic_attributes` does

I have a project with fairly low msrv that is/will have a lower msrv than future diagnostic attributes. So lints will be emitted when I or others compile it on a lower msrv.

At this time, there are two options to silence these lints:

-  `#[allow(unknown_or_malformed_diagnostic_attributes)]` - this risks diagnostic regressions if I (or others) mess up using the attribute, or if the attribute's syntax ever changes.
- write a build script to detect the compiler version and emit cfgs, and then conditionally enable the attribute:
    ```rust
    #[cfg_attr(rust_version_99, diagnostic::new_attr_in_rust_99(thing = ..))]`
    struct Foo;
    ```
    or conditionally `allow`  the lint:
    ```rust
   // lib.rs
   #![cfg_attr(not(current_rust), allow(unknown_or_malformed_diagnostic_attributes))]
   ```

I like to avoid using build scripts if I can, so the following works much better for me. That is what this PR will let me do in the future:
```rust
    #[allow(unknown_diagnostic_attribute, reason = "attribute came out in rust 1.99 but msrv is 1.70")]
    #[diagnostic::new_attr_in_rust_99(thing = ..)]`
    struct Foo;
2025-07-13 01:11:56 +00:00
..
bootstrap Rollup merge of #143707 - Kobzol:bootstrap-std-check, r=jieyouxu 2025-07-10 20:20:39 -04:00
build_helper build-helper: clippy fixes 2025-07-11 07:15:20 +00:00
ci Rollup merge of #140136 - dpaoliello:arm64winci, r=Kobzol 2025-07-10 20:20:37 -04:00
doc Rollup merge of #143747 - Gelbpunkt:aarch64-musl-maintainer, r=jieyouxu 2025-07-11 19:45:24 +02:00
etc tidy: add auto: prefix to --extra-checks syntax 2025-07-08 16:16:48 -05:00
gcc@04ce66d8c9 Update src/gcc submodule to 04ce66d8c918de9273bd7101638ad8724edf5e21 2025-05-14 18:02:02 +02:00
librustdoc Rollup merge of #143590 - GuillaumeGomez:reexport-shadowing, r=lolbinary 2025-07-10 20:28:47 +02:00
llvm-project@99f0e05316 Update LLVM submodule 2025-07-09 12:56:06 -07:00
rustc-std-workspace update rustc-std-workspace crates 2024-11-04 07:45:15 +01:00
rustdoc-json-types Port #[no_mangle] to new attribute parsing infrastructure 2025-06-22 22:17:04 +02:00
tools Auto merge of #140717 - mejrs:diagnostic_lints, r=oli-obk 2025-07-13 01:11:56 +00:00
README.md
stage0 Update stage0 to 1.89.0-beta.1 2025-07-01 10:54:33 -07:00
version Bump the version number to 1.90.0 2025-06-20 10:08:52 -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.