summary refs log tree commit diff
path: root/tests/ui/attributes
AgeCommit message (Collapse)AuthorLines
2024-04-11fix attribute validation on associated items in traitsgvozdvmozgu-0/+15
(cherry picked from commit 8b576d553678688ece127b6f6a25b611e8726c05)
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
2024-03-11unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax testsMartin Nordholts-14/+14
The `sig_dfl` variant of the attribute is the most likely variant to be stabilized first, and thus to become the "most allowed" variant of the attribute. Because of this, it is the most appropriate variant to use in syntax tests, because even if the most allowed variant is used, the compiler shall still emit errors if it e.g. is used in the wrong places.
2024-03-10diagnostics: Do not suggest using `#[unix_sigpipe]` without a valueMartin Nordholts-11/+4
Remove `Word` from the `unix_sigpipe` attribute template so that plain `#[unix_sigpipe]` is not included in suggestions of valid forms of the attribute. Also re-arrange diagnostics code slightly to avoid duplicate diagnostics.
2024-03-04Auto merge of #121900 - chenyukang:yukang-fix-121425-repr-pack-error, ↵bors-10/+79
r=compiler-errors Fix misleading message in struct repr alignment and packed Fixes #121425 By the way, fix the spans for the argument in the second commit.
2024-03-03fix spans of arguments in diagnosticyukang-9/+9
2024-03-02Fix misleading message when using a named constant as a struct alignment/packyukang-10/+79
2024-02-29Update ui testsGuillaume Gomez-53/+10
2024-02-28Rollup merge of #121527 - Enselic:unix_sigpipe-tests-fixes, r=davidtwcoGuillaume Gomez-16/+25
unix_sigpipe: Simple fixes and improvements in tests In https://github.com/rust-lang/rust/pull/120832 I included 5 preparatory commits. It will take a while before discussions there and in https://github.com/rust-lang/rust/issues/62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way. r? ``@davidtwco`` who already approved these commits in https://github.com/rust-lang/rust/pull/120832 (but I have tweaked them a bit and rebased them since then). For the convenience of my reviewer, here are the full commit messages of the commits: <details> <summary>Click to expand</summary> ``` commit 948b1d68abdf6ccde608831401dfe35af4a8cb04 (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes) Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 07:57:27 2024 +0100 tests: Add unix_sigpipe-different-duplicates.rs test variant To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"] commit d14f15862d2ac7111f70efe82882fb3575167a53 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 08:47:47 2024 +0100 tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead. commit a1cb3dba840fd56a7f9a0c90346a1fcddc641f9c Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 06:44:56 2024 +0100 tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"] commit e060274e55a5b09fe6ace6dfe72ca0cca663b711 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 05:48:24 2024 +0100 tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs There is no error expected. It's simply the "regular" test for sig_ign. So rename it. ``` </details> Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-02-24Don't unnecessarily change `SIGPIPE` disposition in unix_sigpipe testsMartin Nordholts-6/+6
In `auxiliary/sigpipe-utils.rs`, all we want to know is the current `SIGPIPE` disposition. We should not change it. So use `libc::sigaction` instead of `libc::signal`. That way we can also remove the code that restores it.
2024-02-23tests: Add unix_sigpipe-different-duplicates.rs test variantMartin Nordholts-2/+21
To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"]
2024-02-23tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rsMartin Nordholts-13/+3
The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead.
2024-02-23tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarityMartin Nordholts-1/+1
The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"]
2024-02-23tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rsMartin Nordholts-0/+0
There is no error expected. It's simply the "regular" test for sig_ign. So rename it.
2024-02-22Deduplicate some logic and reword outputEsteban Küber-2/+2
2024-02-22Make confusable suggestions `verbose`Esteban Küber-1/+6
2024-02-22Consider methods from traits when suggesting typosEsteban Küber-5/+3
Do not provide a structured suggestion when the arguments don't match. ``` error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope --> $DIR/auto-ref-slice-plus-ref.rs:7:7 | LL | a.test_mut(); | ^^^^^^^^ | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test_mut`, perhaps you need to implement it --> $DIR/auto-ref-slice-plus-ref.rs:14:1 | LL | trait MyIter { | ^^^^^^^^^^^^ help: there is a method `get_mut` with a similar name, but with different arguments --> $SRC_DIR/core/src/slice/mod.rs:LL:COL ``` Consider methods beyond inherent ones when suggesting typos. ``` error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope --> $DIR/object-pointer-types.rs:11:7 | LL | fn owned(self: Box<Self>); | --------- the method might not be found because of this arbitrary self type ... LL | x.owned(); | ^^^^^ help: there is a method with a similar name: `to_owned` ``` Fix #101013.
2024-02-22Provide more and more accurate suggestions when calling the wrong methodEsteban Küber-3/+22
``` error[E0308]: mismatched types --> $DIR/rustc_confusables_std_cases.rs:20:14 | LL | x.append(42); | ------ ^^ expected `&mut Vec<{integer}>`, found integer | | | arguments to this method are incorrect | = note: expected mutable reference `&mut Vec<{integer}>` found type `{integer}` note: method defined here --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: you might have meant to use `push` | LL | x.push(42); | ~~~~ ```
2024-02-22On type error of method call arguments, look at confusables for suggestionEsteban Küber-1/+19
2024-02-22Add `rustc_confusables` annotations to some stdlib APIsEsteban Küber-2/+102
Help with common API confusion, like asking for `push` when the data structure really has `append`. ``` error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:17:7 | LL | x.size(); | ^^^^ | help: you might have meant to use `len` | LL | x.len(); | ~~~ help: there is a method with a similar name | LL | x.resize(); | ~~~~~~ ``` #59450
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-60/+60
2023-12-12Improve an error involving attribute values.Nicholas Nethercote-22/+15
Attribute values must be literals. The error you get when that doesn't hold is pretty bad, e.g.: ``` unexpected expression: 1 + 1 ``` You also get the same error if the attribute value is a literal, but an invalid literal, e.g.: ``` unexpected expression: "foo"suffix ``` This commit does two things. - Changes the error message to "attribute value must be a literal", which gives a better idea of what the problem is and how to fix it. It also no longer prints the invalid expression, because the carets below highlight it anyway. - Separates the "not a literal" case from the "invalid literal" case. Which means invalid literals now get the specific error at the literal level, rather than at the attribute level.
2023-11-24Show number in error message even for one errorNilstrieb-23/+23
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-10-26Tweak suggestion spans for invalid crate-level inner attributeEsteban Küber-2/+6
CC #89566.
2023-10-24Auto merge of #117126 - matthiaskrgr:rollup-8huie8f, r=matthiaskrgrbors-0/+95
Rollup of 5 pull requests Successful merges: - #117081 (fix typos in comments) - #117091 (`OptWithInfcx` naming nits, trait bound simplifications) - #117092 (Add regression test for #117058) - #117093 (Update books) - #117105 (remove change-id assertion in bootstrap test) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-24Add regression test for #117058Matthew Jasper-0/+95
2023-10-23Update `since` stability attributes in testsDavid Tolnay-3/+3
2023-09-01Return ident for ExprField and PatField HIR nodesGurinder Singh-0/+36
2023-08-07check_attrs: Warn when #[macro_export] is used on macros 2.0Arthur Cohen-0/+25
The compiler should emit a more specific error when the `#[macro_export]` attribute is present on a decl macro, instead of silently ignoring it. This commit adds the required error message in rustc_passes/messages.ftl, as well as a note. A new variant is added to the `errors::MacroExport` enum, specifically for the case where the attribute is added to a macro 2.0.
2023-07-24validate `doc(masked)`Lukas Markeffsky-110/+0
2023-07-16Add infrastructure `#[rustc_confusables]` attribute to allow targeted许杰友 Jieyou Xu (Joe)-0/+126
"no method" errors on standard library types The standard library developer can annotate methods on e.g. `BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if there are no other candidates to suggest.
2023-05-29Add test for `#![doc(test(...)]` with literal parameterObei Sideg-0/+24
2023-04-27Add invalid_macro_export_arguments to built-in macro listMichael Goulet-19/+30
2023-04-26Migrate `rustc_passes` to translatable diagnosticsclubby789-2/+2
2023-04-17add test for invalid places of repr alignDeadbeef-0/+17
2023-04-03fix ignore-thumbv8m.basePietro Albini-1/+1
2023-03-28Skip no_mangle if the item has no name.Camille GILLOT-0/+19
2023-03-02Restrict `#[rustc_box]` to `Box::new` callsclubby789-0/+52
2023-02-22Add check for invalid \`#[macro_export]\` argumentsblyxyas-0/+42
2023-02-07Replace a command line flag with an env var to allow tools to initialize the ↵Oli Scherer-2/+2
tracing loggers at their own discretion
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-6/+1
Move format_args!() into AST (and expand it during AST lowering) Implements https://github.com/rust-lang/compiler-team/issues/541 This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier. This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`. This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-12Bless tests.Mara Bos-6/+1
2023-01-12Add log-backtrace option to show backtraces along with loggingYuki Omoto-0/+9
2023-01-11Move /src/test to /testsAlbert Larsan-0/+2050