| Age | Commit message (Collapse) | Author | Lines |
|
mbe: Implement `unsafe` attribute rules
This implements `unsafe attr` rules for declarative `macro_rules!` attributes, as specified in [RFC 3697](https://github.com/rust-lang/rfcs/pull/3697).
An invocation of an attribute that uses an `unsafe attr` rule requires the `unsafe(attr(...))` syntax.
An invocation of an attribute that uses an ordinary `attr` rule must *not* use the `unsafe(attr(...))` syntax.
`unsafe` is only supported on an `attr` rule, not any other kind of `macro_rules!` rule.
Tracking issue for `macro_rules!` attributes: https://github.com/rust-lang/rust/issues/143547
|
|
|
|
|
|
Ignore more failing ui tests for GCC backend
Needed for https://github.com/rust-lang/rust/pull/146414.
r? ``@Kobzol``
|
|
|
|
|
|
Co-authored-by: Anne Stijns <anstijns@gmail.com>
|
|
Convert `no_std` and `no_core` to the new attribute infrastructure
r? ```@oli-obk```
Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
|
|
|
|
We need a different attribute than `rustc_align` because unstable attributes are
tied to their feature (we can't have two unstable features use the same
unstable attribute). Otherwise this uses all of the same infrastructure
as `#[rustc_align]`.
|
|
Co-authored-by: Dennis Bonke <dennis@managarm.org>
|
|
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
|
|
Access less HIR attributes from typeck
Typeck relies on attributes to modify its own behaviour. This is a problem, as this means that `typeck(some function)` may depend on the span and doc-comments of many other functions.
This PR attempts to reduce such accesses to attributes. This yields to a sizeable perf improvement: https://github.com/rust-lang/rust/pull/144841#issuecomment-3153339771
Fixes https://github.com/rust-lang/rust/issues/124352
|
|
Use attribute name in message for "outer attr used as inner attr" errors
|
|
|
|
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
|
|
|
|
|
|
|
|
|
|
mention lint group in default level lint note
### Summary
This PR updates lint diagnostics so that default-level notes now mention the lint group they belong to, if any.
Fixes: rust-lang/rust#65464.
### Example
```rust
fn main() {
let x = 5;
}
```
Before:
```
= note: `#[warn(unused_variables)]` on by default
```
After:
```
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
```
### Unchanged Cases
Messages remain the same when the lint level is explicitly set, e.g.:
* Attribute on the lint `#[warn(unused_variables)]`:
```
note: the lint level is defined here
LL | #[warn(unused_variables)]
| ^^^^^^^^^^^^^^^^
```
* Attribute on the group `#[warn(unused)]:`:
```
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
```
* CLI option `-W unused`:
```
= note: `-W unused-variables` implied by `-W unused`
= help: to override `-W unused` add `#[allow(unused_variables)]`
```
* CLI option `-W unused-variables`:
```
= note: requested on the command line with `-W unused-variables`
```
|
|
|
|
Rollup of 15 pull requests
Successful merges:
- rust-lang/rust#145338 (actually provide the correct args to coroutine witnesses)
- rust-lang/rust#145429 (Couple of codegen_fn_attrs improvements)
- rust-lang/rust#145452 (Do not strip binaries in bootstrap everytime if they are unchanged)
- rust-lang/rust#145464 (Stabilize `const_pathbuf_osstring_new` feature)
- rust-lang/rust#145474 (Properly recover from parenthesized use-bounds (precise capturing lists) plus small cleanups)
- rust-lang/rust#145486 (Fix `unicode_data.rs` mention message)
- rust-lang/rust#145490 (Trace some basic I/O operations in bootstrap)
- rust-lang/rust#145493 (remove `should_render` in `PrintAttribute` derive)
- rust-lang/rust#145500 (Port must_use to the new target checking)
- rust-lang/rust#145505 (Simplify span caches)
- rust-lang/rust#145510 (Visit and print async_fut local for async drop.)
- rust-lang/rust#145511 (Rust build fails on OpenBSD after using file_lock feature)
- rust-lang/rust#145532 (resolve: debug for block module)
- rust-lang/rust#145533 (Reorder `lto` options from most to least optimizing)
- rust-lang/rust#145537 (Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation.)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Port must_use to the new target checking
This PR ports `must_use` to the new target checking logic
This also adds a tool-only suggestion to remove attributes on invalid targets, as to not immediately undo the work of https://github.com/rust-lang/rust/pull/145274
r? `@jdonszelmann`
|
|
Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`
Part of rust-lang/rust#133895
Methodology:
1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer
Inspired by the methodology that ``@Kivooeo`` was using.
r? ``@jieyouxu``
|
|
|
|
take attr style into account in diagnostics
when the original attribute was specified as an inner attribute, the suggestion will now match that attribute style
|
|
This removes the #[no_sanitize] attribute, which was behind an unstable
feature named no_sanitize. Instead, we introduce the sanitize attribute
which is more powerful and allows to be extended in the future (instead
of just focusing on turning sanitizers off).
This also makes sanitize(kernel_address = ..) attribute work with
-Zsanitize=address
To do it the same as how clang disables address sanitizer, we now
disable ASAN on sanitize(kernel_address = "off") and KASAN on
sanitize(address = "off").
The same was added to clang in https://reviews.llvm.org/D44981.
|
|
|
|
|
|
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
|
|
Port the `#[linkage]` attribute to the new attribute system
r? `@jdonszelmann`
|
|
Add regression test for a former ICE involving helper attributes containing interpolated tokens
Add regression test for rust-lang/rust#140612 from rust-lang/rust#140601 or rather rust-lang/rust#140859 that only added it to `stable` not `master`.
Supersedes https://github.com/rust-lang/rust/pull/140584.
r? `@jdonszelmann` or anyone
|
|
interpolated tokens
Co-authored-by: Jana Dönszelmann <jana@donsz.nl>
|
|
|
|
Tweak invalid builtin attribute output
- Add link to reference/docs when possible
- More accurate suggestions by supporting multiple alternative suggestions
```
error: malformed `crate_type` attribute input
--> $DIR/crate-type-macro-call.rs:1:1
|
LL | #![crate_type = foo!()]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
help: the following are the possible correct uses
|
LL - #![crate_type = foo!()]
LL + #![crate_type = "bin"]
|
LL - #![crate_type = foo!()]
LL + #![crate_type = "cdylib"]
|
LL - #![crate_type = foo!()]
LL + #![crate_type = "dylib"]
|
LL - #![crate_type = foo!()]
LL + #![crate_type = "lib"]
|
= and 4 other candidates
```
|
|
|
|
|
|
|
|
|
|
`NamedValueStr`
Modify `AttributeTemplate` to support list of alternatives for list and name value attribute styles.
Suggestions now provide more correct suggested code:
```
error[E0805]: malformed `used` attribute input
--> $DIR/used_with_multi_args.rs:3:1
|
LL | #[used(compiler, linker)]
| ^^^^^^------------------^
| |
| expected a single argument here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #[used(compiler, linker)]
LL + #[used(compiler)]
|
LL - #[used(compiler, linker)]
LL + #[used(linker)]
|
LL - #[used(compiler, linker)]
LL + #[used]
|
```
instead of the prior "masking" of the lack of this feature by suggesting pipe-separated lists:
```
error[E0805]: malformed `used` attribute input
--> $DIR/used_with_multi_args.rs:3:1
|
LL | #[used(compiler, linker)]
| ^^^^^^------------------^
| |
| expected a single argument here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #[used(compiler, linker)]
LL + #[used(compiler|linker)]
|
LL - #[used(compiler, linker)]
LL + #[used]
|
```
|
|
|
|
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
|
|
Revert "Port `#[allow_internal_unsafe]` to the new attribute system"
This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143 (PR: https://github.com/rust-lang/rust/pull/144857)
r? `@Kobzol`
cc: `@scrabsha`
clean revert it seems :3
|
|
Use `tcx.short_string()` in more diagnostics
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`.
We add support for shortening the path of "trait path only".
Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem).
|
|
This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143.
|
|
Port `#[allow_internal_unsafe]` to the new attribute system
Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.
r? ````@jdonszelmann````
|
|
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`.
We add support for shortening the path of "trait path only".
Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem).
When we don't actually print out a shortened type we don't need the "use `--verbose`" note.
On E0599 show type identity to avoid expanding the receiver's generic parameters.
Unify wording on `long_ty_path` everywhere.
|
|
|
|
Mark all deprecation lints in name resolution as deny-by-default and report-in-deps
This affects the next lints:
- `MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS` - https://github.com/rust-lang/rust/issues/144408
- `LEGACY_DERIVE_HELPERS` - https://github.com/rust-lang/rust/issues/79202
- `PRIVATE_MACRO_USE` - https://github.com/rust-lang/rust/issues/120192
- `OUT_OF_SCOPE_MACRO_CALLS` - https://github.com/rust-lang/rust/issues/144406
|