]> git.lizzy.rs Git - rust.git/log
rust.git
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.

2 years agoRollup merge of #88211 - petrochenkov:withhilo, r=jyn514
Guillaume Gomez [Sun, 22 Aug 2021 18:52:54 +0000 (20:52 +0200)]
Rollup merge of #88211 - petrochenkov:withhilo, r=jyn514

cleanup: `Span::new` -> `Span::with_lo`

Extracted from https://github.com/rust-lang/rust/pull/84373 as suggested in https://github.com/rust-lang/rust/pull/84373#issuecomment-857773867.
It turned out less useful then I expected, but anyway.
r? `@cjgillot`
`@bors` rollup

2 years agoFix typos “an”→“a” and a few different ones that appeared in the same search
Frank Steffahn [Sun, 22 Aug 2021 16:15:49 +0000 (18:15 +0200)]
Fix typos “an”→“a” and a few different ones that appeared in the same search

2 years agoFix more “a”/“an” typos
Frank Steffahn [Sun, 22 Aug 2021 15:27:18 +0000 (17:27 +0200)]
Fix more “a”/“an” typos

2 years agoFix typos “a”→“an”
Frank Steffahn [Sun, 22 Aug 2021 12:46:15 +0000 (14:46 +0200)]
Fix typos “a”→“an”

2 years agoAuto merge of #88163 - camsteffen:collapsible-match-fix, r=Manishearth
bors [Sun, 22 Aug 2021 13:26:32 +0000 (13:26 +0000)]
Auto merge of #88163 - camsteffen:collapsible-match-fix, r=Manishearth

Fix clippy::collapsible_match with let expressions

This fixes rust-lang/rust-clippy#7575 which is a regression from #80357. I am fixing the bug here instead of in the clippy repo (if that's okay) because a) the regression has not been synced yet and b) I would like to land the fix on nightly asap.

The fix is basically to re-generalize `match` and `if let` for the lint implementation (they were split because `if let` no longer desugars to `match` in the HIR).

Also fixes rust-lang/rust-clippy#7586 and fixes rust-lang/rust-clippy#7591
cc `@rust-lang/clippy`
`@xFrednet` do you want to review this?

2 years agocleanup: `Span::new` -> `Span::with_lo`
Vadim Petrochenkov [Sat, 21 Aug 2021 15:07:21 +0000 (18:07 +0300)]
cleanup: `Span::new` -> `Span::with_lo`

2 years agointroduce a Coerce predicate
Niko Matsakis [Sat, 21 Nov 2020 12:06:16 +0000 (07:06 -0500)]
introduce a Coerce predicate

2 years agoFix clippy let expressions fallout
Cameron Steffen [Thu, 19 Aug 2021 18:31:25 +0000 (13:31 -0500)]
Fix clippy let expressions fallout

2 years agoremove box_syntax uses from cranelift and tools
Marcel Hellwig [Fri, 6 Aug 2021 15:14:27 +0000 (17:14 +0200)]
remove box_syntax uses from cranelift and tools

2 years agoclippy: Fix format_args expansion parsing
Cameron Steffen [Fri, 16 Jul 2021 13:54:08 +0000 (08:54 -0500)]
clippy: Fix format_args expansion parsing

2 years agoAuto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser
bors [Mon, 16 Aug 2021 06:36:13 +0000 (06:36 +0000)]
Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser

Uplift the invalid_atomic_ordering lint from clippy to rustc

This is mostly just a rebase of https://github.com/rust-lang/rust/pull/79654; I've copy/pasted the text from that PR below.

r? `@lcnr` since you reviewed the last one, but feel free to reassign.

---

This is an implementation of https://github.com/rust-lang/compiler-team/issues/390.

As mentioned, in general this turns an unconditional runtime panic into a (compile time) lint failure. It has no false positives, and the only false negatives I'm aware of are if `Ordering` isn't specified directly and is comes from an argument/constant/whatever.

As a result of it having no false positives, and the alternative always being strictly wrong, it's on as deny by default. This seems right.

In the [zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Uplift.20the.20.60invalid_atomic_ordering.60.20lint.20from.20clippy/near/218483957) `@joshtriplett` suggested that lang team should FCP this before landing it. Perhaps libs team cares too?

---

Some notes on the code for reviewers / others below

## Changes from clippy

The code is changed from [the implementation in clippy](https://github.com/rust-lang/rust-clippy/blob/68cf94f6a66e47234e3adefc6dfbe806cd6ad164/clippy_lints/src/atomic_ordering.rs) in the following ways:

1. Uses `Symbols` and `rustc_diagnostic_item`s instead of string literals.
    - It's possible I should have just invoked Symbol::intern for some of these instead? Seems better to use symbol, but it did require adding several.
2. The functions are moved to static methods inside the lint struct, as a way to namespace them.
    - There's a lot of other code in that file — which I picked as the location for this lint because `@jyn514` told me that seemed reasonable.
3. Supports unstable AtomicU128/AtomicI128.
    - I did this because it was almost easier to support them than not — not supporting them would have (ideally) required finding a way not to give them a `rustc_diagnostic_item`, which would have complicated an already big macro.
    - These don't have tests since I wasn't sure if/how I should make tests conditional on whether or not the target has the atomic... This is to a certain extent an issue of 64bit atomics too, but 128-bit atomics are much less common. Regardless, the existing tests should be *more* than thorough enough here.
4. Minor changes like:
    - grammar tweaks ("loads cannot have `Release` **and** `AcqRel` ordering" => "loads cannot have `Release` **or** `AcqRel` ordering")
    - function renames (`match_ordering_def_path` => `matches_ordering_def_path`),
    - avoiding clippy-specific helper methods that don't exist in rustc_lint and didn't seem worth adding for this case (for example `cx.struct_span_lint` vs clippy's `span_lint_and_help` helper).

## Potential issues

(This is just about the code in this PR, not conceptual issues with the lint or anything)

1. I'm not sure if I should have used a diagnostic item for `Ordering` and its variants (I couldn't figure out how really, so if I should do this some pointers would be appreciated).
    - It seems possible that failing to do this might possibly mean there are more cases this lint would miss, but I don't really know how `match_def_path` works and if it has any pitfalls like that, so maybe not.

2. I *think* I deprecated the lint in clippy (CC `@flip1995` who asked to be notified about clippy changes in the future in [this comment](https://github.com/rust-lang/rust/pull/75671#issuecomment-718731659)) but I'm not sure if I need to do anything else there.
    - I'm kind of hoping CI will catch if I missed anything, since `x.py test src/tools/clippy` fails with a lot of errors with and without my changes (and is probably a nonsense command regardless). Running `cargo test` from src/tools/clippy also fails with unrelated errors that seem like refactorings that didnt update clippy? So, honestly no clue.

3. I wasn't sure if the description/example I gave good. Hopefully it is. The example is less thorough than the one from clippy here: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering. Let me know if/how I should change it if it needs changing.

4. It pulls in the `if_chain` crate. This crate was already used in clippy, and seems like it's used elsewhere in rustc, but I'm willing to rewrite it to not use this if needed (I'd prefer not to, all things being equal).

2 years agoUplift the `invalid_atomic_ordering` lint from clippy to rustc
Thom Chiovoloni [Wed, 2 Dec 2020 23:16:12 +0000 (15:16 -0800)]
Uplift the `invalid_atomic_ordering` lint from clippy to rustc

- Deprecate clippy::invalid_atomic_ordering
- Use rustc_diagnostic_item for the orderings in the invalid_atomic_ordering lint
- Reduce code duplication
- Give up on making enum variants diagnostic items and just look for
`Ordering` instead

  I ran into tons of trouble with this because apparently the change to
  store HIR attrs in a side table also gave the DefIds of the
  constructor instead of the variant itself. So I had to change
  `matches_ordering` to also check the grandparent of the defid as well.

- Rename `atomic_ordering_x` symbols to just the name of the variant
- Fix typos in checks - there were a few places that said "may not be
  Release" in the diagnostic but actually checked for SeqCst in the lint.
- Make constant items const
- Use fewer diagnostic items
- Only look at arguments after making sure the method matches

  This prevents an ICE when there aren't enough arguments.

- Ignore trait methods
- Only check Ctors instead of going through `qpath_res`

  The functions take values, so this couldn't ever be anything else.

- Add if_chain to allowed dependencies
- Fix grammar
- Remove unnecessary allow

2 years agoIntroduce hir::ExprKind::Let - Take 2
Caio [Sun, 8 Aug 2021 14:49:13 +0000 (11:49 -0300)]
Introduce hir::ExprKind::Let - Take 2

2 years agomove Constness into TraitPredicate
Deadbeef [Thu, 22 Jul 2021 13:56:07 +0000 (21:56 +0800)]
move Constness into TraitPredicate

2 years agoAuto merge of #87954 - flip1995:clippyup, r=Manishearth
bors [Fri, 13 Aug 2021 05:30:37 +0000 (05:30 +0000)]
Auto merge of #87954 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoRollup merge of #87885 - m-ou-se:edition-guide-links, r=rylev
Guillaume Gomez [Thu, 12 Aug 2021 11:25:07 +0000 (13:25 +0200)]
Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylev

Link to edition guide instead of issues for 2021 lints.

This changes the 2021 lints to not link to github issues, but to the edition guide instead.

Fixes  #86996

2 years agoMerge commit '7bfc26ec8e7a454786668e7e52ffe527fc649735' into clippyup
flip1995 [Thu, 12 Aug 2021 09:16:25 +0000 (11:16 +0200)]
Merge commit '7bfc26ec8e7a454786668e7e52ffe527fc649735' into clippyup

2 years agoBless clippy tests.
Mara Bos [Thu, 12 Aug 2021 08:48:16 +0000 (10:48 +0200)]
Bless clippy tests.

2 years agoupdate clippy
Esteban Kuber [Wed, 11 Aug 2021 14:21:33 +0000 (14:21 +0000)]
update clippy

2 years agoAuto merge of #87568 - petrochenkov:localevel, r=cjgillot
bors [Wed, 4 Aug 2021 02:04:04 +0000 (02:04 +0000)]
Auto merge of #87568 - petrochenkov:localevel, r=cjgillot

rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tables

and passes using those tables - primarily privacy checking, stability checking and dead code checking.

All these passes work with definitions rather than with arbitrary HIR nodes.
r? `@cjgillot`
cc `@lambinoo` (#87487)