]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agonyahggdshjjghsdfhgsf
Ellen [Thu, 13 Jan 2022 09:26:27 +0000 (09:26 +0000)]
nyahggdshjjghsdfhgsf

2 years agoinitial revert
Ellen [Wed, 12 Jan 2022 03:19:52 +0000 (03:19 +0000)]
initial revert

2 years agoRollup merge of #92849 - flip1995:clippyup, r=Manishearth
Matthias Krüger [Fri, 14 Jan 2022 06:47:37 +0000 (07:47 +0100)]
Rollup merge of #92849 - flip1995:clippyup, r=Manishearth

Clippyup

r? ```@Manishearth```

2 years agoAuto merge of #89861 - nbdd0121:closure, r=wesleywiser
bors [Thu, 13 Jan 2022 18:51:07 +0000 (18:51 +0000)]
Auto merge of #89861 - nbdd0121:closure, r=wesleywiser

Closure capture cleanup & refactor

Follow up of #89648

Each commit is self-contained and the rationale/changes are documented in the commit message, so it's advisable to review commit by commit.

The code is significantly cleaner (at least IMO), but that could have some perf implication, so I'd suggest a perf run.

r? `@wesleywiser`
cc `@arora-aman`

2 years agoFix Clippy sync fallout
flip1995 [Thu, 13 Jan 2022 12:37:24 +0000 (13:37 +0100)]
Fix Clippy sync fallout

2 years agoMerge commit '97a5daa65908e59744e2bc625b14849352231c75' into clippyup
flip1995 [Thu, 13 Jan 2022 12:18:19 +0000 (13:18 +0100)]
Merge commit '97a5daa65908e59744e2bc625b14849352231c75' into clippyup

2 years agoStore a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`
Aaron Hill [Mon, 3 Jan 2022 03:37:05 +0000 (22:37 -0500)]
Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`

The field is also renamed from `ident` to `name. In most cases,
we don't actually need the `Span`. A new `ident` method is added
to `VariantDef` and `FieldDef`, which constructs the full `Ident`
using `tcx.def_ident_span()`. This method is used in the cases
where we actually need an `Ident`.

This makes incremental compilation properly track changes
to the `Span`, without all of the invalidations caused by storing
a `Span` directly via an `Ident`.

2 years agorustc_metadata: Rename `item_children(_untracked)` to `module_children(_untracked)`
Vadim Petrochenkov [Thu, 23 Dec 2021 08:12:34 +0000 (16:12 +0800)]
rustc_metadata: Rename `item_children(_untracked)` to `module_children(_untracked)`

And `each_child_of_item` to `for_each_module_child`

2 years agorustc_metadata: Optimize and document module children decoding
Vadim Petrochenkov [Sat, 18 Dec 2021 12:07:58 +0000 (20:07 +0800)]
rustc_metadata: Optimize and document module children decoding

2 years agoRemove region from UpvarCapture and move it to CapturedPlace
Gary Guo [Wed, 13 Oct 2021 20:20:10 +0000 (21:20 +0100)]
Remove region from UpvarCapture and move it to CapturedPlace

Region info is completely unnecessary for upvar capture kind computation
and is only needed to create the final upvar tuple ty. Doing so makes
creation of UpvarCapture very cheap and expose further cleanup opportunity.

2 years agoRemove span from UpvarCapture::ByValue
Gary Guo [Sat, 9 Oct 2021 21:11:13 +0000 (22:11 +0100)]
Remove span from UpvarCapture::ByValue

This span is unused and is superseded by capture_kind_expr_id in CaptureInfo

2 years agoUpdate clippy for associated item changes
Matthew Jasper [Thu, 18 Nov 2021 22:33:49 +0000 (22:33 +0000)]
Update clippy for associated item changes

2 years agoRollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU
Matthias Krüger [Tue, 4 Jan 2022 20:23:06 +0000 (21:23 +0100)]
Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU

Allow `_` as the length of array types and repeat expressions

r? `@BoxyUwU` cc `@varkor`

2 years agoRollup merge of #90102 - nbdd0121:box3, r=jonas-schievink
Matthias Krüger [Mon, 3 Jan 2022 13:44:15 +0000 (14:44 +0100)]
Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink

Remove `NullOp::Box`

Follow up of #89030 and MCP rust-lang/compiler-team#460.

~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely.

r? `@jonas-schievink`
`@rustbot` label T-compiler

2 years agoMake tidy check for magic numbers that spell things
Josh Triplett [Sat, 1 Jan 2022 05:13:07 +0000 (21:13 -0800)]
Make tidy check for magic numbers that spell things

Remove existing problematic cases.

2 years agoAuto merge of #92252 - GuillaumeGomez:update-pulldown, r=camelid,xFrednet
bors [Fri, 31 Dec 2021 12:46:38 +0000 (12:46 +0000)]
Auto merge of #92252 - GuillaumeGomez:update-pulldown, r=camelid,xFrednet

Update pulldown-cmark version to 0.9

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

r? `@camelid`

2 years agoMerge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup
flip1995 [Thu, 30 Dec 2021 14:10:43 +0000 (15:10 +0100)]
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup

2 years agoUpdate pulldown-cmark version in clippy
Guillaume Gomez [Tue, 28 Dec 2021 15:19:23 +0000 (16:19 +0100)]
Update pulldown-cmark version in clippy

2 years agofix clippy
lcnr [Thu, 23 Dec 2021 09:02:05 +0000 (10:02 +0100)]
fix clippy

2 years agoBless clippy test.
Mara Bos [Wed, 22 Dec 2021 16:25:44 +0000 (17:25 +0100)]
Bless clippy test.

2 years agoAuto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
bors [Sun, 19 Dec 2021 09:31:37 +0000 (09:31 +0000)]
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk

Remove `SymbolStr`

This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`

2 years agoAuto merge of #89841 - cormacrelf:let-else-typed, r=nagisa
bors [Fri, 17 Dec 2021 22:12:34 +0000 (22:12 +0000)]
Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisa

Implement let-else type annotations natively

Tracking issue: #87335

Fixes #89688, fixes #89807, edit: fixes  #89960 as well

As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved.

This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically:

* `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~
* It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that.

* ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~
* ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~
    * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~

Some other misc notes:

* ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~
* in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.

2 years agoMerge commit '23d11428de3e973b34a5090a78d62887f821c90e' into clippyup
flip1995 [Fri, 17 Dec 2021 12:40:22 +0000 (13:40 +0100)]
Merge commit '23d11428de3e973b34a5090a78d62887f821c90e' into clippyup

2 years agoRollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix
Matthias Krüger [Wed, 15 Dec 2021 07:36:19 +0000 (08:36 +0100)]
Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix

Stabilize `destructuring_assignment`

Closes #71126

- [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058)
- [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819)

`@rustbot` label +F-destructuring-assignment +T-lang
Also needs +relnotes but I don't have permission to add that tag.

2 years agoRemove unnecessary sigils around `Ident::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 05:13:11 +0000 (16:13 +1100)]
Remove unnecessary sigils around `Ident::as_str()` calls.

2 years agoRemove unnecessary sigils around `Symbol::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 03:39:23 +0000 (14:39 +1100)]
Remove unnecessary sigils around `Symbol::as_str()` calls.

2 years agoStabilize `destructuring_assignment`
Jacob Pratt [Wed, 3 Nov 2021 06:50:57 +0000 (02:50 -0400)]
Stabilize `destructuring_assignment`

2 years agoRemove `SymbolStr`.
Nicholas Nethercote [Tue, 14 Dec 2021 21:32:21 +0000 (08:32 +1100)]
Remove `SymbolStr`.

By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!

2 years agoRollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Matthias Krüger [Wed, 15 Dec 2021 00:28:08 +0000 (01:28 +0100)]
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm

Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).

2 years agoRollup merge of #90939 - estebank:wg-af-polish, r=tmandry
Matthias Krüger [Wed, 15 Dec 2021 00:28:04 +0000 (01:28 +0100)]
Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry

Tweak errors coming from `for`-loop, `?` and `.await` desugaring

 * Suggest removal of `.await` on non-`Future` expression
 * Keep track of obligations introduced by desugaring
 * Remove span pointing at method for obligation errors coming from desugaring
 * Point at called local sync `fn` and suggest making it `async`

```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:9:10
   |
LL |     boo().await;
   |     -----^^^^^^ `()` is not a future
   |     |
   |     this call returns `()`
   |
   = help: the trait `Future` is not implemented for `()`
help: do not `.await` the expression
   |
LL -     boo().await;
LL +     boo();
   |
help: alternatively, consider making `fn boo` asynchronous
   |
LL | async fn boo () {}
   | +++++
```

Fix #66731.

2 years agoRemove iter::zip feature gate from clippy
PFPoitras [Tue, 14 Dec 2021 22:10:57 +0000 (18:10 -0400)]
Remove iter::zip feature gate from clippy

2 years agoAuto merge of #91728 - Amanieu:stable_asm, r=joshtriplett
bors [Tue, 14 Dec 2021 21:15:22 +0000 (21:15 +0000)]
Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett

Stabilize asm! and global_asm!

Tracking issue: #72016

It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature!

The main changes in this PR are:
- Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228.
- Stabilizing the `asm` and `global_asm` features.
- Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483).
  - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example.
- Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`.
- Updating `stdarch` and `compiler-builtins`.
- Updating all the tests.

r? `@joshtriplett`

2 years agofix clippy tests
Esteban Kuber [Fri, 10 Dec 2021 17:20:57 +0000 (17:20 +0000)]
fix clippy tests

2 years agoFix rebase and clippy tests
Esteban Kuber [Tue, 16 Nov 2021 22:06:25 +0000 (22:06 +0000)]
Fix rebase and clippy tests

2 years agoFix clippy uses of QPath::LangItem
Esteban Kuber [Tue, 16 Nov 2021 20:44:25 +0000 (20:44 +0000)]
Fix clippy uses of QPath::LangItem

2 years agolet-else: use hir::Let in clippy
Cormac Relf [Wed, 13 Oct 2021 07:44:47 +0000 (18:44 +1100)]
let-else: use hir::Let in clippy

fix clippy format using `cargo fmt -p clippy_{lints,utils}`
manually revert rustfmt line truncations
rename to hir::Let in clippy
Undo the shadowing of various `expr` variables after renaming `scrutinee`
reduce destructuring of hir::Let to avoid `expr` collisions
cargo fmt -p clippy_{lints,utils}
bless new clippy::author output

2 years agoFix clippy tests
Amanieu d'Antras [Mon, 13 Dec 2021 00:00:51 +0000 (00:00 +0000)]
Fix clippy tests

2 years agoAuto merge of #91549 - fee1-dead:const_env, r=spastorino
bors [Sun, 12 Dec 2021 22:15:32 +0000 (22:15 +0000)]
Auto merge of #91549 - fee1-dead:const_env, r=spastorino

Eliminate ConstnessAnd again

Closes #91489.
Closes #89432.

Reverts #91491.
Reverts #89450.

r? `@spastorino`

2 years agoclippy owo
Ellen [Sun, 12 Dec 2021 12:34:21 +0000 (12:34 +0000)]
clippy owo

2 years agoRevert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"
Deadbeef [Sun, 12 Dec 2021 04:34:46 +0000 (12:34 +0800)]
Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"

This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing
changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.

2 years agoMerge commit 'a5d597637dcb78dc73f93561ce474f23d4177c35' into clippyup
flip1995 [Mon, 6 Dec 2021 11:33:31 +0000 (12:33 +0100)]
Merge commit 'a5d597637dcb78dc73f93561ce474f23d4177c35' into clippyup

2 years agoUse IntoIterator for array impl everywhere.
Mara Bos [Fri, 3 Sep 2021 10:36:33 +0000 (12:36 +0200)]
Use IntoIterator for array impl everywhere.

2 years agoAdd initial AST and MIR support for unwinding from inline assembly
Amanieu d'Antras [Mon, 30 Aug 2021 00:23:33 +0000 (01:23 +0100)]
Add initial AST and MIR support for unwinding from inline assembly

2 years agoRevert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"
Santiago Pastorino [Fri, 3 Dec 2021 13:11:21 +0000 (10:11 -0300)]
Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"

This reverts commit 18bb8c61a975fff6424cda831ace5b0404277145, reversing
changes made to d9baa361902b172be716f96619b909f340802dea.

2 years agoAuto merge of #91354 - fee1-dead:const_env, r=spastorino
bors [Thu, 2 Dec 2021 11:48:58 +0000 (11:48 +0000)]
Auto merge of #91354 - fee1-dead:const_env, r=spastorino

Cleanup: Eliminate ConstnessAnd

This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature.

We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`.

This is a continuation of https://github.com/rust-lang/rust/pull/90274.

r? `@oli-obk`

cc `@spastorino` `@ecstatic-morse`

2 years agoFix tools
Deadbeef [Mon, 29 Nov 2021 12:42:16 +0000 (20:42 +0800)]
Fix tools

2 years agoTake a LocalDefId in expect_*item.
Camille GILLOT [Wed, 20 Oct 2021 20:38:10 +0000 (22:38 +0200)]
Take a LocalDefId in expect_*item.

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 agoRemove NullOp::Box
Gary Guo [Sun, 26 Sep 2021 16:38:05 +0000 (17:38 +0100)]
Remove NullOp::Box

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