Commit Graph

869 Commits

Author SHA1 Message Date
bors
1202bbaf48 Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov
Remove `TreeAndSpacing`.

A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.

r? `@petrochenkov`
2022-07-30 14:50:05 +00:00
Yuki Okushi
5c3b6d6882
Rollup merge of #99888 - nnethercote:streamline-visitors, r=cjgillot
Streamline lint checking

The early (AST) and late (HIR) lint checkers have a number of functions that aren't used by rustc or clippy. Might as well remove them -- it's not like there's a canonical API here, as shown by the ad hoc use of `check_foo`/`check_foo_post` combinations.

r? `@cjgillot`
2022-07-30 07:39:54 +09:00
Nicholas Nethercote
332dffb1f9 Remove TreeAndSpacing.
A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.
2022-07-29 15:52:15 +10:00
Nicholas Nethercote
74e9a29f6e Remove some late check_* functions.
They're not used by rustc or clippy.
2022-07-29 15:30:12 +10:00
Nicholas Nethercote
ab44b5a408 Remove some early check_* functions.
They're not used by rustc or clippy.
2022-07-29 15:27:16 +10:00
bors
ea6ab1bd84 Auto merge of #99660 - PrestonFrom:issue_99265, r=compiler-errors
Generate correct suggestion with named arguments used positionally

Address issue #99265 by checking each positionally used argument
to see if the argument is named and adding a lint to use the name
instead. This way, when named arguments are used positionally in a
different order than their argument order, the suggested lint is
correct.

For example:
```
println!("{b} {}", a=1, b=2);
```
This will now generate the suggestion:
```
println!("{b} {a}", a=1, b=2);
```

Additionally, this check now also correctly replaces or inserts
only where the positional argument is (or would be if implicit).
Also, width and precision are replaced with their argument names
when they exists.

Since the issues were so closely related, this fix for issue #99265
also fixes issue #99266.

Fixes #99265
Fixes #99266
2022-07-29 04:23:08 +00:00
Camille GILLOT
6733bc3066 Remove guess_head_span. 2022-07-28 23:14:04 +02:00
David Wood
7bab769b58 lint: add bad opt access internal lint
Some command-line options accessible through `sess.opts` are best
accessed through wrapper functions on `Session`, `TyCtxt` or otherwise,
rather than through field access on the option struct in the `Session`.

Adds a new lint which triggers on those options that should be accessed
through a wrapper function so that this is prohibited. Options are
annotated with a new attribute `rustc_lint_opt_deny_field_access` which
can specify the error message (i.e. "use this other function instead")
to be emitted.

A simpler alternative would be to simply rename the options in the
option type so that it is clear they should not be used, however this
doesn't prevent uses, just discourages them. Another alternative would
be to make the option fields private, and adding accessor functions on
the option types, however the wrapper functions sometimes rely on
additional state from `Session` or `TyCtxt` which wouldn't be available
in an function on the option type, so the accessor would simply make the
field available and its use would be discouraged too.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 11:24:27 +01:00
David Wood
f5e005f0ca session: disable internal lints for rustdoc
If an internal lint uses `typeck_results` or similar queries then that
can result in rustdoc checking code that it shouldn't (e.g. from other
platforms) and emit compilation errors.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 11:24:27 +01:00
David Wood
1b8e4b9391 lint: add comment about diag lints in group
Add a brief comment explaining why the diagnostic migration lints aren't
included in the `rustc::internal` diagnostic group.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 10:59:10 +01:00
Preston From
3330c7d1c3 Generate correct suggestion with named arguments used positionally
Address issue #99265 by checking each positionally used argument
to see if the argument is named and adding a lint to use the name
instead. This way, when named arguments are used positionally in a
different order than their argument order, the suggested lint is
correct.

For example:
```
println!("{b} {}", a=1, b=2);
```
This will now generate the suggestion:
```
println!("{b} {a}", a=1, b=2);
```

Additionally, this check now also correctly replaces or inserts
only where the positional argument is (or would be if implicit).
Also, width and precision are replaced with their argument names
when they exists.

Since the issues were so closely related, this fix for issue #99265
also fixes issue #99266.

Fixes #99265
Fixes #99266
2022-07-25 00:00:27 -06:00
Ibraheem Ahmed
4fdf43f23f special_module_name: ignore inline modules 2022-07-21 17:22:29 -04:00
Dylan DPC
f02bbbcba6
Rollup merge of #99433 - cjgillot:erase-foreign-sig, r=compiler-errors
Erase regions before comparing signatures of foreign fns.

Fixes https://github.com/rust-lang/rust/issues/99276

The version with explicit lifetimes is probably tracked in another bug, but I could not find it.
2022-07-20 11:29:39 +05:30
Camille GILLOT
0065929599 Erase regions before comparing signatures of foreign fns. 2022-07-19 19:36:45 +02:00
Tomasz Miąsko
45afc214af Update invalid atomic ordering lint
The restriction that success ordering must be at least as strong as its
failure ordering in compare-exchange operations was lifted in #98383.
2022-07-18 12:02:11 +02:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
Michael Goulet
2902b92769 Only suggest if span is not erroneous 2022-07-15 17:32:34 +00:00
Michael Goulet
27b6ab9129 Remove some more usages of guess_head_span 2022-07-15 03:17:20 +00:00
Dylan DPC
8c5c983e5b
Rollup merge of #98580 - PrestonFrom:issue_98466, r=estebank
Emit warning when named arguments are used positionally in format

Addresses Issue 98466 by emitting an error if a named argument
is used like a position argument (i.e. the name is not used in
the string to be formatted).

Fixes rust-lang#98466
2022-07-14 19:24:03 +05:30
bors
f1a8854f9b Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97720 (Always create elided lifetime parameters for functions)
 - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
 - #98705 (Implement `for<>` lifetime binder for closures)
 - #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
 - #99139 (Give a better error when `x dist` fails for an optional tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 11:00:30 +00:00
Dylan DPC
e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
Joshua Nelson
3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Preston From
1219f72f90 Emit warning when named arguments are used positionally in format
Addresses Issue 98466 by emitting a warning if a named argument
is used like a position argument (i.e. the name is not used in
the string to be formatted).

Fixes rust-lang#98466
2022-07-13 15:34:10 -06:00
Dylan DPC
1e7d04b23b
Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb
`UnsafeCell` blocks niches inside its nested type from being available outside

fixes #87341

This implements the plan by `@eddyb` in https://github.com/rust-lang/rust/issues/87341#issuecomment-886083646

Somewhat related PR (not strictly necessary, but that cleanup made this PR simpler): #94527
2022-07-13 19:32:34 +05:30
Maybe Waffle
c2dbd62c7c Lower closure binders to hir & properly check them 2022-07-12 21:00:03 +04:00
Maybe Waffle
40ae7b5b8e Parse closure binders
This is first step in implementing RFC 3216.
- Parse `for<'a>` before closures in ast
  - Error in lowering
- Add `closure_lifetime_binder` feature
2022-07-12 16:25:16 +04:00
bors
0f573a0c54 Auto merge of #95573 - cjgillot:lower-query, r=michaelwoerister
Make lowering a query

Split from https://github.com/rust-lang/rust/pull/88186.

This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query.
In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new `NodeId`s and so.

Then, the `TyCtxt` is modified to allow creating new `LocalDefId`s from inside it. This is done by:
- enclosing `Definitions` in a lock, so as to allow modification;
- creating a query `register_def` whose purpose is to declare a `LocalDefId` to the query system.

See `TyCtxt::create_def` and `TyCtxt::iter_local_def_id` for more detailed explanations of the design.
2022-07-07 18:14:44 +00:00
Dylan DPC
c815fef795
Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, r=wesleywiser
Finishing touches for `#[expect]` (RFC 2383)

This PR adds documentation and some functionality to rustc's lint passes, to manually fulfill expectations. This is needed for some lints in Clippy. Hopefully, it should be one of the last things before we can move forward with stabilizing this feature.

As part of this PR, I've also updated `clippy::duplicate_mod` to showcase how this new functionality can be used and to ensure that it works correctly.

---

changelog: [`duplicate_mod`]: Fixed lint attribute interaction

r? `@wesleywiser`

cc: https://github.com/rust-lang/rust/issues/97660, https://github.com/rust-lang/rust/issues/85549

And I guess that's it. Here have a magical unicorn 🦄
2022-07-07 18:06:50 +05:30
Oli Scherer
8d9f609d0d Comment update 2022-07-07 11:19:57 +00:00
Oli Scherer
2a899dc1cf UnsafeCell now has no niches, ever. 2022-07-07 10:46:22 +00:00
Camille GILLOT
250c71b85d Make AST lowering a query. 2022-07-06 23:04:55 +02:00
xFrednet
c8b4873cf9
Add function to manually fulfill lint expectations (RFC 2383) 2022-07-06 22:01:39 +02:00
Guillaume Gomez
d712f67897
Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, r=cjgillot
Replace some `guess_head_span` with `def_span`

This patch fixes a part of #97417.
r? `@cjgillot`
2022-07-06 20:43:24 +02:00
Takayuki Maeda
b730bc9f20 fix miri-opt tests 2022-07-06 19:09:50 +09:00
Takayuki Maeda
83dea35384 replace guess_head_span with def_span 2022-07-06 19:09:47 +09:00
Dylan DPC
df1f415305
Rollup merge of #98884 - davidtwco:translation-on-lints-derive, r=oli-obk
macros: `LintDiagnostic` derive

- Move `LintDiagnosticBuilder` into `rustc_errors` so that a diagnostic derive can refer to it.
- Introduce a `DecorateLint` trait, which is equivalent to `SessionDiagnostic` or `AddToDiagnostic` but for lints. Necessary without making more changes to the lint infrastructure as `DecorateLint` takes a `LintDiagnosticBuilder` and re-uses all of the existing logic for determining what type of diagnostic a lint should be emitted as (e.g. error/warning).
- Various refactorings of the diagnostic derive machinery (extracting `build_field_mapping` helper and moving `sess` field out of the `DiagnosticDeriveBuilder`).
- Introduce a `LintDiagnostic` derive macro that works almost exactly like the `SessionDiagnostic` derive macro  except that it derives a `DecorateLint` implementation instead. A new derive is necessary for this because `SessionDiagnostic` is intended for when the generated code creates the diagnostic. `AddToDiagnostic` could have been used but it would have required more changes to the lint machinery.

~~At time of opening this pull request, ignore all of the commits from #98624, it's just the last few commits that are new.~~

r? `@oli-obk`
2022-07-06 14:49:10 +05:30
Alan Egerton
4f0a64736b
Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
David Wood
9d864c8d56 macros: add diagnostic derive for lints
`SessionDiagnostic` isn't suitable for use on lints as whether or not it
creates an error or a warning is decided at compile-time by the macro,
whereas lints decide this at runtime based on the location of the lint
being reported (as it will depend on the user's `allow`/`deny`
attributes, etc). Re-using most of the machinery for
`SessionDiagnostic`, this macro introduces a `LintDiagnostic` derive
which implements a `DecorateLint` trait, taking a
`LintDiagnosticBuilder` and adding to the lint according to the
diagnostic struct.
2022-07-05 16:00:21 +01:00
David Wood
540eaf985d errors: introduce DecorateLint
Add a new trait to be generated by diagnostic derives which uses a
`LintDiagnosticBuilder`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05 16:00:20 +01:00
David Wood
2874f09534 lint: LintDiagnosticBuilder into rustc_errors
Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05 16:00:20 +01:00
Dylan DPC
291df97fae
Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errors
lints: mostly translatable diagnostics

As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway).

r? ``@compiler-errors``
2022-07-05 16:04:32 +05:30
Andy Russell
625122af9f
fix grammar in useless doc comment lint 2022-06-30 16:17:38 -04:00
David Wood
fedd4c63f8 lint: port asm labels diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
5524ca1a1d lint: port deref nullptr diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
2e563a4a3e lint: port clashing extern diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
157cbbca04 lint: add todo for invalid value diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
bd8fe82138 lint: port incomplete features diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
acea23e796 lint: port explicit outlives diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
10676418fa lint: port keyword idents diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
10f2d3f566 lint: port test items diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
3a498a7436 lint: port ... range pattern diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
3c9bda5b20 lint: port trivial bounds diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
01a64af4dd lint: port type alias bounds diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
dbced105db lint: port unreachable pub diagnostic
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
23ee3e0914 lint: port unstable feature diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
d071f504f8 lint: port mutable transmutes diagnostic
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
dbdbdb6874 lint: port no-mangle diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
a13b70ea83 lint: port unused doc comment diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
e151d66343 lint: port deprecated attr diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
18a48c1d6c lint: port anonymous parameter diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
284ec37810 lint: port missing debug impl diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
28655bc955 lint: port missing copy impl diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
82bd2c23e5 lint: port missing documentation diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
7dffd14b96 lint: port unsafe diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
4c63a2145c lint: port non-shorthand pattern diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
d433c9a446 lint: port box pointers diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
588977b350 lint: port while true diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
4f7b10f484 lint: port unused allocation diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
e24833869f lint: port unused import braces diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
fc4f8d9bc2 lint: port unused delimiter diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
2829f519a0 lint: port path statement diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:22 +01:00
David Wood
1999a4c421 lint: port unused diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
0602729c71 lint: port atomic ordering diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
14c3016583 lint: port variant size difference diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
e5f2e0e16c lint: port improper ctypes diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
7a9bef4d83 lint: port overflowing literals diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
7ef610c003 lint: port drop trait/glue diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
8e836566f0 lint: port redundant semicolons diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
37588d6d4e lint: port pass-by-value diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
855f23773b lint: port no-op method call diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
096a69dd19 lint: port non-standard style diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
7ee4aa7003 lint: port non-fmt-panic diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
48e4bf115f lint: port non-ascii-idents diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
c29e05e745 lint: port CString ptr diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
4f35c7993b lint: port translation migration diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
674ac60d5a lint: port non-existant doc keyword diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
1c3a3e0711 lint: port impl LintPass by hand diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
0996a7ab5c lint: port ty diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
8139542598 lint: port query instability diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
e88916cc92 lint: port default hash types diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
fd57269e8c lint: port hidden unicode codepoints diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
a0624eb6c9 lint: port expectation diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
2a69640eb2 lint: port enum intrinsics diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:21 +01:00
David Wood
0f4c4c5e18 lint: port array-into-iter diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:59:19 +01:00
David Wood
7d2eba6311 middle: translation in LintDiagnosticBuilder
Accept `DiagnosticMessage` in `LintDiagnosticBuilder::build` so that
lints can be built with translatable diagnostic messages.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:58:41 +01:00
Dylan DPC
400f435c2d
Rollup merge of #98420 - davidtwco:translation-lint-fixes-and-more-migration, r=compiler-errors
translation: lint fix + more migration

- Unfortunately, the diagnostic lints are very broken and trigger much more often than they should. This PR corrects the conditional which checks if the function call being made is to a diagnostic function so that it returns in every intended case.
- The `rustc_lint_diagnostics` attribute is used by the diagnostic translation/struct migration lints to identify calls where non-translatable diagnostics or diagnostics outwith impls are being created. Any function used in creating a diagnostic should be annotated with this attribute so this PR adds the attribute to many more functions.
- Port the diagnostics from the `rustc_privacy` crate and enable the lints for that crate.

r? ``@compiler-errors``
2022-06-28 15:30:04 +05:30
David Wood
871c879bff lint: fix condition in diagnostic lints
Unfortunately, the diagnostic lints are very broken and trigger much
more often than they should. Correct the conditional which checks if the
function call being made is to a diagnostic function so that it returns
in every intended case.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-27 08:32:06 +01:00
Matthias Krüger
3694e40ffa
Rollup merge of #97389 - m-ou-se:memory-ordering-diagnostics, r=estebank
Improve memory ordering diagnostics

Before:

![image](https://user-images.githubusercontent.com/783247/170234545-891cac30-eaa2-4186-847b-35cd51e00f2b.png)

After:

![image](https://user-images.githubusercontent.com/783247/170239684-645f186f-5a02-4eb9-8651-2e5fe9591352.png)

---

Before this change, the compiler suggests the failure ordering is too strong and suggests choosing a weaker ordering. After this change, it instead suggests the success ordering is not strong enough, and suggests chosing a stronger one. This is more likely to be correct.

Also, before this change, the compiler suggested downgrading an invalid AcqRel failure ordering to Relaxed, without mentioning Acquire as an option.
2022-06-27 08:06:45 +02:00
Mara Bos
f107923cc0 Slightly tweak invalid atomic ordering lint messages.
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-06-22 20:09:23 +02:00
Camille GILLOT
47b8d26eff Use ensure for UnusedBrokenConst. 2022-06-19 09:44:32 +02:00