]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agoStabilize half_open_range_patterns
Urgau [Sat, 24 Sep 2022 15:22:04 +0000 (17:22 +0200)]
Stabilize half_open_range_patterns

20 months agoAuto merge of #102091 - RalfJung:const_err, r=oli-obk
bors [Fri, 7 Oct 2022 20:50:51 +0000 (20:50 +0000)]
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

20 months agomake const_err a hard error
Ralf Jung [Wed, 21 Sep 2022 11:05:20 +0000 (13:05 +0200)]
make const_err a hard error

20 months agoChange InferCtxtBuilder from enter to build
Cameron Steffen [Tue, 20 Sep 2022 03:03:59 +0000 (22:03 -0500)]
Change InferCtxtBuilder from enter to build

20 months agoIntroduce TypeErrCtxt
Cameron Steffen [Fri, 9 Sep 2022 20:08:06 +0000 (15:08 -0500)]
Introduce TypeErrCtxt

TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't
need to.

20 months agoMerge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup
Philipp Krones [Thu, 6 Oct 2022 15:41:53 +0000 (17:41 +0200)]
Merge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup

20 months agoMerge commit 'ac0e10aa68325235069a842f47499852b2dee79e' into clippyup
Philipp Krones [Thu, 6 Oct 2022 07:44:38 +0000 (09:44 +0200)]
Merge commit 'ac0e10aa68325235069a842f47499852b2dee79e' into clippyup

20 months agoIt's not about types or consts, but the lack of regions
Oli Scherer [Tue, 4 Oct 2022 09:43:34 +0000 (09:43 +0000)]
It's not about types or consts, but the lack of regions

20 months agoAuto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebank
bors [Sat, 1 Oct 2022 10:44:25 +0000 (10:44 +0000)]
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 😢

20 months agobless clippy
Maybe Waffle [Thu, 22 Sep 2022 16:04:22 +0000 (20:04 +0400)]
bless clippy

20 months agoclippy: adopt to the new lint API
Maybe Waffle [Fri, 16 Sep 2022 15:07:01 +0000 (19:07 +0400)]
clippy: adopt to the new lint API

21 months agoShrink `hir::def::Res`.
Nicholas Nethercote [Fri, 16 Sep 2022 01:45:33 +0000 (11:45 +1000)]
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.

21 months agorustc_typeck to rustc_hir_analysis
lcnr [Mon, 26 Sep 2022 11:00:29 +0000 (13:00 +0200)]
rustc_typeck to rustc_hir_analysis

21 months agoremove cfg(bootstrap)
Pietro Albini [Tue, 20 Sep 2022 13:41:42 +0000 (15:41 +0200)]
remove cfg(bootstrap)

21 months agoRollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
fee1-dead [Mon, 26 Sep 2022 05:09:42 +0000 (13:09 +0800)]
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.

21 months agoseparate definitions and `HIR` owners
Takayuki Maeda [Tue, 20 Sep 2022 05:11:23 +0000 (14:11 +0900)]
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)`

21 months agoAuto merge of #102068 - cjgillot:erased-lifetime-print, r=eholk
bors [Sat, 24 Sep 2022 01:23:17 +0000 (01:23 +0000)]
Auto merge of #102068 - cjgillot:erased-lifetime-print, r=eholk

Always print '_, even for erased lifetimes.

Explicit lifetime arguments are now the recommended syntax in rust 2018 and rust 2021.  This PR applies this discipline to rustc itself.

21 months agoFix clippy's const fn stability check for CURRENT_RUSTC_VERSION
Nilstrieb [Fri, 23 Sep 2022 19:04:54 +0000 (21:04 +0200)]
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.

21 months agoStabilize const `BTree{Map,Set}::new`
Nilstrieb [Fri, 23 Sep 2022 16:03:44 +0000 (18:03 +0200)]
Stabilize const `BTree{Map,Set}::new`

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.

21 months agoBless clippy.
Camille GILLOT [Thu, 22 Sep 2022 17:39:38 +0000 (19:39 +0200)]
Bless clippy.

21 months agoAuto merge of #102056 - b-naber:unevaluated, r=lcnr
bors [Fri, 23 Sep 2022 13:39:11 +0000 (13:39 +0000)]
Auto merge of #102056 - b-naber:unevaluated, r=lcnr

Introduce mir::Unevaluated

Previously the distinction between unevaluated constants in the type-system and in mir was not explicit and a little confusing. Probably better to introduce its own type for that.

r? `@lcnr`

21 months agorename Unevaluated to UnevaluatedConst
b-naber [Thu, 22 Sep 2022 10:34:23 +0000 (12:34 +0200)]
rename Unevaluated to UnevaluatedConst

21 months agoRollup merge of #102123 - schteve:clippy-note, r=Manishearth
Matthias Krüger [Thu, 22 Sep 2022 19:34:51 +0000 (21:34 +0200)]
Rollup merge of #102123 - schteve:clippy-note, r=Manishearth

Add note to clippy::non_expressive_names doc

Addresses confusion in rust-lang/rust-clippy#9514 by updating the lint docs.

21 months agointroduce mir::Unevaluated
b-naber [Mon, 19 Sep 2022 17:46:53 +0000 (19:46 +0200)]
introduce mir::Unevaluated

21 months agoAdd note to clippy::non_expressive_names doc
Steve Heindel [Wed, 21 Sep 2022 23:45:57 +0000 (19:45 -0400)]
Add note to clippy::non_expressive_names doc

21 months agoMerge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy
David Koloski [Wed, 21 Sep 2022 17:02:37 +0000 (13:02 -0400)]
Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy

21 months agoAuto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
bors [Tue, 20 Sep 2022 12:09:52 +0000 (12:09 +0000)]
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

21 months agoremove the `Subst` trait, always use `EarlyBinder`
lcnr [Fri, 16 Sep 2022 13:31:10 +0000 (15:31 +0200)]
remove the `Subst` trait, always use `EarlyBinder`

21 months agoRevert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
Oli Scherer [Wed, 27 Jul 2022 11:58:34 +0000 (11:58 +0000)]
Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""

This reverts commit 4a742a691e7dd2522bad68b86fe2fd5a199d5561.

21 months agoFix clippy
est31 [Fri, 4 Feb 2022 09:13:48 +0000 (10:13 +0100)]
Fix clippy

21 months agoAuto merge of #101811 - flip1995:clippyup, r=flip1995
bors [Thu, 15 Sep 2022 08:53:51 +0000 (08:53 +0000)]
Auto merge of #101811 - flip1995:clippyup, r=flip1995

Clippy pre beta branch fix

Before beta is branched on Friday, I want to move the `unused_peekable` lint  that was added in this release cycle (1.65) to `nursery`. This lint was already reported twice (https://github.com/rust-lang/rust-clippy/issues/9456, https://github.com/rust-lang/rust-clippy/issues/9462) in a short time, so it is probably a good idea to fix it before it hits beta and then stable.

r? `@Manishearth`

21 months agoTemporarily move clippy::unused_peekable to nursery
Philipp Krones [Wed, 14 Sep 2022 18:13:30 +0000 (20:13 +0200)]
Temporarily move clippy::unused_peekable to nursery

21 months agoAuto merge of #101212 - eholk:dyn-star, r=compiler-errors
bors [Wed, 14 Sep 2022 18:10:51 +0000 (18:10 +0000)]
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`

21 months agoAuto merge of #101709 - nnethercote:simplify-visitors-more, r=cjgillot
bors [Wed, 14 Sep 2022 05:21:14 +0000 (05:21 +0000)]
Auto merge of #101709 - nnethercote:simplify-visitors-more, r=cjgillot

Simplify visitors more

A successor to #100392.

r? `@cjgillot`

21 months agoAddress code review comments
Eric Holk [Tue, 30 Aug 2022 19:44:00 +0000 (12:44 -0700)]
Address code review comments

21 months agoAuto merge of #100640 - reitermarkus:socket-display-buffer, r=thomcc
bors [Tue, 13 Sep 2022 06:41:37 +0000 (06:41 +0000)]
Auto merge of #100640 - reitermarkus:socket-display-buffer, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of https://github.com/rust-lang/rust/pull/100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.

21 months agoMake x.py check work
Eric Holk [Tue, 30 Aug 2022 19:39:28 +0000 (12:39 -0700)]
Make x.py check work

21 months agoSimplify `clippy` fix.
Markus Reiter [Mon, 12 Sep 2022 17:03:24 +0000 (19:03 +0200)]
Simplify `clippy` fix.

21 months agoFix clippy.
Markus Reiter [Thu, 1 Sep 2022 23:11:20 +0000 (01:11 +0200)]
Fix clippy.

21 months agoAuto merge of #99334 - NiklasJonsson:84447/error-privacy, r=oli-obk
bors [Mon, 12 Sep 2022 15:57:37 +0000 (15:57 +0000)]
Auto merge of #99334 - NiklasJonsson:84447/error-privacy, r=oli-obk

rustc_error, rustc_private: Switch to stable hash containers

Relates https://github.com/rust-lang/rust/issues/84447

21 months agoRemove unused argument from `visit_poly_trait_ref`.
Nicholas Nethercote [Mon, 12 Sep 2022 03:37:18 +0000 (13:37 +1000)]
Remove unused argument from `visit_poly_trait_ref`.

21 months agoRemove unused span argument from `visit_name`.
Nicholas Nethercote [Mon, 12 Sep 2022 03:30:15 +0000 (13:30 +1000)]
Remove unused span argument from `visit_name`.

21 months agoRemove unused span argument from `walk_fn`.
Nicholas Nethercote [Mon, 12 Sep 2022 03:13:22 +0000 (13:13 +1000)]
Remove unused span argument from `walk_fn`.

21 months agoAuto merge of #98559 - jackh726:remove-reempty, r=oli-obk
bors [Sat, 10 Sep 2022 20:54:01 +0000 (20:54 +0000)]
Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk

Remove ReEmpty

r? rust-lang/types

21 months agorustc_error, rustc_private, rustc_ast: Switch to stable hash containers
Niklas Jonsson [Sat, 16 Jul 2022 13:16:57 +0000 (15:16 +0200)]
rustc_error, rustc_private, rustc_ast: Switch to stable hash containers

21 months agoMerge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup
Philipp Krones [Fri, 9 Sep 2022 11:36:26 +0000 (13:36 +0200)]
Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup

21 months agoAppease clippy again
Michael Goulet [Tue, 6 Sep 2022 17:27:47 +0000 (17:27 +0000)]
Appease clippy again

21 months agoMake clippy happy
Michael Goulet [Wed, 31 Aug 2022 05:29:36 +0000 (05:29 +0000)]
Make clippy happy

21 months agoRemove ReEmpty
Jack Huey [Sun, 26 Jun 2022 19:40:45 +0000 (15:40 -0400)]
Remove ReEmpty

21 months agoAuto merge of #101577 - Dylan-DPC:rollup-l9xw7i7, r=Dylan-DPC
bors [Thu, 8 Sep 2022 15:53:14 +0000 (15:53 +0000)]
Auto merge of #101577 - Dylan-DPC:rollup-l9xw7i7, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #98933 (Opaque types' generic params do not imply anything about their hidden type's lifetimes)
 - #101041 (translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Pt. 2)
 - #101424 (Adjust and slightly generalize operator error suggestion)
 - #101496 (Allow lower_lifetime_binder receive a closure)
 - #101501 (Allow lint passes to be bound by `TyCtxt`)
 - #101515 (Recover from typo where == is used in place of =)
 - #101545 (Remove unnecessary `PartialOrd` and `Ord`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

21 months agoRollup merge of #101501 - Jarcho:tcx_lint_passes, r=davidtwco
Dylan DPC [Thu, 8 Sep 2022 15:18:36 +0000 (20:48 +0530)]
Rollup merge of #101501 - Jarcho:tcx_lint_passes, r=davidtwco

Allow lint passes to be bound by `TyCtxt`

This will allow storing things like `Ty<'tcx>` inside late lint passes. It's already possible to store various id types so they're already implicitly bound to a specific `TyCtxt`.

r? rust-lang/compiler

21 months agoAuto merge of #101467 - nnethercote:shrink-hir-Ty-Pat, r=spastorino
bors [Thu, 8 Sep 2022 13:11:57 +0000 (13:11 +0000)]
Auto merge of #101467 - nnethercote:shrink-hir-Ty-Pat, r=spastorino

Shrink `hir::Ty` and `hir::Pat`

r? `@ghost`

21 months agoRollup merge of #101498 - petrochenkov:visparam, r=cjgillot
Dylan DPC [Thu, 8 Sep 2022 06:25:09 +0000 (11:55 +0530)]
Rollup merge of #101498 - petrochenkov:visparam, r=cjgillot

rustc: Parameterize `ty::Visibility` over used ID

It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.

21 months agoIntroduce `DotDotPos`.
Nicholas Nethercote [Thu, 1 Sep 2022 03:29:57 +0000 (13:29 +1000)]
Introduce `DotDotPos`.

This shrinks `hir::Pat` from 88 to 72 bytes.

21 months agoArena-allocate `hir::Lifetime`.
Nicholas Nethercote [Thu, 1 Sep 2022 02:06:48 +0000 (12:06 +1000)]
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.

21 months agoAuto merge of #101432 - nnethercote:shrink-PredicateS, r=lcnr
bors [Wed, 7 Sep 2022 13:49:58 +0000 (13:49 +0000)]
Auto merge of #101432 - nnethercote:shrink-PredicateS, r=lcnr

Shrink `PredicateS`

r? `@ghost`

21 months agorustc: Parameterize `ty::Visibility` over used ID
Vadim Petrochenkov [Sat, 27 Aug 2022 21:10:06 +0000 (00:10 +0300)]
rustc: Parameterize `ty::Visibility` over used ID

It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.

21 months agoAllow lint passes to be bound by `TyCtxt`
Jason Newcomb [Tue, 6 Sep 2022 18:23:03 +0000 (14:23 -0400)]
Allow lint passes to be bound by `TyCtxt`

21 months agoGeneralize the Assume intrinsic statement to a general Intrinsic statement
Oli Scherer [Tue, 12 Jul 2022 10:05:00 +0000 (10:05 +0000)]
Generalize the Assume intrinsic statement to a general Intrinsic statement

21 months agoLower the assume intrinsic to a MIR statement
Oli Scherer [Thu, 30 Jun 2022 08:16:05 +0000 (08:16 +0000)]
Lower the assume intrinsic to a MIR statement

21 months agoAuto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
bors [Tue, 6 Sep 2022 03:16:29 +0000 (03:16 +0000)]
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.

21 months agoAuto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot
bors [Mon, 5 Sep 2022 16:21:40 +0000 (16:21 +0000)]
Auto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot

Separate the receiver from arguments in HIR

Related to #100232

cc `@cjgillot`

21 months agouse `propagate_through_exprs` instead of `propagate_through_expr`
Takayuki Maeda [Mon, 5 Sep 2022 05:26:00 +0000 (14:26 +0900)]
use `propagate_through_exprs` instead of `propagate_through_expr`

fix `ExprKind` static_assert_size

fix hir-stats

21 months agoAuto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov
bors [Mon, 5 Sep 2022 13:36:54 +0000 (13:36 +0000)]
Auto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov

Simplify `hir::PathSegment`

r? `@petrochenkov`

21 months agorefactor: remove unnecessary variables
Takayuki Maeda [Fri, 2 Sep 2022 13:48:14 +0000 (22:48 +0900)]
refactor: remove unnecessary variables

21 months agoseparate the receiver from arguments in HIR under /clippy
Takayuki Maeda [Thu, 1 Sep 2022 09:43:35 +0000 (18:43 +0900)]
separate the receiver from arguments in HIR under /clippy

21 months agoRollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwco
Dylan DPC [Mon, 5 Sep 2022 08:45:51 +0000 (14:15 +0530)]
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`

21 months agoPack `Term` in the same way as `GenericArg`.
Nicholas Nethercote [Mon, 5 Sep 2022 04:03:53 +0000 (14:03 +1000)]
Pack `Term` in the same way as `GenericArg`.

This shrinks the `PredicateS` type, which is instanted frequently.

21 months agoMake `hir::PathSegment::res` non-optional.
Nicholas Nethercote [Tue, 30 Aug 2022 05:10:28 +0000 (15:10 +1000)]
Make `hir::PathSegment::res` non-optional.

21 months agoclippy: BindingAnnotation change
Cameron Steffen [Tue, 30 Aug 2022 22:36:53 +0000 (17:36 -0500)]
clippy: BindingAnnotation change

21 months agoAuto merge of #101249 - matthiaskrgr:rollup-wahnoz8, r=matthiaskrgr
bors [Wed, 31 Aug 2022 21:45:18 +0000 (21:45 +0000)]
Auto merge of #101249 - matthiaskrgr:rollup-wahnoz8, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #100787 (Pretty printing give proper error message without panic)
 - #100838 (Suggest moving redundant generic args of an assoc fn to its trait)
 - #100844 (migrate rustc_query_system to use SessionDiagnostic)
 - #101140 (Update Clippy)
 - #101161 (Fix uintended diagnostic caused by `drain(..)`)
 - #101165 (Use more `into_iter` rather than `drain(..)`)
 - #101229 (Link “? operator” to relevant chapter in The Book)
 - #101230 (lint: avoid linting diag functions with diag lints)
 - #101236 (Avoid needless buffer zeroing in `std::sys::windows::fs`)
 - #101240 (Fix a typo on `wasm64-unknown-unknown` doc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

21 months agoUse `CountIsStart` in clippy
Jason Newcomb [Wed, 31 Aug 2022 13:33:32 +0000 (09:33 -0400)]
Use `CountIsStart` in clippy

22 months agoMerge commit 'f51aade56f93175dde89177a92e3669ebd8e7592' into clippyup
Jason Newcomb [Wed, 31 Aug 2022 13:24:45 +0000 (09:24 -0400)]
Merge commit 'f51aade56f93175dde89177a92e3669ebd8e7592' into clippyup

22 months agofix a clippy test
Ralf Jung [Wed, 31 Aug 2022 13:24:40 +0000 (15:24 +0200)]
fix a clippy test

22 months agoAuto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung
bors [Tue, 30 Aug 2022 20:39:01 +0000 (20:39 +0000)]
Auto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung

Strengthen invalid_value lint to forbid uninit primitives, adjust docs to say that's UB

For context: https://github.com/rust-lang/rust/issues/66151#issuecomment-1174477404=

This does not make it a FCW, but it does explicitly state in the docs that uninit integers are UB.

This also doesn't affect any runtime behavior, uninit u32's will still successfully be created through mem::uninitialized.

22 months agoFix tests due to stricter invalid_value
5225225 [Mon, 29 Aug 2022 20:28:35 +0000 (21:28 +0100)]
Fix tests due to stricter invalid_value

22 months agoRevert let_chains stabilization
Nilstrieb [Sat, 20 Aug 2022 18:40:08 +0000 (20:40 +0200)]
Revert let_chains stabilization

This reverts commit 326646074940222d602f3683d0559088690830f4.

This is the revert against master, the beta revert was already done in #100538.

22 months agoUse `&'hir Ty` everywhere.
Nicholas Nethercote [Fri, 26 Aug 2022 05:57:44 +0000 (15:57 +1000)]
Use `&'hir Ty` everywhere.

For consistency, and because it makes HIR measurement simpler and more
accurate.

22 months agoUse `&'hir Expr` everywhere.
Nicholas Nethercote [Fri, 26 Aug 2022 05:43:00 +0000 (15:43 +1000)]
Use `&'hir Expr` everywhere.

For consistency, and because it makes HIR measurement simpler and more
accurate.

22 months agoReplace `Body::basic_blocks()` with field access
Tomasz Miąsko [Tue, 5 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Replace `Body::basic_blocks()` with field access

22 months agoRollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov
Yuki Okushi [Wed, 24 Aug 2022 23:50:54 +0000 (08:50 +0900)]
Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov

Stabilize `#![feature(label_break_value)]`

See the stabilization report in https://github.com/rust-lang/rust/issues/48594#issuecomment-1186213313.

22 months agoStabilize `#![feature(label_break_value)]`
Joshua Nelson [Thu, 14 Jul 2022 13:30:38 +0000 (08:30 -0500)]
Stabilize `#![feature(label_break_value)]`

 # Stabilization proposal

The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.

There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630

Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006

Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249

nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs,
and the design space seems rather speculative.

joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804

withoutboats has regrettably left the language team.

joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353

[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+

 ## Report

+ Feature gate:
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
    - https://github.com/rust-lang/rust/blob/6b2d3d5f3cd1e553d87b5496632132565b6779d3/compiler/rustc_parse/src/parser/diagnostics.rs#L2629
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L749
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L1001
    - https://github.com/rust-lang/rust/blob/111df9e6eda1d752233482c1309d00d20a4bbf98/compiler/rustc_passes/src/loops.rs#L254
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L2079
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L1569
+ Tests:
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs

 ## Interactions with other features

Labels follow the hygiene of local variables.

label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
    'foo: {
        Err(())?;
        break 'foo;
    }
};
```

label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
    || break 'a
    //~^ ERROR use of unreachable label `'a`
    //~| ERROR `break` inside of a closure
}
```

label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
    match false 'b: { //~ ERROR block label not supported here
        _ => {}
    }
}

macro_rules! m {
    ($b:block) => {
        'lab: $b; //~ ERROR cannot use a `block` macro fragment here
        unsafe $b; //~ ERROR cannot use a `block` macro fragment here
        |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
    }
}

fn foo() {
    m!({});
}
```

[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html

22 months agoRemove the symbol from `ast::LitKind::Err`.
Nicholas Nethercote [Mon, 22 Aug 2022 03:27:52 +0000 (13:27 +1000)]
Remove the symbol from `ast::LitKind::Err`.

Because it's never used meaningfully.

22 months agoRollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
Matthias Krüger [Wed, 17 Aug 2022 10:32:49 +0000 (12:32 +0200)]
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov

Clean up `LitKind`

r? ``@petrochenkov``

22 months agoRename some things related to literals.
Nicholas Nethercote [Mon, 1 Aug 2022 06:46:08 +0000 (16:46 +1000)]
Rename some things related to literals.

- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is
  `token::Lit`, which is not a token. (This has been confusing me for a
  long time.)
  reasonable because we have an `ast::token::Lit` inside an `ast::Lit`.
- Rename `LitKind::{from,to}_lit_token` as
  `LitKind::{from,to}_token_lit`, to match the above change and
  `token::Lit`.

22 months agoShrink `ast::Attribute`.
Nicholas Nethercote [Thu, 11 Aug 2022 11:06:11 +0000 (21:06 +1000)]
Shrink `ast::Attribute`.

22 months agoAuto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillot
bors [Mon, 15 Aug 2022 05:50:54 +0000 (05:50 +0000)]
Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillot

Visit attributes in more places.

This adds 3 loosely related changes (I can split PRs if desired):

- Attribute checking on pattern struct fields.
- Attribute checking on struct expression fields.
- Lint level visiting on pattern struct fields, struct expression fields, and generic parameters.

There are still some lints which ignore lint levels in various positions. This is a consequence of how the lints themselves are implemented. For example, lint levels on associated consts don't work with `unused_braces`.

22 months agoAdjust cfgs
Mark Rousskov [Tue, 9 Aug 2022 13:56:13 +0000 (09:56 -0400)]
Adjust cfgs

22 months agoUpdate clippy for introduction of Node::ExprField
Eric Huss [Sun, 31 Jul 2022 21:22:27 +0000 (14:22 -0700)]
Update clippy for introduction of Node::ExprField

22 months agoAuto merge of #100419 - flip1995:clippyup, r=Manishearth
bors [Fri, 12 Aug 2022 00:12:51 +0000 (00:12 +0000)]
Auto merge of #100419 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

22 months agoRollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillot
Matthias Krüger [Thu, 11 Aug 2022 20:53:08 +0000 (22:53 +0200)]
Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillot

Simplify visitors

By removing some unused arguments.

r? `@cjgillot`

22 months agoMerge commit '2b2190cb5667cdd276a24ef8b9f3692209c54a89' into clippyup
Philipp Krones [Thu, 11 Aug 2022 17:42:16 +0000 (19:42 +0200)]
Merge commit '2b2190cb5667cdd276a24ef8b9f3692209c54a89' into clippyup

22 months agoSimplify `rustc_ast::visit::Visitor::visit_poly_trait_ref`.
Nicholas Nethercote [Thu, 11 Aug 2022 01:05:26 +0000 (11:05 +1000)]
Simplify `rustc_ast::visit::Visitor::visit_poly_trait_ref`.

It is passed an argument that is never used.

22 months agoDo not consider method call receiver as an argument in AST.
Camille GILLOT [Sun, 7 Aug 2022 13:21:11 +0000 (15:21 +0200)]
Do not consider method call receiver as an argument in AST.

22 months agoAuto merge of #99743 - compiler-errors:fulfillment-context-cleanups, r=jackh726
bors [Sat, 6 Aug 2022 06:48:15 +0000 (06:48 +0000)]
Auto merge of #99743 - compiler-errors:fulfillment-context-cleanups, r=jackh726

Some `FulfillmentContext`-related cleanups

Use `ObligationCtxt` in some places, remove some `FulfillmentContext`s in others...

r? types

22 months agoAdd `traits::fully_solve_obligation` that acts like `traits::fully_normalize`
Michael Goulet [Tue, 2 Aug 2022 06:02:04 +0000 (06:02 +0000)]
Add `traits::fully_solve_obligation` that acts like `traits::fully_normalize`

It spawns up a trait engine, registers the single obligation, then fully
solves it

22 months agoWarn about dead tuple struct fields
Fabian Wolff [Mon, 25 Jul 2022 20:36:03 +0000 (22:36 +0200)]
Warn about dead tuple struct fields

22 months agoRollup merge of #100053 - flip1995:clippy_backport, r=xFrednet
Matthias Krüger [Tue, 2 Aug 2022 15:17:36 +0000 (17:17 +0200)]
Rollup merge of #100053 - flip1995:clippy_backport, r=xFrednet

move [`assertions_on_result_states`] to restriction

"Backports" the first commit of https://github.com/rust-lang/rust-clippy/pull/9273, so that the lint doesn't go into beta as a warn-by-default lint.

The other changes in the linked PR can ride the train as usual.

r? ``@xFrednet`` (only Clippy changes, so we don't need to bother compiler people)

---

For Clippy:

changelog: none

22 months agoRollup merge of #99987 - Alexendoo:parse-format-position-span, r=fee1-dead
Matthias Krüger [Tue, 2 Aug 2022 15:17:30 +0000 (17:17 +0200)]
Rollup merge of #99987 - Alexendoo:parse-format-position-span, r=fee1-dead

Always include a position span in `rustc_parse_format::Argument`

Moves the spans from the `Position` enum to always be included in the `Argument` struct. Doesn't make any changes to use it in rustc, but it will be useful for some upcoming Clippy lints

22 months agomove [`assertions_on_result_states`] to restriction
tabokie [Mon, 1 Aug 2022 05:22:16 +0000 (13:22 +0800)]
move [`assertions_on_result_states`] to restriction

Signed-off-by: tabokie <xy.tao@outlook.com>