Commit Graph

965 Commits

Author SHA1 Message Date
Matthias Krüger
d6506cc0be
Rollup merge of #102953 - WaffleLapkin:better_docs_for_decorate_param, r=RalfJung
Improve docs for `struct_lint_level` function.

r? ``@RalfJung``

Does this answer your questions?
2022-10-16 17:51:31 +02:00
Rageking8
7122abaddf more dupe word typos 2022-10-14 12:57:56 +08:00
Maybe Waffle
c5de3ecec3 link lint function with decorate function param to struct_lint_level 2022-10-12 14:16:24 +00:00
David Wood
b4ac26289f errors: AddToDiagnostic::add_to_diagnostic_with
`AddToDiagnostic::add_to_diagnostic_with` is similar to the previous
`AddToDiagnostic::add_to_diagnostic` but takes a function that can be
used by the caller to modify diagnostic messages originating from the
subdiagnostic (such as performing translation eagerly).

`add_to_diagnostic` now just calls `add_to_diagnostic_with` with an
empty closure.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10 14:20:16 +01:00
Dylan DPC
81b9d0b1d1
Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type`

Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10 13:43:43 +05:30
Michael Goulet
d3bd6beb97 Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
Maybe Waffle
9d4edff1b0 adopt to building infcx 2022-10-09 13:07:21 +00:00
Maybe Waffle
40f36fac49 adopt to new rustc lint api 2022-10-09 13:07:21 +00:00
Maybe Waffle
7434b9f0d1 fixup lint name 2022-10-09 13:07:21 +00:00
Maybe Waffle
98e0c4df73 fix for_loop_over_fallibles lint docs 2022-10-09 13:07:21 +00:00
Maybe Waffle
6766113c87 remove an infinite loop 2022-10-09 13:07:21 +00:00
Maybe Waffle
b9b2059e84 Edit documentation for for_loop_over_fallibles lint 2022-10-09 13:07:20 +00:00
Maybe Waffle
8ca57b54c1 for_loop_over_fallibles: don't use MachineApplicable
The loop could contain `break;` that won't work with an `if let`
2022-10-09 13:05:53 +00:00
Maybe Waffle
23a7674e3e for_loop_over_fallibles: fix suggestion for "remove .next()" case
if the iterator is used after the loop, we need to use `.by_ref()`
2022-10-09 13:05:53 +00:00
Maybe Waffle
dd842ffc3d for_loop_over_fallibles: remove duplication from the message 2022-10-09 13:05:53 +00:00
Maybe Waffle
b2975ee974 for_loop_over_fallibles: suggest using ? in some cases 2022-10-09 13:05:52 +00:00
Maybe Waffle
5dcfdbf31e for_loop_over_fallibles: suggest while let loop 2022-10-09 13:05:52 +00:00
Maybe Waffle
21ec99b6fa for_loop_over_fallibles: Suggest removing .next() 2022-10-09 13:05:52 +00:00
Maybe Waffle
d030ba52e2 Use structured suggestions for for_loop_over_fallibles lint 2022-10-09 13:05:52 +00:00
Maybe Waffle
fa380a82a5 Start uplifting clippy::for_loops_over_fallibles
I refactored the code:
- Removed handling of methods, as it felt entirely unnecessary
- Removed clippy utils (obviously...)
- Used some shiny compiler features
  (let-else is very handy for lints 👀)
- I also renamed the lint to `for_loop_over_fallibles` (note: no `s`).
  I'm not sure what's the naming convention here, so maybe I'm wrong.
2022-10-09 13:05:52 +00:00
bors
8b0c05d9ad Auto merge of #102091 - RalfJung:const_err, r=oli-obk
make const_err a hard error

This lint has been deny-by-default with future incompat wording since [Rust 1.51](https://github.com/rust-lang/rust/pull/80394) and the stable release of this week starts showing it in cargo's future compat reports. I can't wait to finally get rid of at least some of the mess in our const-err-reporting-code. ;)

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/71800
Fixes https://github.com/rust-lang/rust/issues/100114
2022-10-07 20:50:51 +00:00
Ralf Jung
fd59d44f58 make const_err a hard error 2022-10-07 18:08:49 +02:00
Cameron Steffen
283abbf0e7 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Matthias Krüger
42df0a580f
Rollup merge of #102725 - nnethercote:rm-Z-time, r=davidtwco
Remove `-Ztime`

Because it has a lot of overlap with `-Ztime-passes` but is generally less useful. Plus some related cleanups.

Best reviewed one commit at a time.

r? `@davidtwco`
2022-10-06 16:29:45 +02:00
Nicholas Nethercote
9110d925d0 Remove -Ztime option.
The compiler currently has `-Ztime` and `-Ztime-passes`. I've used
`-Ztime-passes` for years but only recently learned about `-Ztime`.

What's the difference? Let's look at the `-Zhelp` output:
```
  -Z        time=val -- measure time of rustc processes (default: no)
  -Z time-passes=val -- measure time of each rustc pass (default: no)
```
The `-Ztime-passes` description is clear, but the `-Ztime` one is less so.
Sounds like it measures the time for the entire process?

No. The real difference is that `-Ztime-passes` prints out info about passes,
and `-Ztime` does the same, but only for a subset of those passes. More
specifically, there is a distinction in the profiling code between a "verbose
generic activity" and an "extra verbose generic activity". `-Ztime-passes`
prints both kinds, while `-Ztime` only prints the first one. (It took me
a close reading of the source code to determine this difference.)

In practice this distinction has low value. Perhaps in the past the "extra
verbose" output was more voluminous, but now that we only print stats for a
pass if it exceeds 5ms or alters the RSS, `-Ztime-passes` is less spammy. Also,
a lot of the "extra verbose" cases are for individual lint passes, and you need
to also use `-Zno-interleave-lints` to see those anyway.

Therefore, this commit removes `-Ztime` and the associated machinery. One thing
to note is that the existing "extra verbose" activities all have an extra
string argument, so the commit adds the ability to accept an extra argument to
the "verbose" activities.
2022-10-06 15:49:44 +11:00
Michael Goulet
fe0533638c Use proper subdiagnostic 2022-10-05 19:55:19 +00:00
Michael Goulet
8e7783bd13 Fix opaque_hidden_inferred_bound lint ICE 2022-10-05 19:47:19 +00:00
Dylan DPC
35f92ed1bf
Rollup merge of #102568 - compiler-errors:lint-unsatisfied-opaques, r=oli-obk
Lint against nested opaque types that don't satisfy associated type bounds

See the test failures for examples of places where this lint would fire.

r? `@oli-obk`
2022-10-04 16:11:02 +05:30
Michael Goulet
e1b313af46 We are able to resolve methods even if they need subst 2022-10-04 03:29:19 +00:00
Michael Goulet
8c600120e6 Normalize substs before resolving instance in NoopMethodCall lint 2022-10-04 03:20:49 +00:00
Michael Goulet
7a8854037b Add example to opaque_hidden_inferred_bound lint 2022-10-02 19:54:39 +00:00
Michael Goulet
426424b320 Make it a lint for all opaque types 2022-10-02 19:50:19 +00:00
Michael Goulet
d0d6af9146 Lint for unsatisfied nested opaques 2022-10-02 19:50:19 +00:00
Camille GILLOT
fec53fd9db Add sanity Drop impl. 2022-10-01 16:24:44 +02:00
Camille GILLOT
299e10d7ad Add FIXME. 2022-10-01 16:24:34 +02:00
Camille GILLOT
13608715d8 Replace retain with assertion. 2022-10-01 16:23:20 +02:00
Camille GILLOT
c2d5dd2566 Add fast path without visiting. 2022-10-01 16:23:10 +02:00
Camille GILLOT
e78dd6d781 Simplify LintLevelsProvider. 2022-10-01 16:23:00 +02:00
Camille GILLOT
d08669c4fa Compute by owner instead of HirId. 2022-10-01 16:22:40 +02:00
Camille GILLOT
273b54d6ac Add FIXME. 2022-10-01 16:19:52 +02:00
Camille GILLOT
af495f8bb6 Comment LintLevelSets. 2022-10-01 16:19:40 +02:00
Camille GILLOT
34bc5c8824 Move lint level computation to rustc_middle::lint. 2022-10-01 16:18:54 +02:00
Camille GILLOT
6977f7dbe9 Reduce visibilities and remove dead code. 2022-10-01 16:18:42 +02:00
Camille GILLOT
41db9b152f Move code to rustc_lint. 2022-10-01 16:18:13 +02:00
Camille GILLOT
107170b9c3 Remove unused tool_name. 2022-10-01 16:12:54 +02:00
Deadbeef
3cb1811e45 Compute lint_levels by definition 2022-10-01 16:12:50 +02:00
bors
744e397d88 Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebank
Move lint level source explanation to the bottom

So, uhhhhh

r? `@estebank`

## User-facing change

"note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic:
```diff
-   = note: `#[warn(unsupported_calling_conventions)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
+   = note: `#[warn(unsupported_calling_conventions)]` on by default
```

Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO.

## Developer-facing change

`struct_span_lint` and similar methods have a different signature.

Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)`
After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>`

The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion.

Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere.

## Subtle problem

By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings...

I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate.

## P.S.

I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01 10:44:25 +00:00
Maybe Waffle
d028db9dbd ui-fulldeps: adopt to the new rustc lint API 2022-10-01 10:03:07 +00:00
Maybe Waffle
a8f7e244b7 Refactor rustc lint API 2022-10-01 10:03:06 +00:00
bors
1bb8d276c9 Auto merge of #101887 - nnethercote:shrink-Res, r=spastorino
Shrink `hir::def::Res`

r? `@spastorino`
2022-09-29 22:45:24 +00:00