]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyup
flip1995 [Thu, 3 Jun 2021 06:41:37 +0000 (08:41 +0200)]
Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyup

3 years agoremove cfg(bootstrap)
Pietro Albini [Thu, 6 May 2021 11:36:07 +0000 (13:36 +0200)]
remove cfg(bootstrap)

3 years agoMerge commit '9e3cd88718cd1912a515d26dbd9c4019fd5a9577' into clippyup
flip1995 [Thu, 20 May 2021 10:30:31 +0000 (12:30 +0200)]
Merge commit '9e3cd88718cd1912a515d26dbd9c4019fd5a9577' into clippyup

3 years agoAuto merge of #84767 - scottmcm:try_trait_actual, r=lcnr
bors [Tue, 18 May 2021 20:50:01 +0000 (20:50 +0000)]
Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnr

Implement the new desugaring from `try_trait_v2`

~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix.

`try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277

Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them.  (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits.

r? `@ghost`

~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.

3 years agoAuto merge of #85178 - cjgillot:local-crate, r=oli-obk
bors [Mon, 17 May 2021 01:42:03 +0000 (01:42 +0000)]
Auto merge of #85178 - cjgillot:local-crate, r=oli-obk

Remove CrateNum parameter for queries that only work on local crate

The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea.

Using `()` as query key in those cases avoids having to worry about the validity of the query key.

3 years agoAddressed PR coments
ayushmishra2005 [Fri, 14 May 2021 12:00:26 +0000 (17:30 +0530)]
Addressed PR coments

3 years agoImprove match statements
ayushmishra2005 [Fri, 14 May 2021 03:27:33 +0000 (08:57 +0530)]
Improve match statements

3 years agoShow macro name in 'this error originates in macro' message
Aaron Hill [Sat, 13 Feb 2021 19:52:25 +0000 (14:52 -0500)]
Show macro name in 'this error originates in macro' message

When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.

3 years agoUse () for inherent_impls.
Camille GILLOT [Tue, 11 May 2021 11:39:19 +0000 (13:39 +0200)]
Use () for inherent_impls.

3 years agoUse () for entry_fn.
Camille GILLOT [Tue, 11 May 2021 10:00:59 +0000 (12:00 +0200)]
Use () for entry_fn.

3 years agoUse () for HIR queries.
Camille GILLOT [Tue, 11 May 2021 09:42:01 +0000 (11:42 +0200)]
Use () for HIR queries.

3 years agoAuto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
bors [Wed, 12 May 2021 11:05:56 +0000 (11:05 +0000)]
Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister

Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths

This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped.

`RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path.

`RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure.

When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host".

`rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`.

cc `@eddyb` who implemented `/rustc/...` path devirtualisation

3 years agoImplement span quoting for proc-macros
Aaron Hill [Sun, 2 Aug 2020 23:52:16 +0000 (19:52 -0400)]
Implement span quoting for proc-macros

This PR implements span quoting, allowing proc-macros to produce spans
pointing *into their own crate*. This is used by the unstable
`proc_macro::quote!` macro, allowing us to get error messages like this:

```
error[E0412]: cannot find type `MissingType` in this scope
  --> $DIR/auxiliary/span-from-proc-macro.rs:37:20
   |
LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
   | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]`
...
LL |             field: MissingType
   |                    ^^^^^^^^^^^ not found in this scope
   |
  ::: $DIR/span-from-proc-macro.rs:8:1
   |
LL | #[error_from_attribute]
   | ----------------------- in this macro invocation
```

Here, `MissingType` occurs inside the implementation of the proc-macro
`#[error_from_attribute]`. Previosuly, this would always result in a
span pointing at `#[error_from_attribute]`

This will make many proc-macro-related error message much more useful -
when a proc-macro generates code containing an error, users will get an
error message pointing directly at that code (within the macro
definition), instead of always getting a span pointing at the macro
invocation site.

This is implemented as follows:
* When a proc-macro crate is being *compiled*, it causes the `quote!`
  macro to get run. This saves all of the sapns in the input to `quote!`
  into the metadata of *the proc-macro-crate* (which we are currently
  compiling). The `quote!` macro then expands to a call to
  `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an
opaque identifier for the span in the crate metadata.
* When the same proc-macro crate is *run* (e.g. it is loaded from disk
  and invoked by some consumer crate), the call to
`proc_macro::Span::recover_proc_macro_span` causes us to load the span
from the proc-macro crate's metadata. The proc-macro then produces a
`TokenStream` containing a `Span` pointing into the proc-macro crate
itself.

The recursive nature of 'quote!' can be difficult to understand at
first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows
the output of the `quote!` macro, which should make this eaier to
understand.

This PR also supports custom quoting spans in custom quote macros (e.g.
the `quote` crate). All span quoting goes through the
`proc_macro::quote_span` method, which can be called by a custom quote
macro to perform span quoting. An example of this usage is provided in
`src/test/ui/proc-macro/auxiliary/custom-quote.rs`

Custom quoting currently has a few limitations:

In order to quote a span, we need to generate a call to
`proc_macro::Span::recover_proc_macro_span`. However, proc-macros
support renaming the `proc_macro` crate, so we can't simply hardcode
this path. Previously, the `quote_span` method used the path
`crate::Span` - however, this only works when it is called by the
builtin `quote!` macro in the same crate. To support being called from
arbitrary crates, we need access to the name of the `proc_macro` crate
to generate a path. This PR adds an additional argument to `quote_span`
to specify the name of the `proc_macro` crate. Howver, this feels kind
of hacky, and we may want to change this before stabilizing anything
quote-related.

Additionally, using `quote_span` currently requires enabling the
`proc_macro_internals` feature. The builtin `quote!` macro
has an `#[allow_internal_unstable]` attribute, but this won't work for
custom quote implementations. This will likely require some additional
tricks to apply `allow_internal_unstable` to the span of
`proc_macro::Span::recover_proc_macro_span`.

3 years agoAuto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk
bors [Tue, 11 May 2021 10:25:14 +0000 (10:25 +0000)]
Auto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk

remove const_fn feature gate

Fixes https://github.com/rust-lang/rust/issues/84510
r? `@oli-obk`

3 years agofix clippy test
Ralf Jung [Mon, 10 May 2021 22:40:25 +0000 (00:40 +0200)]
fix clippy test

3 years agoAuto merge of #85053 - camsteffen:duplicate-lint, r=davidtwco
bors [Mon, 10 May 2021 09:45:28 +0000 (09:45 +0000)]
Auto merge of #85053 - camsteffen:duplicate-lint, r=davidtwco

Fix duplicate unknown lint errors

Fixes rust-lang/rust-clippy#6602

3 years agoFix duplicate unknown lint errors
Cameron Steffen [Fri, 7 May 2021 19:53:02 +0000 (14:53 -0500)]
Fix duplicate unknown lint errors

3 years agoFix clippy
Scott McMurray [Sat, 1 May 2021 01:40:34 +0000 (18:40 -0700)]
Fix clippy

3 years agoMerge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup
flip1995 [Thu, 6 May 2021 09:51:22 +0000 (11:51 +0200)]
Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup

3 years agoUse local and remapped paths where appropriate
Andy Wang [Mon, 19 Apr 2021 22:27:02 +0000 (23:27 +0100)]
Use local and remapped paths where appropriate

3 years agoAuto merge of #84200 - CDirkx:os, r=m-ou-se
bors [Wed, 5 May 2021 14:15:19 +0000 (14:15 +0000)]
Auto merge of #84200 - CDirkx:os, r=m-ou-se

Move all `sys::ext` modules to `os`

This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`.

Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038.

`@rustbot` label: +T-libs-impl

3 years agoAuto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis
bors [Tue, 4 May 2021 08:09:23 +0000 (08:09 +0000)]
Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis

Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021

This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition.

r? `@estebank`

3 years agoChange `std::sys::unix::ext::fs::PermissionsExt::from_mode` to `std::os::imp::unix...
Christiaan Dirkx [Sun, 25 Apr 2021 11:10:19 +0000 (13:10 +0200)]
Change `std::sys::unix::ext::fs::PermissionsExt::from_mode` to `std::os::imp::unix::fs::PermissionsExt::from_mode` in Clippy

3 years agoAdd ErrorKind::OutOfMemory
Kornel [Fri, 30 Apr 2021 11:15:38 +0000 (12:15 +0100)]
Add ErrorKind::OutOfMemory

3 years agoAuto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov
bors [Fri, 30 Apr 2021 06:59:37 +0000 (06:59 +0000)]
Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov

Implement RFC 1260 with feature_name `imported_main`.

This is the second extraction part of #84062 plus additional adjustments.
This (mostly) implements RFC 1260.

However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure.

cc https://github.com/rust-lang/rust/issues/28937
r? `@petrochenkov`

3 years agoFix clippy error
Ryan Levick [Thu, 29 Apr 2021 16:37:22 +0000 (18:37 +0200)]
Fix clippy error

3 years agoAuto merge of #84189 - jyn514:clippy-dev, r=Mark-Simulacrum
bors [Thu, 29 Apr 2021 12:03:43 +0000 (12:03 +0000)]
Auto merge of #84189 - jyn514:clippy-dev, r=Mark-Simulacrum

Implement `x.py test src/tools/clippy --bless`

- Add clippy_dev to the rust workspace

  Before, it would give an error that it wasn't either included or
  excluded from the workspace:

  ```
  error: current package believes it's in a workspace when it's not:
  current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
  workspace: /home/joshua/rustc/Cargo.toml

  this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
  Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
  ```

- Change clippy's copy of compiletest not to special-case
  rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find
  the test outputs. This is one of the reasons why `cargo dev bless` used
  to silently do nothing (the others were that `CARGO_TARGET_DIR` and
  `PROFILE` weren't set appropriately).

- Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

- Fix clippy_dev warnings

3 years agoRollup merge of #84484 - jyn514:check-tools, r=Mark-Simulacrum
Jack Huey [Thu, 29 Apr 2021 02:59:22 +0000 (22:59 -0400)]
Rollup merge of #84484 - jyn514:check-tools, r=Mark-Simulacrum

Don't rebuild rustdoc and clippy after checking bootstrap

This works by unconditionally passing -Z unstable-options to the
compiler. This has no affect in practice since bootstrap doesn't use
`deny(rustc::internal)`.

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

r? ```@Mark-Simulacrum```

3 years agoImplement RFC 1260 with feature_name `imported_main`.
Charles Lew [Sun, 25 Apr 2021 17:09:35 +0000 (01:09 +0800)]
Implement RFC 1260 with feature_name `imported_main`.

3 years agoSwitch `rustc::internal` from deny to warn
Joshua Nelson [Tue, 27 Apr 2021 17:00:36 +0000 (13:00 -0400)]
Switch `rustc::internal` from deny to warn

These should still obey deny-warnings.

3 years agoImplement `x.py test src/tools/clippy --bless`
Joshua Nelson [Wed, 14 Apr 2021 13:20:49 +0000 (09:20 -0400)]
Implement `x.py test src/tools/clippy --bless`

- Add clippy_dev to the rust workspace

  Before, it would give an error that it wasn't either included or
  excluded from the workspace:

  ```
  error: current package believes it's in a workspace when it's not:
  current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
  workspace: /home/joshua/rustc/Cargo.toml

  this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
  Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
  ```

- Change clippy's copy of compiletest not to special-case
  rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find
  the test outputs. This is one of the reasons why `cargo dev bless` used
  to silently do nothing (the others were that `CARGO_TARGET_DIR` and
  `PROFILE` weren't set appropriately).

- Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

- Fix clippy_dev warnings

3 years agoMerge commit '7c7683c8efe447b251d6c5ca6cce51233060f6e8' into clippyup
flip1995 [Tue, 27 Apr 2021 14:55:11 +0000 (16:55 +0200)]
Merge commit '7c7683c8efe447b251d6c5ca6cce51233060f6e8' into clippyup

3 years agofix clippy
Ralf Jung [Sun, 25 Apr 2021 15:05:48 +0000 (17:05 +0200)]
fix clippy

3 years agoMerge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup
flip1995 [Thu, 22 Apr 2021 09:31:13 +0000 (11:31 +0200)]
Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup

3 years agofix suggestion for unsized function parameters
lcnr [Sun, 18 Apr 2021 17:35:23 +0000 (19:35 +0200)]
fix suggestion for unsized function parameters

3 years agoAuto merge of #78880 - CDirkx:not_supported, r=joshtriplett
bors [Sun, 18 Apr 2021 20:03:54 +0000 (20:03 +0000)]
Auto merge of #78880 - CDirkx:not_supported, r=joshtriplett

Add `Unsupported` to `std::io::ErrorKind`

I noticed a significant portion of the uses of `ErrorKind::Other` in std is for unsupported operations.
The notion that a specific operation is not available on a target (and will thus never succeed) seems semantically distinct enough from just "an unspecified error occurred", which is why I am proposing to add the variant `Unsupported` to `std::io::ErrorKind`.

**Implementation**:

The following variant will be added to `std::io::ErrorKind`:

```rust
/// This operation is unsupported on this platform.
Unsupported
```
`std::io::ErrorKind::Unsupported` is an error returned when a given operation is not supported on a platform, and will thus never succeed; there is no way for the software to recover. It will be used instead of `Other` where appropriate, e.g. on wasm for file and network operations.

`decode_error_kind` will be updated  to decode operating system errors to `Unsupported`:
- Unix and VxWorks: `libc::ENOSYS`
- Windows: `c::ERROR_CALL_NOT_IMPLEMENTED`
- WASI: `wasi::ERRNO_NOSYS`

**Stability**:
This changes the kind of error returned by some functions on some platforms, which I think is not covered by the stability guarantees of the std? User code could depend on this behavior, expecting `ErrorKind::Other`, however the docs already mention:

> Errors that are `Other` now may move to a different or a new `ErrorKind` variant in the future. It is not recommended to match an error against `Other` and to expect any additional characteristics, e.g., a specific `Error::raw_os_error` return value.

The most recent variant added to `ErrorKind` was `UnexpectedEof` in `1.6.0` (almost 5 years ago), but `ErrorKind` is marked as `#[non_exhaustive]` and the docs warn about exhaustively matching on it, so adding a new variant per se should not be a breaking change.

The variant `Unsupported` itself could be marked as `#[unstable]`, however, because this PR also immediately uses this new variant and changes the errors returned by functions I'm inclined to agree with the others in this thread that the variant should be insta-stabilized.

3 years agoFix clippy test using `ErrorKind`
Christiaan Dirkx [Mon, 29 Mar 2021 10:35:16 +0000 (12:35 +0200)]
Fix clippy test using `ErrorKind`

3 years agoAuto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkov
bors [Sun, 18 Apr 2021 02:12:13 +0000 (02:12 +0000)]
Auto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkov

Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes

Fixes #83477.

3 years agoDo not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid...
hyd-dev [Sat, 10 Apr 2021 17:08:31 +0000 (01:08 +0800)]
Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes

3 years agoRemove #[main] attribute.
Charles Lew [Thu, 8 Apr 2021 13:37:38 +0000 (21:37 +0800)]
Remove #[main] attribute.

3 years agoMerge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup
flip1995 [Thu, 8 Apr 2021 15:50:13 +0000 (17:50 +0200)]
Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup

3 years agoRollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov
Dylan DPC [Wed, 7 Apr 2021 11:07:14 +0000 (13:07 +0200)]
Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov

Use AnonConst for asm! constants

This replaces the old system which used explicit promotion. See #83169 for more background.

The syntax for `const` operands is still the same as before: `const <expr>`.

Fixes #83169

Because the implementation is heavily based on inline consts, we suffer from the same issues:
- We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`.
- We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.

3 years agoUse AnonConst for asm! constants
Amanieu d'Antras [Tue, 6 Apr 2021 04:50:55 +0000 (05:50 +0100)]
Use AnonConst for asm! constants

3 years agoRollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa
Dylan DPC [Sun, 4 Apr 2021 22:24:33 +0000 (00:24 +0200)]
Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa

Remove attribute `#[link_args]`

Closes https://github.com/rust-lang/rust/issues/29596

The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc.
Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.

3 years agoRemove attribute `#[link_args]`
Vadim Petrochenkov [Sat, 3 Apr 2021 17:20:18 +0000 (20:20 +0300)]
Remove attribute `#[link_args]`

3 years agofix clippy error
Roxane [Tue, 30 Mar 2021 04:30:20 +0000 (00:30 -0400)]
fix clippy error

3 years agoTrack bound vars
Jack Huey [Tue, 6 Oct 2020 00:41:46 +0000 (20:41 -0400)]
Track bound vars

3 years agoRemove hir::CrateItem.
Camille GILLOT [Tue, 30 Mar 2021 18:31:06 +0000 (20:31 +0200)]
Remove hir::CrateItem.

3 years agoRemove (lots of) dead code
Joshua Nelson [Tue, 16 Mar 2021 05:50:34 +0000 (01:50 -0400)]
Remove (lots of) dead code

Found with https://github.com/est31/warnalyzer.

Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
  x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
  wants to use it in the future?
- Don't change rustc_serialize

  I plan to scrap most of the json module in the near future (see
  https://github.com/rust-lang/compiler-team/issues/418) and fixing the
  tests needed more work than I expected.

TODO: check if any of the comments on the deleted code should be kept.

3 years agoRollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
Dylan DPC [Sat, 27 Mar 2021 19:37:07 +0000 (20:37 +0100)]
Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se

Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in #78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html

3 years agoformat macro argument parsing fix
Ömer Sinan Ağacan [Sun, 21 Mar 2021 14:29:21 +0000 (17:29 +0300)]
format macro argument parsing fix

When the character next to `{}` is "shifted" (when mapping a byte index
in the format string to span) we should avoid shifting the span end
index, so first map the index of `}` to span, then bump the span,
instead of first mapping the next byte index to a span (which causes
bumping the end span too much).

Regression test added.

Fixes #83344

3 years agoUse iter::zip in src/tools/clippy/
Josh Stone [Mon, 8 Mar 2021 23:57:44 +0000 (15:57 -0800)]
Use iter::zip in src/tools/clippy/

3 years agoMerge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyup
flip1995 [Thu, 25 Mar 2021 18:29:11 +0000 (19:29 +0100)]
Merge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyup

3 years agoAdd has_default to GenericParamDefKind::Const
kadmin [Tue, 11 Aug 2020 00:02:45 +0000 (00:02 +0000)]
Add has_default to GenericParamDefKind::Const

This currently creates a field which is always false on GenericParamDefKind for future use when
consts are permitted to have defaults

Update const_generics:default locations

Previously just ignored them, now actually do something about them.

Fix using type check instead of value

Add parsing

This adds all the necessary changes to lower const-generics defaults from parsing.

Change P<Expr> to AnonConst

This matches the arguments passed to instantiations of const generics, and makes it specific to
just anonymous constants.

Attempt to fix lowering bugs

3 years agoAuto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis
bors [Mon, 22 Mar 2021 19:48:27 +0000 (19:48 +0000)]
Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis

Stabilize or_patterns (RFC 2535, 2530, 2175)

closes #54883

This PR stabilizes the or_patterns feature in Rust 1.53.

This is blocked on the following (in order):
- [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021
- [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705)
    - It looks like we will need to pursue some sort of edition-based transition for `:pat`.
- [x] Nomination and discussion by T-lang
- [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100).
- [ ] An FCP on stabilization

EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177

3 years agoupdate `const_eval_resolve`
lcnr [Sat, 13 Mar 2021 15:31:38 +0000 (16:31 +0100)]
update `const_eval_resolve`

3 years agoclippy: stabilize or_patterns lint
mark [Sat, 21 Nov 2020 21:22:32 +0000 (15:22 -0600)]
clippy: stabilize or_patterns lint

3 years agohir: Preserve used syntax in `TyKind::TraitObject`
Vadim Petrochenkov [Sat, 13 Mar 2021 12:44:29 +0000 (15:44 +0300)]
hir: Preserve used syntax in `TyKind::TraitObject`

3 years agoAuto merge of #82122 - bstrie:dep4real, r=dtolnay
bors [Wed, 17 Mar 2021 19:39:03 +0000 (19:39 +0000)]
Auto merge of #82122 - bstrie:dep4real, r=dtolnay

Deprecate `intrinsics::drop_in_place` and `collections::Bound`, which accidentally weren't deprecated

Fixes #82080.

I've taken the liberty of updating the `since` values to 1.52, since an unobservable deprecation isn't much of a deprecation (even the detailed release notes never bothered to mention these deprecations).

As mentioned in the issue I'm *pretty* sure that using a type alias for `Bound` is semantically equivalent to the re-export; [the reference implies](https://doc.rust-lang.org/reference/items/type-aliases.html) that type aliases only observably differ from types when used on unit structs or tuple structs, whereas `Bound` is an enum.

3 years agoAuto merge of #83188 - petrochenkov:field, r=lcnr
bors [Wed, 17 Mar 2021 16:49:46 +0000 (16:49 +0000)]
Auto merge of #83188 - petrochenkov:field, r=lcnr

ast/hir: Rename field-related structures

I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.

- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")

Various visiting and other methods working with the fields are renamed correspondingly too.

The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.

3 years agoRollup merge of #83092 - petrochenkov:qspan, r=estebank
Yuki Okushi [Wed, 17 Mar 2021 06:20:54 +0000 (15:20 +0900)]
Rollup merge of #83092 - petrochenkov:qspan, r=estebank

More precise spans for HIR paths

`Ty::assoc_item` is lowered to `<Ty>::assoc_item` in HIR, but `Ty` got span from the whole path.
This PR fixes that, and adjusts some diagnostic code that relied on `Ty` having the whole path span.

This is a pre-requisite for https://github.com/rust-lang/rust/pull/82868 (we cannot report suggestions like `Tr::assoc` -> `<dyn Tr>::assoc` with the current imprecise spans).
r? ````@estebank````

3 years agoAuto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis
bors [Tue, 16 Mar 2021 19:19:06 +0000 (19:19 +0000)]
Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis

2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled

This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled.
1. Matching is always considered a use of the place, even with `_` patterns
2. Compiler ICE when capturing fields in closures through `let` assignments

To do so, we

- Introduced new Fake Reads
- Delayed use of `Place` in favor of `PlaceBuilder`
- Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code

Closes rust-lang/project-rfc-2229/issues/27
Closes rust-lang/project-rfc-2229/issues/24
r? `@nikomatsakis`

3 years agoast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`
Vadim Petrochenkov [Tue, 16 Mar 2021 00:15:53 +0000 (03:15 +0300)]
ast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`

3 years agoast/hir: Rename field-related structures
Vadim Petrochenkov [Mon, 15 Mar 2021 21:36:07 +0000 (00:36 +0300)]
ast/hir: Rename field-related structures

StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")

Also rename visiting and other methods working on them.

3 years agoUpdate clippy tests
Vadim Petrochenkov [Mon, 15 Mar 2021 20:52:57 +0000 (23:52 +0300)]
Update clippy tests

3 years agoFix error after rebase
Roxane [Mon, 15 Mar 2021 03:53:43 +0000 (23:53 -0400)]
Fix error after rebase

3 years agoAdd comments with examples and tests
Roxane [Thu, 25 Feb 2021 23:03:41 +0000 (18:03 -0500)]
Add comments with examples and tests

3 years agoUse `rustc_interface::interface::Config::parse_sess_created` in Clippy
hyd-dev [Mon, 15 Mar 2021 10:24:28 +0000 (18:24 +0800)]
Use `rustc_interface::interface::Config::parse_sess_created` in Clippy

3 years agoAdd fake_read() to clippy
Roxane [Thu, 25 Feb 2021 20:33:18 +0000 (15:33 -0500)]
Add fake_read() to clippy

3 years agoClippy: HACK! Fix bootstrap error
flip1995 [Fri, 12 Mar 2021 14:32:04 +0000 (15:32 +0100)]
Clippy: HACK! Fix bootstrap error

This will be removed in the next sync, once beta is at 1.52. Until then
this hack avoids to put `cfg(bootstrap)` into Clippy.

3 years agoMerge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
flip1995 [Fri, 12 Mar 2021 14:30:50 +0000 (15:30 +0100)]
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup

3 years agoAuto merge of #79519 - cjgillot:noattr, r=wesleywiser
bors [Wed, 10 Mar 2021 08:40:51 +0000 (08:40 +0000)]
Auto merge of #79519 - cjgillot:noattr, r=wesleywiser

Store HIR attributes in a side table

Same idea as #72015 but for attributes.
The objective is to reduce incr-comp invalidations due to modified attributes.
Notably, those due to modified doc comments.

Implementation:
- collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables;
- access the attributes through a `hir_owner_attrs` query;
- local refactorings to use this access;
- remove `attrs` from HIR data structures one-by-one.

Change in behaviour:
- the HIR visitor traverses all attributes at once instead of parent-by-parent;
- attribute arrays are sometimes duplicated: for statements and variant constructors;
- as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints.

~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~

3 years agoDeprecate items that accidentally weren't deprecated
bstrie [Sun, 14 Feb 2021 21:42:38 +0000 (16:42 -0500)]
Deprecate items that accidentally weren't deprecated

Fixes #82080

3 years agoRemove hir::Expr::attrs.
Camille GILLOT [Fri, 27 Nov 2020 16:41:05 +0000 (17:41 +0100)]
Remove hir::Expr::attrs.

3 years agoRemove hir::Item::attrs.
Camille GILLOT [Sun, 24 Jan 2021 12:17:54 +0000 (13:17 +0100)]
Remove hir::Item::attrs.

3 years agoRemove hir::ImplItem::attrs.
Camille GILLOT [Fri, 27 Nov 2020 08:55:10 +0000 (09:55 +0100)]
Remove hir::ImplItem::attrs.

3 years agoRemove hir::TraitItem::attrs.
Camille GILLOT [Fri, 27 Nov 2020 08:41:53 +0000 (09:41 +0100)]
Remove hir::TraitItem::attrs.

3 years agoRemove hir::StructField::attrs.
Camille GILLOT [Thu, 26 Nov 2020 23:27:34 +0000 (00:27 +0100)]
Remove hir::StructField::attrs.

3 years agoRemove hir::Variant::attrs.
Camille GILLOT [Thu, 26 Nov 2020 23:07:36 +0000 (00:07 +0100)]
Remove hir::Variant::attrs.

3 years agoRemove hir::Arm::attrs.
Camille GILLOT [Thu, 26 Nov 2020 22:46:48 +0000 (23:46 +0100)]
Remove hir::Arm::attrs.

3 years agoRemove hir::Crate::attrs.
Camille GILLOT [Thu, 26 Nov 2020 22:38:53 +0000 (23:38 +0100)]
Remove hir::Crate::attrs.

3 years agoRemove hir::Local::attrs.
Camille GILLOT [Wed, 25 Nov 2020 21:45:24 +0000 (22:45 +0100)]
Remove hir::Local::attrs.

3 years agoRemove hir::StmtKind::attrs.
Camille GILLOT [Wed, 25 Nov 2020 21:07:09 +0000 (22:07 +0100)]
Remove hir::StmtKind::attrs.

3 years agoDo not store attrs in FnKind.
Camille GILLOT [Fri, 27 Nov 2020 08:24:42 +0000 (09:24 +0100)]
Do not store attrs in FnKind.

3 years agoSimplify clippy author.
Camille GILLOT [Sun, 6 Dec 2020 21:00:24 +0000 (22:00 +0100)]
Simplify clippy author.

3 years agoSwitch to changing cp_non_overlap in tform
kadmin [Sat, 23 Jan 2021 08:57:04 +0000 (08:57 +0000)]
Switch to changing cp_non_overlap in tform

It was suggested to lower this in MIR instead of ssa, so do that instead.

3 years agoUpdate cranelift
kadmin [Tue, 29 Dec 2020 02:00:04 +0000 (02:00 +0000)]
Update cranelift

3 years agoUpdate match branches
kadmin [Mon, 5 Oct 2020 22:53:00 +0000 (22:53 +0000)]
Update match branches

This updates all places where match branches check on StatementKind or UseContext.
This doesn't properly implement them, but adds TODOs where they are, and also adds some best
guesses to what they should be in some cases.

3 years agoRollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov
Mara Bos [Tue, 9 Mar 2021 09:05:20 +0000 (09:05 +0000)]
Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov

or-patterns: disallow in `let` bindings

~~Blocked on https://github.com/rust-lang/rust/pull/81869~~

Disallows top-level or-patterns before type ascription. We want to reserve this syntactic space for possible future generalized type ascription.

r? ``@petrochenkov``

3 years agoclippy: fix or-pattern in let binding
mark [Mon, 8 Mar 2021 18:41:28 +0000 (12:41 -0600)]
clippy: fix or-pattern in let binding

3 years agoAuto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix
bors [Mon, 8 Mar 2021 08:39:24 +0000 (08:39 +0000)]
Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix

Test the effect of shrinking the size of Rvalue by 16 bytes

r? `@ghost`

3 years agoRollup merge of #82736 - spastorino:mir-opt-level-perf-changes, r=oli-obk
Guillaume Gomez [Fri, 5 Mar 2021 20:44:40 +0000 (21:44 +0100)]
Rollup merge of #82736 - spastorino:mir-opt-level-perf-changes, r=oli-obk

Bump optimization from mir_opt_level 2 to 3 and 3 to 4 and make "release" be level 2 by default

r? `@oli-obk`

3 years agoMake clippy set mir_opt_level using Option
Santiago Pastorino [Thu, 4 Mar 2021 02:33:18 +0000 (23:33 -0300)]
Make clippy set mir_opt_level using Option

3 years agoShrink the size of Rvalue by 16 bytes
Oli Scherer [Fri, 5 Mar 2021 09:32:47 +0000 (09:32 +0000)]
Shrink the size of Rvalue by 16 bytes

3 years agoFix borrow and deref
Ryan Levick [Tue, 16 Feb 2021 21:39:05 +0000 (22:39 +0100)]
Fix borrow and deref

3 years agoAllow noop_method_call in clippy ui test
Ryan Levick [Mon, 18 Jan 2021 13:15:19 +0000 (14:15 +0100)]
Allow noop_method_call in clippy ui test

3 years agoUse diagnostic items in into_iter_collections
Cameron Steffen [Sat, 27 Feb 2021 03:17:29 +0000 (21:17 -0600)]
Use diagnostic items in into_iter_collections

3 years agoAdd missing diagnostic item Symbols
Cameron Steffen [Sat, 27 Feb 2021 04:04:02 +0000 (22:04 -0600)]
Add missing diagnostic item Symbols

3 years agoFix Clippy build and test
flip1995 [Thu, 25 Feb 2021 10:25:45 +0000 (11:25 +0100)]
Fix Clippy build and test

3 years agoMerge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup
flip1995 [Thu, 25 Feb 2021 10:25:22 +0000 (11:25 +0100)]
Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup