about summary refs log tree commit diff
path: root/tests/ui/attributes
AgeCommit message (Collapse)AuthorLines
2024-10-02Add `get_line` confusable to `Stdin::read_line()`Jaken Herman-1/+16
Add tests for addition of `#[rustc_confusables("get_line")]`
2024-09-30Reject leading unsafe in `cfg!(...)` and `--check-cfg`.Urgau-2/+24
2024-09-21remove `#[cmse_nonsecure_entry]`Folkert-24/+3
2024-08-24New `#[rustc_pub_transparent]` attributePavel Grigorenko-0/+48
2024-08-18Check that `#[may_dangle]` is properly appliedGoldstein-0/+103
It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation.
2024-08-17Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercotebors-48/+35
Stabilize `unsafe_attributes` # Stabilization report ## Summary This is a tracking issue for the RFC 3325: unsafe attributes We are stabilizing `#![feature(unsafe_attributes)]`, which makes certain attributes considered 'unsafe', meaning that they must be surrounded by an `unsafe(...)`, as in `#[unsafe(no_mangle)]`. RFC: rust-lang/rfcs#3325 Tracking issue: #123757 ## What is stabilized ### Summary of stabilization Certain attributes will now be designated as unsafe attributes, namely, `no_mangle`, `export_name`, and `link_section` (stable only), and these attributes will need to be called by surrounding them in `unsafe(...)` syntax. On editions prior to 2024, this is simply an edition lint, but it will become a hard error in 2024. This also works in `cfg_attr`, but `unsafe` is not allowed for any other attributes, including proc-macros ones. ```rust #[unsafe(no_mangle)] fn a() {} #[cfg_attr(any(), unsafe(export_name = "c"))] fn b() {} ``` For a table showing the attributes that were considered to be included in the list to require unsafe, and subsequent reasoning about why each such attribute was or was not included, see [this comment here](https://github.com/rust-lang/rust/pull/124214#issuecomment-2124753464) ## Tests The relevant tests are in `tests/ui/rust-2024/unsafe-attributes` and `tests/ui/attributes/unsafe`.
2024-08-17Rollup merge of #128989 - s7tya:check-linkage-attribute-pos, r=petrochenkovMatthias Krüger-0/+97
Emit an error for invalid use of the linkage attribute fixes #128486 Currently, the use of the linkage attribute for Mod, Impl,... is incorrectly permitted. This PR will correct this issue by generating errors, and I've also added some UI test cases for it. Related: #128552.
2024-08-17Emit an error for invalid use of the linkage attributeShina-0/+97
2024-08-16Overhaul token collection.Nicholas Nethercote-0/+42
This commit does the following. - Renames `collect_tokens_trailing_token` as `collect_tokens`, because (a) it's annoying long, and (b) the `_trailing_token` bit is less accurate now that its types have changed. - In `collect_tokens`, adds a `Option<CollectPos>` argument and a `UsePreAttrPos` in the return type of `f`. These are used in `parse_expr_force_collect` (for vanilla expressions) and in `parse_stmt_without_recovery` (for two different cases of expression statements). Together these ensure are enough to fix all the problems with token collection and assoc expressions. The changes to the `stringify.rs` test demonstrate some of these. - Adds a new test. The code in this test was causing an assertion failure prior to this commit, due to an invalid `NodeRange`. The extra complexity is annoying, but necessary to fix the existing problems.
2024-08-07Rollup merge of #128552 - s7tya:check-no-sanitize-attribute-pos, r=BoxyUwUTrevor Gross-0/+89
Emit an error for invalid use of the `#[no_sanitize]` attribute fixes #128487. Currently, the use of the `#[no_sanitize]` attribute for Mod, Impl,... is incorrectly permitted. This PR will correct this issue by generating errors, and I've also added some UI test cases for it. Referenced #128458. As far as I know, the `#[no_sanitize]` attribute can only be used with functions, so I changed that part to `Fn` and `Method` using `check_applied_to_fn_or_method`. However, I couldn't find explicit documentation on this, so I could be mistaken...
2024-08-07Stabilize `unsafe_attributes`carbotaniuman-48/+35
2024-08-06tests: add regression test to make sure `cfg_attr` isn't considered unhandled许杰友 Jieyou Xu (Joe)-0/+169
2024-08-05Emit an error for invalid use of the `#[no_sanitize]` attributeShina-0/+89
2024-08-04tests: add regression test for incorrect "builtin attribute is checked" ↵许杰友 Jieyou Xu (Joe)-0/+79
assertion ICE See <https://github.com/rust-lang/rust/issues/128622>.
2024-08-01Auto merge of #127543 - carbotaniuman:more_unsafe_attr_verification, ↵bors-6/+331
r=estebank,traviscross More unsafe attr verification This code denies unsafe on attributes such as `#[test]` and `#[ignore]`, while also changing the `MetaItem` parsing so `unsafe` in args like `#[allow(unsafe(dead_code))]` is not accidentally allowed. Tracking: - https://github.com/rust-lang/rust/issues/123757
2024-07-31Emit an error if `#[optimize]` is applied to an incompatible itemclubby789-0/+48
2024-07-30Add toggle for `parse_meta_item` unsafe parsingcarbotaniuman-25/+157
This makes it possible for the `unsafe(...)` syntax to only be valid at the top level, and the `NestedMetaItem`s will automatically reject `unsafe(...)`.
2024-07-29Deny unsafe on more builtin attributescarbotaniuman-1/+194
2024-07-29Structured suggestion for `extern crate foo` when `foo` isn't resolved in importEsteban Küber-2/+8
When encountering a name in an import that could have come from a crate that wasn't imported, use a structured suggestion to suggest `extern crate foo;` pointing at the right place in the crate. When encountering `_` in an import, do not suggest `extern crate _;`. ``` error[E0432]: unresolved import `spam` --> $DIR/import-from-missing-star-3.rs:2:9 | LL | use spam::*; | ^^^^ maybe a missing crate `spam`? | help: consider importing the `spam` crate | LL + extern crate spam; | ```
2024-07-25Auto merge of #127042 - GrigorenkoPV:derivative, r=compiler-errorsbors-1/+1
Switch from `derivative` to `derive-where` This is a part of the effort to get rid of `syn 1.*` in compiler's dependencies: #109302 Derivative has not been maintained in nearly 3 years[^1]. It also depends on `syn 1.*`. This PR replaces `derivative` with `derive-where`[^2], a not dead alternative, which uses `syn 2.*`. A couple of `Debug` formats have changed around the skipped fields[^3], but I doubt this is an issue. [^1]: https://github.com/mcarton/rust-derivative/issues/117 [^2]: https://lib.rs/crates/derive-where [^3]: See the changes in `tests/ui`
2024-07-24Do not use question as labelEsteban Küber-4/+4
We don't want to have questions in the diagnostic output. Instead, we use wording that communicates uncertainty, like "might": ``` error[E0432]: unresolved import `spam` --> $DIR/import-from-missing-star-3.rs:2:9 | LL | use spam::*; | ^^^^ you might be missing crate `spam` | = help: consider adding `extern crate spam` to use the `spam` crate ```
2024-07-12rustc_type_ir: derivative -> derive-wherePavel Grigorenko-1/+1
2024-07-12Make parse error suggestions verbose and fix spansEsteban Küber-1/+6
Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-07-11Always use a colon in `//@ normalize-*:` headersZalathar-2/+2
2024-06-30add `rustc_dump_def_parents` attributeBoxy-0/+162
2024-06-29Rollup merge of #127118 - surechen:fix_126789, r=jieyouxuMatthias Krüger-0/+16
Show `used attribute`'s kind for user when find it isn't applied to a `static` variable. For example : ```rust extern "C" { #[used] //~ ERROR attribute must be applied to a `static` variable static FOO: i32; // show the kind of this item to help user understand why the error is reported. } ``` fixes #126789
2024-06-29Show `used attribute`'s kind for user when find it isn't applied to a ↵surechen-0/+16
`static` variable. fixes #126789
2024-06-24resolve: Implement a lint for out-of-scope use of `macro_rules`Vadim Petrochenkov-49/+113
2024-06-24ast: Standardize visiting order for attributes and node IDsVadim Petrochenkov-5/+37
2024-06-23Add hard error and migration lint for unsafe attrscarbotaniuman-6/+6
2024-06-22Add `#[rustc_dump_{predicates,item_bounds}]`León Orell Valerian Liehr-0/+59
2024-06-06Add double unsafe testcarbotaniuman-0/+36
2024-06-06Error on unsafe on non-unsafe attributecarbotaniuman-0/+34
2024-06-06Add testscarbotaniuman-0/+14
2024-06-06Disallow unsafe in derivecarbotaniuman-0/+14
2024-05-29ast: Revert a breaking attribute visiting order changeVadim Petrochenkov-19/+3
2024-05-29Add a test for resolving `macro_rules` calls inside attributesVadim Petrochenkov-0/+202
2024-05-20Note for E0599 if shadowed bindings has the method.surechen-0/+8
implement #123558
2024-05-10Fix parse error message for meta itemsLeón Orell Valerian Liehr-2/+2
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-384/+0
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern was raised related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was also raised, namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.
2024-04-29Typo fix: exec:ing -> exec'ingMartin Nordholts-1/+1
2024-04-25debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and ↵Vadim Petrochenkov-96/+95
`#[collapse_debuginfo]` `-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local). `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-24Rollup merge of #123316 - Enselic:sigpipe-inherit-variants, r=fmeaseLeón Orell Valerian Liehr-8/+39
Test `#[unix_sigpipe = "inherit"]` with both `SIG_DFL` and `SIG_IGN` Extend our `#[unix_sigpipe = "inherit"]` test so that it detects if `SIGPIPE` wrongly ends up being `SIG_DFL` when the parent has `SIG_IGN`. We have no current test for this particular case. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-04-18Auto merge of #124072 - saethlin:less-sysroot-libc-misc, r=jieyouxubors-2/+0
Remove libc from more tests The goal here is to trim down the number of tests that depend on libc from the sysroot to make https://github.com/rust-lang/rust/pull/123938 more plausible. This PR is a few simple cases that I missed in https://github.com/rust-lang/rust/pull/123943.
2024-04-17Remove libc from rust_get_test_int usesBen Kimock-1/+1
2024-04-17Remove libc from more testsBen Kimock-2/+0
2024-04-13Test `#[unix_sigpipe = "inherit"]` with both `SIG_DFL` and `SIG_IGN`Martin Nordholts-8/+39
Add a test that fails if `#[unix_sigpipe = "inherit"]` wrongly results in `SIGPIPE` being `SIG_DFL` if the parent has `SIG_IGN`. We have no current test for this particular case.
2024-03-25unix_sigpipe: Add test for SIGPIPE disposition in child processesMartin Nordholts-0/+90
For robustness, also test the disposition in our own process even if other tests in `tests/ui/attributes/unix_sigpipe` already covers it.
2024-03-16Rollup merge of #121545 - ↵León Orell Valerian Liehr-0/+15
gvozdvmozgu:fix-attribute-validation-associated-items, r=fmease fix attribute validation on associated items in traits #121537, fixed attribute validation on associated items in traits
2024-03-12tests: Add ui/attributes/unix_sigpipe/unix_sigpipe-str-list.rsMartin Nordholts-1/+13
Which is a variant of [`unix_sigpipe-list.rs`][1] but where a string is used instead of an identifier. This makes it more similar to the proper form `#[unix_sigpipe = "sig_dfl"]` and thus more likely to be written by users by mistake. Also rename the first test to be more in line with the terminology of [The Reference][2]. [1]: https://github.com/rust-lang/rust/blob/master/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs [2]: https://doc.rust-lang.org/reference/attributes.html#meta-item-attribute-syntax