rust/compiler/rustc_resolve/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
..
late Remove uncessary parens in closure body with unused lint 2025-07-10 09:25:56 +08:00
rustdoc Update tests to work with new DocFragment field and redundant_explicit_links new API 2025-06-23 16:02:34 +02:00
build_reduced_graph.rs MacroData in ResolverArenas + split macro_map into extern_macro_map and local_macro_map. 2025-07-09 23:24:36 +02:00
check_unused.rs deduplicate more walk_* methods in AST visit 2025-06-06 04:59:26 +00:00
def_collector.rs MacroData in ResolverArenas + split macro_map into extern_macro_map and local_macro_map. 2025-07-09 23:24:36 +02:00
diagnostics.rs MacroData in ResolverArenas + split macro_map into extern_macro_map and local_macro_map. 2025-07-09 23:24:36 +02:00
effective_visibilities.rs Reorder ast::ItemKind::{Struct,Enum,Union} fields. 2025-05-28 15:48:45 +10:00
errors.rs Rollup merge of #134006 - klensy:typos, r=nnethercote 2025-07-03 13:29:35 +02:00
ident.rs extract single_import_can_define_name and finalize_glob_module_binding 2025-07-10 15:30:28 +02:00
imports.rs explain ImportData::imported_module 2025-06-29 00:23:35 +08:00
late.rs compiler: rename {ast,hir}::BareFn* to FnPtr* 2025-07-06 15:03:08 -07:00
lib.rs Use reference for MacroRulesScopeRef instead of Interned. 2025-07-09 23:24:51 +02:00
macros.rs Auto merge of #140717 - mejrs:diagnostic_lints, r=oli-obk 2025-07-13 01:11:56 +00:00
rustdoc.rs setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00