Commit Graph

289 Commits

Author SHA1 Message Date
bors
9e8f53d09a 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
0867c64a54 clippy: adopt to the new lint API 2022-10-01 10:03:06 +00:00
Nicholas Nethercote
8b59fe4981 Shrink hir::def::Res.
`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-29 08:44:52 +10:00
lcnr
e5ce6d18df rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
Pietro Albini
06568fd6c7 remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
fee1-dead
c69edba515 Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
Stabilize const `BTree{Map,Set}::new`

The FCP was completed in #71835.

Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2022-09-26 13:09:42 +08:00
Takayuki Maeda
ea75178219 separate definitions and HIR owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
Nilstrieb
e30b37b84b Fix clippy's const fn stability check for CURRENT_RUSTC_VERSION
Since clippy can use a projects MSRV for its lints, it might not want
to consider functions as const stable if they have been added lately.

Functions that have been stabilized this version use
CURRENT_RUSTC_VERSION as their version, which gets then turned into the
current version, which might be something like `1.66.0-dev`. The version
parser cannot deal with this version, so it has to be stripped off.
2022-09-23 21:04:54 +02:00
b-naber
26861fbd7f rename Unevaluated to UnevaluatedConst 2022-09-23 14:27:34 +02:00
b-naber
adc7e3e679 introduce mir::Unevaluated 2022-09-22 12:35:28 +02:00
David Koloski
4d015293d1 Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy 2022-09-21 13:13:27 -04:00
bors
0dc24ca376 Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
Allow patterns to constrain the hidden type of opaque types

fixes #96572

reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864)

TODO:

* check if https://github.com/rust-lang/rust/issues/99685 is avoided
2022-09-20 12:09:52 +00:00
lcnr
70f4c712c5 remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
Oli Scherer
c2e9c991d5 Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
This reverts commit 4a742a691e.
2022-09-16 11:36:39 +00:00
est31
2be8b73328 Fix clippy 2022-09-15 21:21:18 +02:00
bors
f6a07d1d36 Auto merge of #101212 - eholk:dyn-star, r=compiler-errors
Initial implementation of dyn*

This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things:

* Introduce `dyn_star` feature flag
* Adds parsing for `dyn* Trait` types
* Defines `dyn* Trait` as a sized type
* Adds support for explicit casts, like `42usize as dyn* Debug`
  * Including const evaluation of such casts
* Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope
* Adds codegen for method calls, at least for methods that take `&self`

Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits.

Joint work with `@nikomatsakis` and `@compiler-errors.`

r? `@bjorn3`
2022-09-14 18:10:51 +00:00
bors
cf043f6a16 Auto merge of #101709 - nnethercote:simplify-visitors-more, r=cjgillot
Simplify visitors more

A successor to #100392.

r? `@cjgillot`
2022-09-14 05:21:14 +00:00
Eric Holk
27e91b65d5 Address code review comments 2022-09-13 14:50:12 -07:00
Eric Holk
b95b285ef4 Make x.py check work 2022-09-12 17:29:11 -07:00
Markus Reiter
64a42db51a Simplify clippy fix. 2022-09-12 19:46:51 +02:00
Nicholas Nethercote
308153563b Remove unused span argument from visit_name. 2022-09-12 13:44:29 +10:00
Philipp Krones
98bf99e2f8 Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup 2022-09-09 13:36:26 +02:00
Michael Goulet
854f751b26 Appease clippy again 2022-09-09 01:31:46 +00:00
Michael Goulet
ac1c68a5e6 Make clippy happy 2022-09-09 01:31:45 +00:00
Nicholas Nethercote
c86a9c077c Introduce DotDotPos.
This shrinks `hir::Pat` from 88 to 72 bytes.
2022-09-08 15:25:50 +10:00
Nicholas Nethercote
977b6e29a3 Arena-allocate hir::Lifetime.
This shrinks `hir::Ty` from 72 to 48 bytes.

`visit_lifetime` is added to the HIR stats collector because these types
are now stored in memory on their own, instead of being within other
types.
2022-09-08 15:07:19 +10:00
Oli Scherer
9cbbd4a80e Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00
Oli Scherer
e1b3483ee8 Lower the assume intrinsic to a MIR statement 2022-09-06 14:18:32 +00:00
bors
ce339b219a Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-06 03:16:29 +00:00
Takayuki Maeda
4bcaddeeb2 separate the receiver from arguments in HIR under /clippy 2022-09-05 22:25:57 +09:00
Dylan DPC
9ae329232b Rollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwco
Improve HIR stats

#100398 improve the AST stats collection done by `-Zhir-stats`. This PR does the same for HIR stats collection.

r? `@davidtwco`
2022-09-05 14:15:51 +05:30
Cameron Steffen
e5f30f4dfa clippy: BindingAnnotation change 2022-09-02 13:03:11 -05:00
Jason Newcomb
7bd5b012c7 Use CountIsStart in clippy 2022-08-31 09:45:51 -04:00
Jason Newcomb
fb41bfa774 Merge commit 'f51aade56f93175dde89177a92e3669ebd8e7592' into clippyup 2022-08-31 09:24:45 -04:00
Nilstrieb
ce847beb47 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Nicholas Nethercote
3ce109e12d Use &'hir Ty everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Nicholas Nethercote
3b80e994d5 Use &'hir Expr everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Tomasz Miąsko
e4eddc611a Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
Nicholas Nethercote
06d7119f40 Remove the symbol from ast::LitKind::Err.
Because it's never used meaningfully.
2022-08-23 16:56:24 +10:00
Nicholas Nethercote
6e5f90ae46 Shrink ast::Attribute. 2022-08-16 11:10:13 +10:00
Mark Rousskov
1a3192a331 Adjust cfgs 2022-08-12 16:28:15 -04:00
bors
9ac237dce5 Auto merge of #100419 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2022-08-12 00:12:51 +00:00
Philipp Krones
dc29cfb8d5 Merge commit '2b2190cb5667cdd276a24ef8b9f3692209c54a89' into clippyup 2022-08-11 19:42:16 +02:00
Camille GILLOT
cf3f71d2a2 Do not consider method call receiver as an argument in AST. 2022-08-10 18:34:54 +02:00
bors
80a56878cf Auto merge of #99884 - nnethercote:lexer-improvements, r=matklad
Lexer improvements

Some cleanups and small speed improvements.

r? `@matklad`
2022-08-01 12:52:49 +00:00
Nicholas Nethercote
09f9acea0a Shrink Token.
From 72 bytes to 12 bytes (on x86-64).

There are two parts to this:
- Changing various source code offsets from 64-bit to 32-bit. This is
  not a problem because the rest of rustc also uses 32-bit source code
  offsets. This means `Token` is no longer `Copy` but this causes no
  problems.
- Removing the `RawStrError` from `LiteralKind`. Raw string literal
  invalidity is now indicated by a `None` value within
  `RawStr`/`RawByteStr`, and the new `validate_raw_str` function can be
  used to re-lex an invalid raw string literal to get the `RawStrError`.

There is one very small change in behaviour. Previously, if a raw string
literal matched both the `InvalidStarter` and `TooManyHashes` cases,
the latter would override the former. This has now changed, because
`raw_double_quoted_string` now uses `?` and so returns immediately upon
detecting the `InvalidStarter` case. I think this is a slight
improvement to report the earlier-detected error, and it explains the
change in the `test_too_many_hashes` test.

The commit also removes a couple of comments that refer to #77629 and
say that the size of these types don't affect performance. These
comments are wrong, though the performance effect is small.
2022-08-01 08:53:04 +10:00
Dylan DPC
72649cf2a6 Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot
Use LocalDefId for closures more
2022-07-31 17:36:40 +05:30
Cameron Steffen
62907727af Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
Miguel Guarniz
ce5fa10cce Change enclosing_body_owner to return LocalDefId
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Philipp Krones
67c405cc1d Merge commit '3c7e7dbc1583a0b06df5bd7623dd354a4debd23d' into clippyup 2022-07-28 19:08:22 +02:00