Port lint attributes to attribute parser
*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152369)*
Tracking issue: rust-lang/rust#131229
Ports `#[allow]`, `#[deny]`, `#[expect]`, `#[forbid]`, and `#[warn]` to being parsed attrs
I tried my best to make this PR as small as possible, it was difficult. I hope it isn't too difficult to review
r? @JonathanBrouwer
r? @jdonszelmann
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#154696 (rustdoc_missing_doc_code_examples: lint on macro_rules macros)
- rust-lang/rust#154698 (Improve workings of the `desc` query modifier and custom query cycle handlers)
- rust-lang/rust#154713 (Stop compiling when we get resolving crate failure)
- rust-lang/rust#154736 (Add a regression test for the duplicated `crate` keyword in path suggestions)
- rust-lang/rust#154739 (ci: update upload-artifact action to v7)
- rust-lang/rust#154741 (Enforce `#![warn(unreachable_pub)]` in compiletest source)
Failed merges:
- rust-lang/rust#154605 (Make `span_suggestions` always verbose)
also removes E0452 and splits
`tests/rustdoc-ui/lints/renamed-lint-still-applies` into 2 tests
this is because of delayed warn lint being lost on compiler aborting on
error
Enforce `#![warn(unreachable_pub)]` in compiletest source
The actual public API surface of compiletest is restricted to two specific modules, `cli` and `rustdoc_gui_test`.
Other items have no reason to be `pub`.
There should be no change to compiletest behaviour.
Add a regression test for the duplicated `crate` keyword in path suggestions
The issue has (long) been fixed, but needs a test.
Closesrust-lang/rust#115858.
Improve workings of the `desc` query modifier and custom query cycle handlers
This PR does two things involving query modifiers.
- It changes how the `desc` query modifier is handled, eliminating the generated `_description_fns` module.
- It adds a new `handle_cycle_error` query modifier for queries that do custom cycle handling.
Details are in the individual commits.
r? @Zalathar
rustdoc_missing_doc_code_examples: lint on macro_rules macros
part of rust-lang/rust#154640
accidentally built this on top of rust-lang/rust#154644, but since that PR is already approved it should be fine if we just wait for it to be merged.
r? @GuillaumeGomez
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#154444 (rustdoc ICE fix: When collecting `Deref` impls with their targets, skip the negative ones)
- rust-lang/rust#154590 (Make #[cfg] suggest any or all on #[cfg(a, b)])
- rust-lang/rust#154691 (core: Update the feature gate on `TryFrom<integer> for bool`)
- rust-lang/rust#154697 (rustdoc: fix href of extern crates in search results)
- rust-lang/rust#154728 (rustdoc: Improve internal function name)
- rust-lang/rust#154732 (fix(std): avoid AT_MINSIGSTKSZ on uclibc targets)
Failed merges:
- rust-lang/rust#154722 (fix(lints): Improve `ill_formed_attribute_input` with better help message)
This modifier indicates that a query has a custom handler for cycles.
That custom handler must be found at
`rustc_query_impl::handle_cycle_error::$name`.
This eliminates the need for `specialize_query_vtables`, which is the
current hack to install custom handlers. It's more lines of code in
total, but indicating special treatment of a query via a modifier in
`queries.rs` is more consistent with how other aspects of queries are
handled.
`rustc_queries` generates a macro and two modules. One of the modules
looks like this:
```
mod _description_fns {
...
#[allow(unused_variables)]
pub fn hir_module_items<'tcx>(tcx: TyCtxt<'tcx>, key: LocalModDefId) -> String {
format!("getting HIR module items in `{}`", tcx.def_path_str(key))
}
...
}
```
Members of this module are then used in `TaggedQueryKey::description`.
This commit removes the `_description_fns` module entirely. For each
query we now instead generate a description closure that is used
instead. This closure is passed in the modifiers list.
This change simplifies `rustc_queries` quite a bit. It requires adding
another query modifier, but query modifiers are how other query-specific
details are already passed to the declarative macros, so it's more
consistent.
rustdoc: Improve internal function name
This functions name totally contradicted what it did. And the only places it was used immediatly `!`ed it. Push the `!` into the function, and rename it to make sense.
Should hopefully result in less head-scratching next time someone looks at this.
r? @GuillaumeGomez
rustdoc: fix href of extern crates in search results
To avoid modifying the search index, I instead overloaded an existing field that is always unused for extern crate items.
fixesrust-lang/rust#148300
r? @GuillaumeGomez
core: Update the feature gate on `TryFrom<integer> for bool`
This implementation was added recently in f12288ec26 ("TryFrom<integer> for bool") but used an old feature gate and stabilization version. Update to reflect when these were actually added.
rustdoc ICE fix: When collecting `Deref` impls with their targets, skip the negative ones
rustdoc assumed every `Deref` impl has an associated `Target` type, but negative impls (e.g. `impl !Deref for T {}`) have none.
Skip them in both the trait-impl collection pass and the HTML render pass to avoid panicking on the missing `Target`.
Closesrust-lang/rust#128801.
This functions name totally contradicted what it did. And the only
places it was used immediatly `!`ed it. Push the `!` into the function,
and rename it to make sense.
Should hopefully result in less head-scratching next time someone looks
at this.
[rustdoc] Replace `DocContext` with `TyCtxt` wherever possible
In a lot of places, we pass down `DocContext` but actually only use its `tcx` field (`TyCtxt`). To make it more obvious what's actually being done, I replaced `DocContext` with `TyCtxt` (which implements `Copy`) in the function arguments. It created quite the cascade effect so I ended up with a lot more changes I expected.
Because it's a lot of changes, I made small commits which are easy to go through, so I strongly recommend reviewing this PR one commit at a time.
r? @Urgau
Add a test for a past ICE when calling a const fn of an unresolved type with the wrong number of args
The ICE is fixed, but there needs to be a regression test for it.
Closesrust-lang/rust#127423.
Avoid creating async return opaques for foreign async fns
Fixes https://github.com/rust-lang/rust/issues/146754
Previously, def collection created the desugared async return opaque for foreign `async fn` items, but AST lowering won't lower that opaque for foreign items. That left a `DefId` without a corresponding HIR owner, which later caused an ICE during analysis.
Migrate transmute tests
I have made the following changes in this PR:
- `tests/ui/issues/issue-23477.rs` ➝ `tests/ui/transmute/transmute-slice-to-dst.rs`
- `tests/ui/issues/issue-28625.{rs,stderr}` ➝ `tests/ui/transmute/transmute-associated-type-to-slice.{rs,stderr}`
The reason I changed the trait name from `trait Bar` to `trait MyTrait` and `type Bar` to `type MyType` is that the same name (i.e., `Bar`) for the trait and associated type was making it harder to follow the test. It was confusing for me, at least.
r? Kivooeo