about summary refs log tree commit diff
path: root/tests/ui/attributes
AgeCommit message (Collapse)AuthorLines
2025-07-01Fix duplicate errors for `link_section`, ↵Jonathan Brouwer-18/+24
`rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end`
2025-07-01moved testsKivooeo-0/+11
2025-07-01Fix duplicate help on export_name and othersJonathan Brouwer-16/+4
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01Fix `#[rustc_macro_transparency]` giving two errorsJonathan Brouwer-75/+68
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01Fix `#[must_use = 1]` not giving an errorJonathan Brouwer-33/+52
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01Fix double error for `export_name`Jonathan Brouwer-88/+74
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01New test for malformed attributesJonathan Brouwer-0/+825
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-30Rollup merge of #142429 - Kivooeo:tf13, r=jieyouxudianqk-0/+36
`tests/ui`: A New Order [13/N] Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? ```@jieyouxu```
2025-06-29cleaned up some testsKivooeo-0/+36
2025-06-29Rollup merge of #142417 - Kivooeo:tf12, r=jieyouxuGuillaume Gomez-0/+27
`tests/ui`: A New Order [12/N] Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@jieyouxu`
2025-06-28cleaned up some testsKivooeo-0/+27
2025-06-27Port `#[used]` to new attribute parsing infrastructureJonathan Brouwer-13/+59
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-26Rewrite `macro_rules!` parser to not use the MBE engine itselfJosh Triplett-3/+3
The `macro_rules!` parser was written to match the series of rules using the macros-by-example (MBE) engine and a hand-written equivalent of the left-hand side of a MBE macro. This was complex to read, difficult to extend, and produced confusing error messages. Because it was using the MBE engine, any parse failure would be reported as if some macro was being applied to the `macro_rules!` invocation itself; for instance, errors would talk about "macro invocation", "macro arguments", and "macro call", when they were actually about the macro *definition*. And in practice, the `macro_rules!` parser only used the MBE engine to extract the left-hand side and right-hand side of each rule as a token tree, and then parsed the rest using a separate parser. Rewrite it to parse the series of rules using a simple loop, instead. This makes it more extensible in the future, and improves error messages. For instance, omitting a semicolon between rules will result in "expected `;`" and "unexpected token", rather than the confusing "no rules expected this token in macro call". This work was greatly aided by pair programming with Vincenzo Palazzo and Eric Holk.
2025-06-26Move mixed export_name/no_mangle check to check_attr.rs and improve the errorJonathan Brouwer-10/+81
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-23Port `#[rustc_skip_during_method_dispatch]` to the new attribute systemPavel Grigorenko-0/+114
2025-06-23fix 142891Jana Dönszelmann-0/+16
2025-06-23test for lint on root node crashJana Dönszelmann-0/+3
2025-06-22Port `#[must_use]` to new attribute parsing infrastructureJonathan Brouwer-0/+12
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-20Auto merge of #142794 - tgross35:rollup-iae7okj, r=tgross35bors-0/+15
Rollup of 9 pull requests Successful merges: - rust-lang/rust#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.) - rust-lang/rust#142491 (Rework #[cold] attribute parser) - rust-lang/rust#142494 (Fix missing docs in `rustc_attr_parsing`) - rust-lang/rust#142495 (Better template for `#[repr]` attributes) - rust-lang/rust#142497 (Fix random failure when JS code is executed when the whole file was not read yet) - rust-lang/rust#142575 (Ensure copy* intrinsics also perform the static self-init checks) - rust-lang/rust#142650 (Refactor Translator) - rust-lang/rust#142713 (mbe: Refactor transcription) - rust-lang/rust#142755 (rustdoc: Remove `FormatRenderer::cache`) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-20expected word diagnostic testJana Dönszelmann-0/+15
2025-06-19correct template for `#[align]`Folkert de Vries-25/+29
it should not suggest just `#[align]`
2025-06-18add `#[align]` attributeFolkert de Vries-16/+88
Right now it's used for functions with `fn_align`, in the future it will get more uses (statics, struct fields, etc.)
2025-06-17make error codes reflect reality betterJana Dönszelmann-13/+7
2025-06-17use consistent attr errors in all attribute parsersJana Dönszelmann-14/+21
2025-06-17fix bugs in inline/force_inline and diagnostics of all attr parsersJana Dönszelmann-9/+9
2025-06-16trait_sel: skip elaboration of sizedness supertraitDavid Wood-1/+0
As a performance optimization, skip elaborating the supertraits of `Sized`, and if a `MetaSized` obligation is being checked, then look for a `Sized` predicate in the parameter environment. This makes the `ParamEnv` smaller which should improve compiler performance as it avoids all the iteration over the larger `ParamEnv`.
2025-06-16tests: bless remaining testsDavid Wood-1/+2
These tests just need blessing, they don't have any interesting behaviour changes. Some of these tests have new errors because `LegacyReceiver` cannot be proven to be implemented now that it is also testing for `MetaSized` - but this is just a consequence of the other errors in the test.
2025-06-16tests: `{Meta,Pointee}Sized` in non-minicore testsDavid Wood-1/+21
As before, add `MetaSized` and `PointeeSized` traits to all of the non-minicore `no_core` tests so that they don't fail for lack of language items.
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `?Sized` typesDavid Wood-0/+1
Expand the automatic implementation of `MetaSized` and `PointeeSized` so that it is also implemented on non-`Sized` types, just not `ty::Foreign` (extern type).
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `Sized` typesDavid Wood-0/+1
Introduce the `MetaSized` and `PointeeSized` traits as supertraits of `Sized` and initially implement it on everything that currently implements `Sized` to isolate any changes that simply adding the traits introduces.
2025-06-08Rollup merge of #142171 - Kivooeo:tf7, r=workingjubileeJubilee-0/+62
`tests/ui`: A New Order [7/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.
2025-06-08cleaned up some testsKivooeo-0/+62
2025-06-08cleaned up some testsKivooeo-0/+9
2025-06-02allow macro_use as first segmentbohan-0/+60
2025-05-24Avoid extra path trimming in method not found errorNoratrieb-3/+3
Method errors have an extra check that force trim paths whenever the normal string is longer than 10 characters, which can be quite unhelpful when multiple items have the same name (for example an `Error`). A user reported this force trimming as being quite unhelpful when they had a method error where the precise path of the `Error` mattered. The code uses `tcx.short_string` already to get the normal path, which tries to be clever around trimming paths if necessary, so there is no reason for this extra force trimming.
2025-05-21collect doc alias as tips during resolutionbohan-0/+241
2025-05-12Move more tests/ui testsmejrs-16/+75
2025-05-04Initial support for dynamically linked cratesBryanskiy-0/+307
2025-05-03Move some tests out of tests/uimejrs-0/+55
2025-04-18Rollup merge of #139615 - nnethercote:rm-name_or_empty, r=jdonszelmannMatthias Krüger-8/+64
Remove `name_or_empty` Another step towards #137978. r? ``@jdonszelmann``
2025-04-17Rollup merge of #138632 - clubby789:stabilize-cfg-boolean-lit, ↵Matthias Krüger-2/+2
r=davidtwco,Urgau,traviscross Stabilize `cfg_boolean_literals` Closes #131204 `@rustbot` labels +T-lang +I-lang-nominated This will end up conflicting with the test in #138293 so whichever doesn't land first will need updating -- # Stabilization Report ## General design ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized? [RFC 3695](https://github.com/rust-lang/rfcs/pull/3695), none. ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con. None ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those? None ## Has a call-for-testing period been conducted? If so, what feedback was received? Yes; only positive feedback was received. ## Implementation quality ### Summarize the major parts of the implementation and provide links into the code (or to PRs) Implemented in [#131034](https://github.com/rust-lang/rust/pull/131034). ### Summarize existing test coverage of this feature - [Basic usage, including `#[cfg()]`, `cfg!()` and `#[cfg_attr()]`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/true-false.rs) - [`--cfg=true/false` on the command line being accessible via `r#true/r#false`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/raw-true-false.rs) - [Interaction with the unstable `#[doc(cfg(..))]` feature](https://github.com/rust-lang/rust/tree/6d71251/tests/rustdoc-ui/cfg-boolean-literal.rs) - [Denying `--check-cfg=cfg(true/false)`](https://github.com/rust-lang/rust/tree/6d71251/tests/ui/check-cfg/invalid-arguments.rs) - Ensuring `--cfg false` on the command line doesn't change the meaning of `cfg(false)`: `tests/ui/cfg/cmdline-false.rs` - Ensuring both `cfg(true)` and `cfg(false)` on the same item result in it being disabled: `tests/ui/cfg/both-true-false.rs` ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking? The above mentioned issue; it should not block as it interacts with another unstable feature. ### What FIXMEs are still in the code for that feature and why is it ok to leave them there? None ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization - `@clubby789` (RFC) - `@Urgau` (Implementation in rustc) ### Which tools need to be adjusted to support this feature. Has this work been done? `rustdoc`'s unstable`#[doc(cfg(..)]` has been updated to respect it. `cargo` has been updated with a forward compatibility lint to enable supporting it in cargo once stabilized. ## Type system and execution rules ### What updates are needed to the reference/specification? (link to PRs when they exist) A few lines to be added to the reference for configuration predicates, specified in the RFC.
2025-04-17Replace infallible `name_or_empty` methods with fallible `name` methods.Nicholas Nethercote-6/+6
I'm removing empty identifiers everywhere, because in practice they always mean "no identifier" rather than "empty identifier". (An empty identifier is impossible.) It's better to use `Option` to mean "no identifier" because you then can't forget about the "no identifier" possibility. Some specifics: - When testing an attribute for a single name, the commit uses the `has_name` method. - When testing an attribute for multiple names, the commit uses the new `has_any_name` method. - When using `match` on an attribute, the match arms now have `Some` on them. In the tests, we now avoid printing empty identifiers by not printing the identifier in the `error:` line at all, instead letting the carets point out the problem.
2025-04-17Augment some tests involving attributes.Nicholas Nethercote-2/+36
This shows places where the use of `name_or_empty` causes problems, i.e. we print empty identifiers in error messages: ``` error: unrecognized field name `` error: `` isn't a valid `#[macro_export]` argument `#[no_sanitize()]` should be applied to a function ``` (The last one is about an attribute `#[no_sanitize("address")]`.) The next commit will fix these.
2025-04-17Fix attribute printing in an error.Nicholas Nethercote-4/+4
The current code assumes that the attribute is just an identifier, and so misprints paths.
2025-04-17Warnings-as-errors in `check-builtin-attr-ice.rs`.Nicholas Nethercote-4/+26
This adds two new warnings, both of which print the attribute incorrectly as `#[]`. The next commit will fix this.
2025-04-13Improve `-Z crate-attr` diagnosticsjyn-36/+56
- Show the `#![ ... ]` in the span (to make it clear that it should not be included in the CLI argument) - Show more detailed errors when the crate has valid token trees but invalid syntax. Previously, `crate-attr=feature(foo),feature(bar)` would just say "invalid crate attribute" and point at the comma. Now, it explicitly says that the comma was unexpected, which is useful when using `--error-format=short`. It also fixes the column to show the correct span. - Recover from parse errors. Previously we would abort immediately on syntax errors; now we go on to try and type-check the rest of the crate. The new diagnostic code also happens to be slightly shorter.
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-4/+4
2025-04-07Auto merge of #133781 - cjgillot:shallow-allowed-lints, r=petrochenkovbors-1/+19
Do not visit whole crate to compute `lints_that_dont_need_to_run`. This allows to reuse the computed lint levels instead of re-visiting the whole crate.
2025-04-06Rollup merge of #139391 - TaKO8Ki:check-if-merged-attrs-list-is-empty, ↵Guillaume Gomez-0/+39
r=jdonszelmann Check if merged attributes list is empty in expr Fixes #139373 In the example code, an [`UnrecognizedReprHint`](https://github.com/rust-lang/rust/blob/6b5ccfc87f59ab017032e430d4d358b4989735da/compiler/rustc_attr_parsing/src/attributes/repr.rs#L155) error is output, and the list of merged attributes becomes empty. This causes a [panic](https://github.com/rust-lang/rust/blob/6b5ccfc87f59ab017032e430d4d358b4989735da/compiler/rustc_ast_lowering/src/lib.rs#L618) to occur. So, it's necessary to check if merged attributes list is empty as other functions do. ref: https://github.com/rust-lang/rust/blob/6b5ccfc87f59ab017032e430d4d358b4989735da/compiler/rustc_ast_lowering/src/lib.rs#L896
2025-04-05check if merged attributes list is emptyTakayuki Maeda-0/+39