]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoFix tools
Deadbeef [Mon, 29 Nov 2021 12:42:16 +0000 (20:42 +0800)]
Fix tools

2 years agoOnly check for errors in predicate when skipping impl assembly
Aaron Hill [Fri, 26 Nov 2021 15:14:16 +0000 (09:14 -0600)]
Only check for errors in predicate when skipping impl assembly

Prior to PR #91205, checking for errors in the overall obligation
would check checking the `ParamEnv`, due to an incorrect
`super_visit_with` impl. With this bug fixed, we will now
bail out of impl candidate assembly if the `ParamEnv` contains
any error types.

In practice, this appears to be overly conservative - when an error
occurs early in compilation, we end up giving up early for some
predicates that we could have successfully evaluated without overflow.
By only checking for errors in the predicate itself, we avoid causing
additional spurious 'type annotations needed' errors after a 'real'
error has already occurred.

With this PR, the diagnostic changes caused by PR #91205 are reverted.

2 years agoAuto merge of #91205 - Aaron1011:visit_param_env, r=lcnr
bors [Fri, 26 Nov 2021 09:55:06 +0000 (09:55 +0000)]
Auto merge of #91205 - Aaron1011:visit_param_env, r=lcnr

Visit `param_env` field in Obligation's `TypeFoldable` impl

This oversight appears to have gone unnoticed for a long time
without causing issues, but it should still be fixed.

2 years agoVisit `param_env` field in Obligation's `TypeFoldable` impl
Aaron Hill [Wed, 24 Nov 2021 23:20:52 +0000 (17:20 -0600)]
Visit `param_env` field in Obligation's `TypeFoldable` impl

This oversight appears to have gone unnoticed for a long time
without causing issues, but it should still be fixed.

2 years agoFix clippy test
Esteban Kuber [Thu, 25 Nov 2021 18:39:32 +0000 (18:39 +0000)]
Fix clippy test

2 years agoclippy: Fix pattern_type_mismatch for loop
Cameron Steffen [Fri, 19 Nov 2021 18:23:52 +0000 (12:23 -0600)]
clippy: Fix pattern_type_mismatch for loop

2 years agoFix Clippy with changed for loop desugar
Cameron Steffen [Wed, 27 Oct 2021 14:48:06 +0000 (09:48 -0500)]
Fix Clippy with changed for loop desugar

2 years agorustc: Remove `#[rustc_synthetic]`
Vadim Petrochenkov [Thu, 18 Nov 2021 05:25:27 +0000 (13:25 +0800)]
rustc: Remove `#[rustc_synthetic]`

This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.

2 years agoRollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakis
Matthias Krüger [Tue, 9 Nov 2021 18:00:40 +0000 (19:00 +0100)]
Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakis

Type inference for inline consts

Fixes #78132
Fixes #78174
Fixes #81857
Fixes #89964

Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure.

Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts.

The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure.

With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME.

Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck).
cc `````@spastorino````` `````@lcnr`````
r? `````@nikomatsakis`````

`````@rustbot````` label A-inference F-inline_const T-compiler

2 years agoAuto merge of #90700 - fee1-dead:select-returns-vec, r=davidtwco
bors [Tue, 9 Nov 2021 11:16:38 +0000 (11:16 +0000)]
Auto merge of #90700 - fee1-dead:select-returns-vec, r=davidtwco

Make `select_*` methods return `Vec` for `TraitEngine`

This reduces some complexity as an empty vec means no errors and non-empty vec means errors occurred.

2 years agoAuto merge of #87337 - jyn514:lint-error, r=oli-obk,flip1995
bors [Tue, 9 Nov 2021 08:21:10 +0000 (08:21 +0000)]
Auto merge of #87337 - jyn514:lint-error, r=oli-obk,flip1995

Don't abort compilation after giving a lint error

The only reason to use `abort_if_errors` is when the program is so broken that either:
1. later passes get confused and ICE
2. any diagnostics from later passes would be noise

This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints.
So it can continue to lint and compile even if there are lint errors.

Closes https://github.com/rust-lang/rust/issues/82761. This is a WIP because I have a feeling it will exit with 0 even if there were lint errors; I don't have a computer that can build rustc locally at the moment.

2 years agoAuto merge of #90485 - camsteffen:fmt-args-less-bind, r=m-ou-se
bors [Tue, 9 Nov 2021 05:33:16 +0000 (05:33 +0000)]
Auto merge of #90485 - camsteffen:fmt-args-less-bind, r=m-ou-se

Don't destructure args tuple in format_args!

This allows Clippy to parse the HIR more simply since `arg0` is changed to `_args.0`. (cc rust-lang/rust-clippy#7843). From rustc's perspective, I think this is something between a lateral move and a tiny improvement since there are fewer bindings.

r? `@m-ou-se`

2 years agoMake select_* methods return Vec for TraitEngine
Deadbeef [Mon, 8 Nov 2021 15:35:23 +0000 (23:35 +0800)]
Make select_* methods return Vec for TraitEngine

2 years agoDon't abort compilation after giving a lint error
Joshua Nelson [Wed, 21 Jul 2021 03:23:22 +0000 (23:23 -0400)]
Don't abort compilation after giving a lint error

The only reason to use `abort_if_errors` is when the program is so broken that either:
1. later passes get confused and ICE
2. any diagnostics from later passes would be noise

This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints.
So it can continue to lint and compile even if there are lint errors.

2 years agoast: Fix naming conventions in AST structures
Vadim Petrochenkov [Sun, 7 Nov 2021 08:43:49 +0000 (16:43 +0800)]
ast: Fix naming conventions in AST structures

TraitKind -> Trait
TyAliasKind -> TyAlias
ImplKind -> Impl
FnKind -> Fn

All `*Kind`s in AST are supposed to be enums.

Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order.

Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.

2 years agoGive inline const separate DefKind
Gary Guo [Sat, 2 Oct 2021 11:59:26 +0000 (12:59 +0100)]
Give inline const separate DefKind

2 years agoFix Clippy with changed format_args!
Cameron Steffen [Sat, 6 Nov 2021 21:03:32 +0000 (16:03 -0500)]
Fix Clippy with changed format_args!

2 years agoMerge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup
flip1995 [Thu, 4 Nov 2021 12:52:36 +0000 (12:52 +0000)]
Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup

2 years agoRollup merge of #90500 - xFrednet:00000-update-clippy-deps, r=flip1995
Matthias Krüger [Tue, 2 Nov 2021 22:48:49 +0000 (23:48 +0100)]
Rollup merge of #90500 - xFrednet:00000-update-clippy-deps, r=flip1995

Update Clippy dependencies

Clippy has two outdated dependencies, where one indirect dependency has been flagged by rustsec for dropping a lifetime. See [RUSTSEC-2020-0146](https://rustsec.org/advisories/RUSTSEC-2020-0146). This PR updates these dependencies.

With previous dependency updates, it was tried to prevent duplicates in the `Cargo.lock` file of rust-lang/rust. I've tried to keep this in mind with this update.

* Dependency `semver`
    * Used in `src/tools/cargo/Cargo.toml` as version `1.0.3`
    * Used in `src/tools/rust-analyzer/crates/project_model/Cargo.toml` as version `1`
    * Updated in Clippy from `0.11` to `1.0` (Clippy usually defines the major and minor patch version). The `Cargo.lock` file lists `1.0.3` which is one patch version behind the most recent one but prevents a duplicate with cargo's pinned version.
* Dependency `cargo_metadata`
    * Used in several tools as `0.14`
    * Used in `src/tools/tidy` and `src/tools/rls` as `0.12`
    * Updated in Clippy from `0.12` to `0.14`

All updates to the `Cargo.lock` have been done automatically by `x.py`.

There are still some tools with these outdated dependencies. Clippy didn't require any changes, and it would be likely that the others could also be updated without any problem. Let me know if I should try to update them as well :upside_down_face:.

Keep up the good work, whoever is reading this :crab:

---

For Clippy:

changelog: none

2 years agoUpdate clippy dependencies
xFrednet [Tue, 2 Nov 2021 13:19:31 +0000 (14:19 +0100)]
Update clippy dependencies

* semver = "0.11" -> "1.0"
* cargo_metadata = "0.12" -> "0.14"

2 years agoRollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=joshtriplett
Matthias Krüger [Sun, 31 Oct 2021 12:20:05 +0000 (13:20 +0100)]
Rollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=joshtriplett

Add #[must_use] to len and is_empty

Parent issue: #89692

r? `@joshtriplett`

2 years agoAdd #[must_use] to len and is_empty
John Kugelman [Mon, 11 Oct 2021 20:15:50 +0000 (16:15 -0400)]
Add #[must_use] to len and is_empty

2 years agoAlways sort suggestions before emitting them
Esteban Kuber [Fri, 1 Oct 2021 18:09:31 +0000 (18:09 +0000)]
Always sort suggestions before emitting them

2 years agoRollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco
Yuki Okushi [Fri, 22 Oct 2021 10:42:45 +0000 (19:42 +0900)]
Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco

Don't mark for loop iter expression as desugared

We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.

2 years agoMerge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyup
flip1995 [Thu, 21 Oct 2021 11:11:36 +0000 (13:11 +0200)]
Merge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyup

2 years agoRollup merge of #88860 - nbdd0121:panic, r=m-ou-se
Yuki Okushi [Tue, 19 Oct 2021 19:35:14 +0000 (04:35 +0900)]
Rollup merge of #88860 - nbdd0121:panic, r=m-ou-se

Deduplicate panic_fmt

std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.

2 years agoRemove begin_panic_fmt from clippy
Gary Guo [Tue, 19 Oct 2021 12:58:58 +0000 (13:58 +0100)]
Remove begin_panic_fmt from clippy

2 years agoRollup merge of #89990 - petrochenkov:idempty, r=wesleywiser
Matthias Krüger [Mon, 18 Oct 2021 06:13:30 +0000 (08:13 +0200)]
Rollup merge of #89990 - petrochenkov:idempty, r=wesleywiser

rustc_span: `Ident::invalid` -> `Ident::empty`

The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s as well.

2 years agorustc_span: `Ident::invalid` -> `Ident::empty`
Vadim Petrochenkov [Sun, 17 Oct 2021 20:20:30 +0000 (23:20 +0300)]
rustc_span: `Ident::invalid` -> `Ident::empty`

The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.

2 years agoRollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisa
Matthias Krüger [Sun, 17 Oct 2021 16:18:59 +0000 (18:18 +0200)]
Rollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisa

Some "parenthesis" and "parentheses" fixes

"Parenthesis" is the singular (e.g. one `(` or one `)`) and "parentheses" is the plural (multiple `(` or `)`s) and this is not hard to mix up so here are some fixes for that.

Inspired by #89958

2 years agoSome "parenthesis" and "parentheses" fixes
r00ster91 [Sun, 17 Oct 2021 10:04:01 +0000 (12:04 +0200)]
Some "parenthesis" and "parentheses" fixes

2 years agoFix clippy with for loop span change
Cameron Steffen [Thu, 14 Oct 2021 21:41:46 +0000 (16:41 -0500)]
Fix clippy with for loop span change

2 years agoFix clippy with changed macro statement spans
Cameron Steffen [Thu, 14 Oct 2021 18:28:30 +0000 (13:28 -0500)]
Fix clippy with changed macro statement spans

2 years agoUpdate clippy ui output
Oli Scherer [Wed, 13 Oct 2021 11:06:14 +0000 (11:06 +0000)]
Update clippy ui output

2 years agoAuto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett
bors [Tue, 12 Oct 2021 09:43:37 +0000 (09:43 +0000)]
Auto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett

Add #[must_use] to From::from and Into::into

Risk of churn: **High**
Magic 8-Ball says: **Outlook not so good**

I figured I'd put this out there. If we don't do it now maybe we save it for a rainy day.

Parent issue: #89692

r? `@joshtriplett`

2 years agoAdd #[must_use] to From::from and Into::into
John Kugelman [Mon, 11 Oct 2021 14:13:50 +0000 (10:13 -0400)]
Add #[must_use] to From::from and Into::into

2 years agoDeprecate mem_discriminant_non_enum
flip1995 [Mon, 11 Oct 2021 08:10:16 +0000 (10:10 +0200)]
Deprecate mem_discriminant_non_enum

This lint has been uplifted and is now included in
enum_intrinsics_non_enums.

2 years agoMerge commit 'b7f3f7f6082679da2da9a0b3faf1b5adef3afd3b' into clippyup
flip1995 [Thu, 7 Oct 2021 09:21:30 +0000 (11:21 +0200)]
Merge commit 'b7f3f7f6082679da2da9a0b3faf1b5adef3afd3b' into clippyup

2 years agoAuto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth
bors [Sun, 3 Oct 2021 21:44:10 +0000 (21:44 +0000)]
Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth

Add expansion to while desugar spans

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`

2 years agoMake diangostic item names consistent
Cameron Steffen [Sat, 2 Oct 2021 23:51:01 +0000 (18:51 -0500)]
Make diangostic item names consistent

2 years agoAdd desugaring mark to while loop
Cameron Steffen [Thu, 19 Aug 2021 21:57:15 +0000 (16:57 -0500)]
Add desugaring mark to while loop

2 years agoAuto merge of #89449 - Manishearth:rollup-3alb61f, r=Manishearth
bors [Fri, 1 Oct 2021 22:47:22 +0000 (22:47 +0000)]
Auto merge of #89449 - Manishearth:rollup-3alb61f, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #85223 (rustdoc: Clarified the attribute which prompts the warning)
 - #88847 (platform-support.md: correct ARMv7+MUSL platform triple notes)
 - #88963 (Coerce const FnDefs to implement const Fn traits )
 - #89376 (Fix use after drop in self-profile with llvm events)
 - #89422 (Replace whitespaces in doctests' name with dashes)
 - #89440 (Clarify a sentence in the documentation of Vec (#84488))
 - #89441 (Normalize after substituting via `field.ty()`)

Failed merges:

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

2 years agoRollup merge of #88963 - fee1-dead:const-iterator, r=oli-obk
Manish Goregaokar [Fri, 1 Oct 2021 21:46:48 +0000 (14:46 -0700)]
Rollup merge of #88963 - fee1-dead:const-iterator, r=oli-obk

Coerce const FnDefs to implement const Fn traits

You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`.

r? ``@oli-obk``

``@rustbot`` label T-compiler F-const_trait_impl

2 years agoAuto merge of #88880 - cjgillot:no-krate, r=oli-obk
bors [Fri, 1 Oct 2021 20:06:34 +0000 (20:06 +0000)]
Auto merge of #88880 - cjgillot:no-krate, r=oli-obk

Rework HIR API to make invocations of the hir_crate query harder.

`hir_crate` forces the recomputation of queries that depend on it.

This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.

2 years agoRollup merge of #88782 - asquared31415:issue-79559, r=cjgillot
Manish Goregaokar [Fri, 1 Oct 2021 01:05:20 +0000 (18:05 -0700)]
Rollup merge of #88782 - asquared31415:issue-79559, r=cjgillot

Fix ICE when `start` lang item has wrong generics

In my previous pr #87875 I missed the requirements on the `start` lang item due to its relative difficulty to test and opting for more conservative estimates.  This fixes that by updating the requirement to be exactly one generic type.

The `start` lang item should have exactly one generic type for the return type of the `main` fn ptr passed to it.  I believe having zero would previously *sometimes* compile (often with the use of `fn() -> ()` as the fn ptr but it was likely UB to call if the return type of `main` was not `()` as far as I know) however it also sometimes would not for various errors including ICEs and LLVM errors depending on exact situations.  Having more than 1 generic has always failed with an ICE because only the one generic type is expected and provided.

Fixes #79559, fixes #73584, fixes #83117 (all duplicates)
Relevant to #9307

r? ````@cjgillot````

2 years agoDo not pass hir::Crate to lints.
Camille GILLOT [Sun, 12 Sep 2021 09:58:27 +0000 (11:58 +0200)]
Do not pass hir::Crate to lints.

2 years agoAvoid more invocations of hir_crate query.
Camille GILLOT [Sat, 11 Sep 2021 23:11:22 +0000 (01:11 +0200)]
Avoid more invocations of hir_crate query.

2 years agoMerge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup
flip1995 [Tue, 28 Sep 2021 17:03:12 +0000 (18:03 +0100)]
Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup

2 years agoRollup merge of #89216 - r00ster91:bigo, r=dtolnay
Manish Goregaokar [Sun, 26 Sep 2021 01:22:20 +0000 (18:22 -0700)]
Rollup merge of #89216 - r00ster91:bigo, r=dtolnay

Consistent big O notation

This makes the big O time complexity notation in places with markdown support more consistent.
Inspired by #89210

2 years agoAuto merge of #89030 - nbdd0121:box2, r=jonas-schievink
bors [Sat, 25 Sep 2021 11:01:13 +0000 (11:01 +0000)]
Auto merge of #89030 - nbdd0121:box2, r=jonas-schievink

Introduce `Rvalue::ShallowInitBox`

Polished version of #88700.

Implements MCP rust-lang/compiler-team#460, and should allow #43596 to go forward.

In short, creating an empty box is split from a nullary-op `NullOp::Box` into two steps, first a call to `exchange_malloc`, then a `Rvalue::ShallowInitBox` which transmutes `*mut u8` to a shallow-initialized `Box<T>`. This allows the `exchange_malloc` call to unwind. Details can be found in the MCP.

`NullOp::Box` is not yet removed, purely to make reverting easier in case anything goes wrong as the result of this PR. If revert is needed a reversion of "Use Rvalue::ShallowInitBox for box expression" commit followed by a test bless should be sufficient.

Experiments in #88700 showed a very slight compile-time perf regression due to (supposedly) slightly more time spent in LLVM. We could omit unwind edge generation (in non-`oom=panic` case) in box expression MIR construction to restore perf; but I don't think it's necessary since runtime perf isn't affected and perf difference is rather small.

2 years agoIntroduce `Rvalue::ShallowInitBox`
Gary Guo [Mon, 6 Sep 2021 17:33:23 +0000 (18:33 +0100)]
Introduce `Rvalue::ShallowInitBox`

2 years agoRollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakis
Jubilee [Fri, 24 Sep 2021 18:40:11 +0000 (11:40 -0700)]
Rollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakis

Be explicit about using Binder::dummy

This is somewhat of a late followup to the binder refactor PR. It removes `ToPredicate` and `ToPolyTraitImpls` that hide the use of `Binder::dummy`. While this does make code a bit more verbose, it allows us be more careful about where we create binders.

Another alternative here might be to add a new trait `ToBinder` or something with a `dummy()` fn. Which could still allow grepping but allows doing something like `trait_ref.dummy()` (but I also wonder if longer-term, it would be better to be even more explicit with a `bind_with_vars(ty::List::empty())` *but* that's not clear yet.

r? ``@nikomatsakis``

2 years agoconsistent big O notation
r00ster91 [Fri, 24 Sep 2021 10:44:28 +0000 (12:44 +0200)]
consistent big O notation

2 years agoAuto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum
bors [Thu, 23 Sep 2021 02:10:26 +0000 (02:10 +0000)]
Auto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum

Use ZST for fmt unsafety

as suggested here - https://github.com/rust-lang/rust/pull/83302#issuecomment-923529151.

2 years agoAuto merge of #89158 - the8472:rollup-3e4ijth, r=the8472
bors [Tue, 21 Sep 2021 22:07:32 +0000 (22:07 +0000)]
Auto merge of #89158 - the8472:rollup-3e4ijth, r=the8472

Rollup of 12 pull requests

Successful merges:

 - #88795 (Print a note if a character literal contains a variation selector)
 - #89015 (core::ascii::escape_default: reduce struct size)
 - #89078 (Cleanup: Remove needless reference in ParentHirIterator)
 - #89086 (Stabilize `Iterator::map_while`)
 - #89096 ([bootstrap] Improve the error message when `ninja` is not found to link to installation instructions)
 - #89113 (dont `.ensure()` the `thir_abstract_const` query call in `mir_build`)
 - #89114 (Fixes a technicality regarding the size of C's `char` type)
 - #89115 (:arrow_up: rust-analyzer)
 - #89126 (Fix ICE when `indirect_structural_match` is allowed)
 - #89141 (Impl `Error` for `FromSecsError` without foreign type)
 - #89142 (Fix match for placeholder region)
 - #89147 (add case for checking const refs in check_const_value_eq)

Failed merges:

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

2 years agoRollup merge of #89078 - camsteffen:map-ref, r=cjgillot
the8472 [Tue, 21 Sep 2021 20:54:00 +0000 (22:54 +0200)]
Rollup merge of #89078 - camsteffen:map-ref, r=cjgillot

Cleanup: Remove needless reference in ParentHirIterator

It forces an intermediate binding of `Map` which is a Copy type.

2 years agoAuto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank
bors [Tue, 21 Sep 2021 19:25:49 +0000 (19:25 +0000)]
Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank

Migrate in-tree crates to 2021

This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074.

It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there.

I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first.

Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately.

It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c877110748296760aefddc21a0ea1d316 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.

2 years agoUse ZST for fmt unsafety
Cameron Steffen [Tue, 21 Sep 2021 05:56:45 +0000 (00:56 -0500)]
Use ZST for fmt unsafety

This allows the format_args! macro to keep the pre-expansion code out of
the unsafe block without doing gymnastics with nested `match`
expressions. This reduces codegen.

2 years agoRemove Drop-caused migration-added captures
Mark Rousskov [Sun, 19 Sep 2021 17:46:05 +0000 (13:46 -0400)]
Remove Drop-caused migration-added captures

All of these were added due to insignificant Drop types being present.

2 years agoEnable 2021 compatibility lints for all in-tree code
Mark Rousskov [Sat, 18 Sep 2021 21:37:24 +0000 (17:37 -0400)]
Enable 2021 compatibility lints for all in-tree code

This just applies the suggested fixes from the compatibility warnings,
leaving any that are in practice spurious in. This is primarily intended to
provide a starting point to identify possible fixes to the migrations (e.g., by
avoiding spurious warnings).

A secondary commit cleans these up where they are false positives (as is true in
many of the cases).

2 years agoDo not store visibility in *ItemRef.
Camille GILLOT [Thu, 15 Jul 2021 20:19:39 +0000 (22:19 +0200)]
Do not store visibility in *ItemRef.

2 years agoRemove needless hir Map ref
Cameron Steffen [Sat, 18 Sep 2021 20:48:07 +0000 (15:48 -0500)]
Remove needless hir Map ref

2 years agoFix clippy
jackh726 [Thu, 16 Sep 2021 04:12:56 +0000 (00:12 -0400)]
Fix clippy

2 years agoMove is_const_fn to under TyCtxt
Deadbeef [Wed, 15 Sep 2021 10:03:03 +0000 (10:03 +0000)]
Move is_const_fn to under TyCtxt

2 years agoupdate test
asquared31415 [Fri, 10 Sep 2021 13:33:06 +0000 (09:33 -0400)]
update test

2 years agoUpdate permissions path for clippy lint
Guillaume Gomez [Mon, 13 Sep 2021 19:27:53 +0000 (21:27 +0200)]
Update permissions path for clippy lint

2 years agoAuto merge of #88517 - smoelius:without-patch-versions, r=flip1995
bors [Mon, 13 Sep 2021 02:45:18 +0000 (02:45 +0000)]
Auto merge of #88517 - smoelius:without-patch-versions, r=flip1995

Update Clippy dependencies without patch versions

Trial run for https://github.com/rust-lang/rust-clippy/pull/7606

2 years agoAuto merge of #88839 - nbdd0121:alignof, r=nagisa
bors [Sun, 12 Sep 2021 23:49:24 +0000 (23:49 +0000)]
Auto merge of #88839 - nbdd0121:alignof, r=nagisa

Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.

2 years agoIntroduce NullOp::AlignOf
Gary Guo [Tue, 7 Sep 2021 15:06:07 +0000 (16:06 +0100)]
Introduce NullOp::AlignOf

2 years agoRollup merge of #88677 - petrochenkov:exportid, r=davidtwco
Manish Goregaokar [Sun, 12 Sep 2021 10:44:53 +0000 (03:44 -0700)]
Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco

rustc: Remove local variable IDs from `Export`s

Local variables can never be exported.

2 years agoAuto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
bors [Sat, 11 Sep 2021 23:35:28 +0000 (23:35 +0000)]
Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov

Encode spans relative to the enclosing item

The aim of this PR is to avoid recomputing queries when code is moved without modification.

MCP at https://github.com/rust-lang/compiler-team/issues/443

This is achieved by :
1. storing the HIR owner LocalDefId information inside the span;
2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache;
3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation.

Since all client code uses `Span`, step 3 ensures that all manipulations
of span byte positions actually create the dependency edge between
the caller and the `source_span(LocalDefId)`.
This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
- modify the distance to the parent's beginning, so change the relative span's hash;
- dirty `source_span`, and trigger the incremental recomputation of all code that
  depends on the span's absolute byte position.

With this scheme, I believe the dependency tracking to be accurate.

For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.

2 years agoRebase fallout.
Camille GILLOT [Fri, 10 Sep 2021 17:57:06 +0000 (19:57 +0200)]
Rebase fallout.

2 years agoAuto merge of #88214 - notriddle:notriddle/for-loop-span-drop-temps-mut, r=nagisa
bors [Sat, 11 Sep 2021 07:11:01 +0000 (07:11 +0000)]
Auto merge of #88214 - notriddle:notriddle/for-loop-span-drop-temps-mut, r=nagisa

rustc: use more correct span data in for loop desugaring

Fixes #82462

Before:

      help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
         |
      LL |     for x in DroppingSlice(&*v).iter(); {
         |                                       +

After:

      help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
         |
      LL |     };
         |      +

This seems like a reasonable fix: since the desugared "expr_drop_temps_mut" contains the entire desugared loop construct, its span should contain the entire loop construct as well.

2 years agorustc: Remove local variable IDs from `Export`s
Vadim Petrochenkov [Sun, 5 Sep 2021 20:37:15 +0000 (23:37 +0300)]
rustc: Remove local variable IDs from `Export`s

Local variables can never be exported.

2 years agoKeep a parent LocalDefId in SpanData.
Camille GILLOT [Sun, 18 Apr 2021 12:27:04 +0000 (14:27 +0200)]
Keep a parent LocalDefId in SpanData.

2 years agoIgnore automatically derived impls of `Clone` and `Debug` in dead code analysis
Fabian Wolff [Fri, 21 May 2021 17:35:49 +0000 (19:35 +0200)]
Ignore automatically derived impls of `Clone` and `Debug` in dead code analysis

2 years agoUpdate dependencies
Samuel E. Moelius III [Thu, 9 Sep 2021 09:19:03 +0000 (05:19 -0400)]
Update dependencies

2 years agoPrep for upgrade to cargo_metadata 0.14.0
Samuel E. Moelius III [Wed, 1 Sep 2021 22:31:42 +0000 (18:31 -0400)]
Prep for upgrade to cargo_metadata 0.14.0

2 years agoAuto merge of #88615 - flip1995:clippyup, r=Manishearth
bors [Wed, 8 Sep 2021 23:52:31 +0000 (23:52 +0000)]
Auto merge of #88615 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoMerge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup
flip1995 [Wed, 8 Sep 2021 14:31:47 +0000 (16:31 +0200)]
Merge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup

2 years agoRename rustc_mir to rustc_const_eval.
Camille GILLOT [Tue, 5 Jan 2021 19:08:11 +0000 (20:08 +0100)]
Rename rustc_mir to rustc_const_eval.

2 years agoMove the dataflow framework to its own crate.
Camille GILLOT [Tue, 5 Jan 2021 18:53:07 +0000 (19:53 +0100)]
Move the dataflow framework to its own crate.

2 years agofix(clippy): update loop lints to use arg.span
Michael Howell [Tue, 7 Sep 2021 06:30:04 +0000 (23:30 -0700)]
fix(clippy): update loop lints to use arg.span

Adapts clippy for fe1a7f71fbf3cf845a09a9b333a6adcf7e839607

2 years agoAuto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
bors [Mon, 6 Sep 2021 00:14:41 +0000 (00:14 +0000)]
Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank

Fix #88256 remove duplicated diagnostics

Fix #88256

2 years agoAuto merge of #88499 - eddyb:layout-off, r=nagisa
bors [Sun, 5 Sep 2021 16:14:41 +0000 (16:14 +0000)]
Auto merge of #88499 - eddyb:layout-off, r=nagisa

Provide `layout_of` automatically (given tcx + param_env + error handling).

After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit.

This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context.

After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type:
* `TyCtxt`, via `HasTyCtxt`
* `ParamEnv`, via `HasParamEnv`
* a way to transform `LayoutError`s into the desired error type
  * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen
  * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`)

When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform.

(**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it)

Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts.

r? `@nagisa` cc `@oli-obk` `@bjorn3`

2 years agoFix #88256, remove duplicated diagnostic
yukang [Sat, 4 Sep 2021 11:26:25 +0000 (19:26 +0800)]
Fix #88256, remove duplicated diagnostic

2 years agoAuto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank
bors [Fri, 3 Sep 2021 00:23:10 +0000 (00:23 +0000)]
Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank

Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix.

This PR fixes a regression (#87745) with `--remap-path-prefix` where the flag stopped causing diagnostic messages to be remapped as well. The regression was introduced in https://github.com/rust-lang/rust/pull/83813 where we erroneously assumed that remapping of diagnostic messages was not desired anymore (because #70642 partially undid that functionality with nobody objecting).

The issue is fixed by making `--remap-path-prefix` remap diagnostic messages again, including for paths that have been remapped in upstream crates (e.g. the standard library). This means that "sysroot-localization" (implemented in #70642) is also disabled if `rustc` is invoked with `--remap-path-prefix`. The assumption is that once someone starts explicitly remapping paths they also don't want paths to their local Rust installation in their build output.

In the future we might want to give more fine-grained control over this behavior via compiler flags (see https://github.com/rust-lang/rfcs/pull/3127 for a related RFC). For now this PR is intended as a regression fix.

This PR is an alternative to https://github.com/rust-lang/rust/pull/88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642.

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

cc `@cbeuw`
r? `@ghost`

2 years agorustc_target: move `LayoutOf` to `ty::layout`.
Eduard-Mihai Burtescu [Mon, 30 Aug 2021 14:38:27 +0000 (17:38 +0300)]
rustc_target: move `LayoutOf` to `ty::layout`.

2 years agoFix clippy for let-else
Cameron Steffen [Sun, 25 Jul 2021 23:27:44 +0000 (18:27 -0500)]
Fix clippy for let-else

2 years ago`feature(const_generics)` -> `feature(const_param_types)`
lcnr [Fri, 27 Aug 2021 16:04:57 +0000 (18:04 +0200)]
`feature(const_generics)` -> `feature(const_param_types)`

2 years agorename const_evaluatable_checked to generic_const_exprs
Ellen [Wed, 25 Aug 2021 09:21:39 +0000 (10:21 +0100)]
rename const_evaluatable_checked to generic_const_exprs

:sparkles:

2 years agoTeach tools that macros are now HIR items
inquisitivecrystal [Thu, 5 Aug 2021 23:58:46 +0000 (16:58 -0700)]
Teach tools that macros are now HIR items

2 years agoTreat macros as HIR items
inquisitivecrystal [Sat, 31 Jul 2021 06:50:57 +0000 (23:50 -0700)]
Treat macros as HIR items

2 years agoPath remapping: Make behavior of diagnostics output dependent on presence of --remap...
Michael Woerister [Thu, 26 Aug 2021 10:46:01 +0000 (12:46 +0200)]
Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix.

2 years agoupdate `TypeFlags` to deal with missing ct substs
lcnr [Sat, 17 Jul 2021 16:48:07 +0000 (18:48 +0200)]
update `TypeFlags` to deal with missing ct substs

2 years agoadd `tcx` to `fn walk`
lcnr [Sat, 17 Jul 2021 14:43:23 +0000 (16:43 +0200)]
add `tcx` to `fn walk`

2 years agomake unevaluated const substs optional
lcnr [Mon, 15 Mar 2021 23:05:45 +0000 (00:05 +0100)]
make unevaluated const substs optional

2 years agorequire a `tcx` for `TypeVisitor`
lcnr [Sat, 13 Mar 2021 15:05:15 +0000 (16:05 +0100)]
require a `tcx` for `TypeVisitor`

2 years agoAuto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay
bors [Mon, 23 Aug 2021 22:55:19 +0000 (22:55 +0000)]
Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay

Get piece unchecked in `write`

We already use specialized `zip`, but it seems like we can do a little better by not checking `pieces` length at all.

`Arguments` constructors are now unsafe. So the `format_args!` expansion now includes an `unsafe` block.

<details>
<summary>Local Bench Diff</summary>

```text
 name                        before ns/iter  after ns/iter  diff ns/iter   diff %  speedup
 fmt::write_str_macro1       22,967          19,718               -3,249  -14.15%   x 1.16
 fmt::write_str_macro2       35,527          32,654               -2,873   -8.09%   x 1.09
 fmt::write_str_macro_debug  571,953         575,973               4,020    0.70%   x 0.99
 fmt::write_str_ref          9,579           9,459                  -120   -1.25%   x 1.01
 fmt::write_str_value        9,573           9,572                    -1   -0.01%   x 1.00
 fmt::write_u128_max         176             173                      -3   -1.70%   x 1.02
 fmt::write_u128_min         138             134                      -4   -2.90%   x 1.03
 fmt::write_u64_max          139             136                      -3   -2.16%   x 1.02
 fmt::write_u64_min          129             135                       6    4.65%   x 0.96
 fmt::write_vec_macro1       24,401          22,273               -2,128   -8.72%   x 1.10
 fmt::write_vec_macro2       37,096          35,602               -1,494   -4.03%   x 1.04
 fmt::write_vec_macro_debug  588,291         589,575               1,284    0.22%   x 1.00
 fmt::write_vec_ref          9,568           9,732                   164    1.71%   x 0.98
 fmt::write_vec_value        9,516           9,625                   109    1.15%   x 0.99
```
</details>

2 years agoRollup merge of #88230 - steffahn:a_an, r=oli-obk
Mara Bos [Mon, 23 Aug 2021 18:45:49 +0000 (20:45 +0200)]
Rollup merge of #88230 - steffahn:a_an, r=oli-obk

Fix typos “a”→“an”

Fix typos in comments; found using a regex to find some easy instance of incorrect usage of a vs. an.

While automation was used to find these, every change was checked manually.

Changes in submodules get separate PRs:
* https://github.com/rust-lang/stdarch/pull/1201
* https://github.com/rust-lang/cargo/pull/9821
* https://github.com/rust-lang/miri/pull/1874
* https://github.com/rust-lang/rls/pull/1746
* https://github.com/rust-analyzer/rust-analyzer/pull/9984
  _folks @ rust-analyzer are fast at merging…_
  * https://github.com/rust-analyzer/rust-analyzer/pull/9985
  * https://github.com/rust-analyzer/rust-analyzer/pull/9987
  * https://github.com/rust-analyzer/rust-analyzer/pull/9989

_For `clippy`, I don’t know if the changes should better better be moved to a PR to the original repo._

<hr>

This has some overlap with #88226, but neither is a strict superset of the other.

If you want multiple commits, I can split it up; in that case, make sure to suggest a criterion for splitting.