Commit Graph

90 Commits

Author SHA1 Message Date
yukang
53dba7fb55 fix spans of arguments in diagnostic 2024-03-03 10:48:40 +08:00
yukang
5a5c6dfb33 Fix misleading message when using a named constant as a struct alignment/pack 2024-03-02 23:15:39 +08:00
Guillaume Gomez
8e817af3ae Update ui tests 2024-02-29 14:43:43 +01:00
Guillaume Gomez
d8e6550838
Rollup merge of #121527 - Enselic:unix_sigpipe-tests-fixes, r=davidtwco
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 948b1d68ab (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 d14f15862d
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 a1cb3dba84
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 e060274e55
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-28 16:04:50 +01:00
Martin Nordholts
f5b9eaf18f Don't unnecessarily change SIGPIPE disposition in unix_sigpipe tests
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-24 16:18:34 +01:00
gvozdvmozgu
8b576d5536 fix attribute validation on associated items in traits 2024-02-24 08:14:38 -05:00
Martin Nordholts
948b1d68ab 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"]
2024-02-23 22:03:09 +01:00
Martin Nordholts
d14f15862d 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.
2024-02-23 22:03:09 +01:00
Martin Nordholts
a1cb3dba84 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"]
2024-02-23 22:02:27 +01:00
Martin Nordholts
e060274e55 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.
2024-02-23 21:59:35 +01:00
Esteban Küber
28c028737d Deduplicate some logic and reword output 2024-02-22 18:05:28 +00:00
Esteban Küber
e1e4da2b0a Make confusable suggestions verbose 2024-02-22 18:04:55 +00:00
Esteban Küber
385eea1d46 Consider methods from traits when suggesting typos
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-22 18:04:55 +00:00
Esteban Küber
d30dfb0af7 Provide more and more accurate suggestions when calling the wrong method
```
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-22 18:04:55 +00:00
Esteban Küber
0e89465672 On type error of method call arguments, look at confusables for suggestion 2024-02-22 18:04:55 +00:00
Esteban Küber
e5b3c7ef14 Add rustc_confusables annotations to some stdlib APIs
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-22 18:04:55 +00:00
许杰友 Jieyou Xu (Joe)
ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Nicholas Nethercote
226edf64fa Improve an error involving attribute values.
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-12-12 15:54:25 +11:00
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Esteban Küber
27919ceba7 Tweak suggestion spans for invalid crate-level inner attribute
CC #89566.
2023-10-26 18:35:09 +00:00
bors
98b4a64a16 Auto merge of #117126 - matthiaskrgr:rollup-8huie8f, r=matthiaskrgr
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-24 17:28:45 +00:00
Matthew Jasper
712106b122 Add regression test for #117058 2023-10-24 08:21:52 +00:00
David Tolnay
6a02e20fb5
Update since stability attributes in tests 2023-10-23 13:04:47 -07:00
Gurinder Singh
19574d216a Return ident for ExprField and PatField HIR nodes 2023-09-01 06:36:02 +05:30
Arthur Cohen
bdf4e3de9c check_attrs: Warn when #[macro_export] is used on macros 2.0
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-08-07 21:14:28 +02:00
Lukas Markeffsky
637ea3f746 validate doc(masked) 2023-07-24 18:04:35 +02:00
许杰友 Jieyou Xu (Joe)
08c77a6eb4
Add infrastructure #[rustc_confusables] attribute to allow targeted
"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-07-16 19:22:03 +08:00
Obei Sideg
70bbcceaec Add test for #![doc(test(...)] with literal parameter 2023-05-29 22:33:46 +03:00
Michael Goulet
183c7904e9 Add invalid_macro_export_arguments to built-in macro list 2023-04-27 18:33:39 +00:00
clubby789
6a41cfe095 Migrate rustc_passes to translatable diagnostics 2023-04-26 11:40:21 +01:00
Deadbeef
84de04155c add test for invalid places of repr align 2023-04-17 12:42:02 +00:00
Pietro Albini
703ba0ce26
fix ignore-thumbv8m.base 2023-04-03 09:24:07 +02:00
Camille GILLOT
3102722ef4 Skip no_mangle if the item has no name. 2023-03-28 18:05:12 +00:00
clubby789
d845769557 Restrict #[rustc_box] to Box::new calls 2023-03-02 02:42:19 +00:00
blyxyas
e39fe374df Add check for invalid \#[macro_export]\ arguments 2023-02-22 21:53:16 +00:00
Oli Scherer
f95b553eb4 Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion 2023-02-07 16:33:03 +00:00
bors
3e97763872 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk
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-26 12:44:47 +00:00
Mara Bos
525b0bb77a Bless tests. 2023-01-12 00:25:46 +01:00
Yuki Omoto
4e2a3567bc Add log-backtrace option to show backtraces along with logging 2023-01-12 00:17:48 +09:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00