]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #87162 - GuillaumeGomez:type-decl-overflow, r=notriddle
Guillaume Gomez [Fri, 16 Jul 2021 08:08:09 +0000 (10:08 +0200)]
Rollup merge of #87162 - GuillaumeGomez:type-decl-overflow, r=notriddle

Fix type decl layout "overflow"

Before:

![Screenshot from 2021-07-15 17-56-12](https://user-images.githubusercontent.com/3050060/125822644-c4595211-d75e-4dd7-ba44-183197ee836c.png)

After:

![Screenshot from 2021-07-15 17-56-17](https://user-images.githubusercontent.com/3050060/125822648-7b363847-e153-4ff3-9fba-59478e32eced.png)

cc ```@SergioBenitez```

r? ```@notriddle```

3 years agoRollup merge of #87161 - sexxi-goose:fix-issue-87097, r=nikomatsakis
Guillaume Gomez [Fri, 16 Jul 2021 08:08:08 +0000 (10:08 +0200)]
Rollup merge of #87161 - sexxi-goose:fix-issue-87097, r=nikomatsakis

RFC2229: Use the correct place type

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

The ICE occurred because instead of looking at the type of the place after all the projections are applied, we instead looked at the `base_ty` of the Place to decide whether a discriminant should be read of not. This lead to two issues:

1. the kind of the type is not necessarily `Adt` since we only look at the `base_ty`, it could be instead `Ref` for example
2. if the kind of the type is `Adt` you could still be looking at the wrong variant to make a decision on whether the discriminant should be read or not

r? `@nikomatsakis`

3 years agoRollup merge of #87145 - jsgf:fix-lint-opt-hash, r=michaelwoerister
Guillaume Gomez [Fri, 16 Jul 2021 08:08:07 +0000 (10:08 +0200)]
Rollup merge of #87145 - jsgf:fix-lint-opt-hash, r=michaelwoerister

Make --cap-lints and related options leave crate hash alone

Closes: #87144
3 years agoRollup merge of #87138 - dhwthompson:fix-range-invariant, r=JohnTitor
Guillaume Gomez [Fri, 16 Jul 2021 08:08:06 +0000 (10:08 +0200)]
Rollup merge of #87138 - dhwthompson:fix-range-invariant, r=JohnTitor

Correct invariant documentation for `steps_between`

Given that the previous example involves stepping forward from A to B, the equivalent example on this line would make most sense as stepping backward from B to A.

I should probably add a caveat here that I’m fairly new to Rust, and this is my first contribution to this repo, so it’s very possible that I’ve misunderstood how this is supposed to work (either on a technical level or a social one). If this is the case, please do let me know.

3 years agoRollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis
Guillaume Gomez [Fri, 16 Jul 2021 08:08:05 +0000 (10:08 +0200)]
Rollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis

ExprUseVisitor: Treat ByValue use of Copy types as ImmBorrow

r? ```@nikomatsakis```

3 years agoRollup merge of #86983 - wesleywiser:natvis_std_types, r=michaelwoerister
Guillaume Gomez [Fri, 16 Jul 2021 08:07:59 +0000 (10:07 +0200)]
Rollup merge of #86983 - wesleywiser:natvis_std_types, r=michaelwoerister

Add or improve natvis definitions for common standard library types

Natvis definitions are used by Windows debuggers to provide a better experience when inspecting a value for types with natvis definitions. Many of our standard library types and intrinsic Rust types like slices and `str` already have natvis definitions.

This PR adds natvis definitions for missing types (like all of the `Atomic*` types) and improves some of the existing ones (such as showing the ref count on `Arc<T>` and `Rc<T>` and showing the borrow state of `RefCell<T>`). I've also added cdb tests to cover these definitions and updated existing tests with the new visualizations.

With this PR, the following types now visualize in a much more intuitive way:

### Type: `NonZero{I,U}{8,16,32,64,128,size}`, `Atomic{I,U}{8,16,32,64,size}`, `AtomicBool` and `Wrapping<T>`

<details><summary>Example:</summary>

```rust
let a_u32 = AtomicU32::new(32i32);
```

```
0:000> dx a_u32
a_u32            : 32 [Type: core::sync::atomic::AtomicU32]
    [<Raw View>]     [Type: core::sync::atomic::AtomicU32]
```

</details>

### Type: `Cell<T>` and `UnsafeCell<T>`
<details><summary>Example:</summary>

```rust
let cell = Cell::new(123u8);
let unsafecell = UnsafeCell::new((42u16, 30u16));
```

```
0:000> dx cell
cell             : 123 [Type: core::cell::Cell<u8>]
    [<Raw View>]     [Type: core::cell::Cell<u8>]

0:000> dx unsafecell
unsafecell       : (42, 30) [Type: core::cell::UnsafeCell<tuple<u16, u16>>]
    [<Raw View>]     [Type: core::cell::UnsafeCell<tuple<u16, u16>>]
    [0]              : 42 [Type: unsigned short]
    [1]              : 30 [Type: unsigned short]
```

</details>

### Type: `RefCell<T>`

<details><summary>Example:</summary>

```rust
let refcell = RefCell::new((123u16, 456u32));
```

```
0:000> dx refcell
refcell          : (123, 456) [Type: core::cell::RefCell<tuple<u16, u32>>]
    [<Raw View>]     [Type: core::cell::RefCell<tuple<u16, u32>>]
    [Borrow state]   : Unborrowed
    [0]              : 123 [Type: unsigned short]
    [1]              : 456 [Type: unsigned int]
```

</details>

### Type: `NonNull<T>` and `Unique<T>`
<details><summary>Example:</summary>

```rust
let nonnull: NonNull<_> = (&(10, 20)).into();
```

```
0:000> dx nonnull
nonnull          : NonNull(0x7ff6a5d9c390: (10, 20)) [Type: core::ptr::non_null::NonNull<tuple<i32, i32>>]
    [<Raw View>]     [Type: core::ptr::non_null::NonNull<tuple<i32, i32>>]
    [0]              : 10 [Type: int]
    [1]              : 20 [Type: int]
```

</details>

### Type: `Range<T>`, `RangeFrom<T>`, `RangeInclusive<T>`, `RangeTo<T>` and `RangeToInclusive<T>`
<details><summary>Example:</summary>

```rust
let range = (1..12);
let rangefrom = (9..);
let rangeinclusive = (32..=80);
let rangeto = (..42);
let rangetoinclusive = (..=120);
```

```
0:000> dx range
range            : (1..12) [Type: core::ops::range::Range<i32>]
    [<Raw View>]     [Type: core::ops::range::Range<i32>]

0:000> dx rangefrom
rangefrom        : (9..) [Type: core::ops::range::RangeFrom<i32>]
    [<Raw View>]     [Type: core::ops::range::RangeFrom<i32>]

0:000> dx rangeinclusive
rangeinclusive   : (32..=80) [Type: core::ops::range::RangeInclusive<i32>]
    [<Raw View>]     [Type: core::ops::range::RangeInclusive<i32>]

0:000> dx rangeto
rangeto          : (..42) [Type: core::ops::range::RangeTo<i32>]
    [<Raw View>]     [Type: core::ops::range::RangeTo<i32>]

0:000> dx rangetoinclusive
rangetoinclusive : (..=120) [Type: core::ops::range::RangeToInclusive<i32>]
    [<Raw View>]     [Type: core::ops::range::RangeToInclusive<i32>]
```

</details>

### Type: `Duration`
<details><summary>Example:</summary>

```rust
let duration = Duration::new(5, 12);
```

```
0:000> dx duration
duration         : 5s 12ns [Type: core::time::Duration]
    [<Raw View>]     [Type: core::time::Duration]
    seconds          : 5 [Type: unsigned __int64]
    nanoseconds      : 12 [Type: unsigned int]
```

</details>

### Type: `ManuallyDrop<T>`
<details><summary>Example:</summary>

```rust
let manuallydrop = ManuallyDrop::new((123, 456));
```

```
0:000> dx manuallydrop
manuallydrop     : (123, 456) [Type: core::mem::manually_drop::ManuallyDrop<tuple<i32, i32>>]
    [<Raw View>]     [Type: core::mem::manually_drop::ManuallyDrop<tuple<i32, i32>>]
    [0]              : 123 [Type: int]
    [1]              : 456 [Type: int]
```

</details>

### Type: `Pin<T>`
<details><summary>Example:</summary>

```rust
let mut s = "this".to_string();
let pin = Pin::new(&mut s);
```

```
0:000> dx pin
pin              : Pin(0x11a0ff6f0: "this") [Type: core::pin::Pin<mut alloc::string::String*>]
    [<Raw View>]     [Type: core::pin::Pin<mut alloc::string::String*>]
    [len]            : 4 [Type: unsigned __int64]
    [capacity]       : 4 [Type: unsigned __int64]
    [chars]
```

</details>

### Type: `Rc<T>` and `Arc<T>`
<details><summary>Example:</summary>

```rust
let rc = Rc::new(42i8);
let rc_weak = Rc::downgrade(&rc);
```

```
0:000> dx rc
rc               : 42 [Type: alloc::rc::Rc<i8>]
    [<Raw View>]     [Type: alloc::rc::Rc<i8>]
    [Reference count] : 1 [Type: core::cell::Cell<usize>]

0:000> dx rc_weak
rc_weak          : 42 [Type: alloc::rc::Weak<i8>]
    [<Raw View>]     [Type: alloc::rc::Weak<i8>]
```

</details>

r? ```@michaelwoerister```
cc ```@nanguye2496```

3 years agoAuto merge of #87177 - ehuss:update-cargo, r=ehuss
bors [Fri, 16 Jul 2021 04:03:12 +0000 (04:03 +0000)]
Auto merge of #87177 - ehuss:update-cargo, r=ehuss

Update cargo

6 commits in 66a6737a0c9f3a974af2dd032a65d3e409c77aac..27277d966b3cfa454d6dea7f724cb961c036251c
2021-07-14 20:54:28 +0000 to 2021-07-16 00:50:39 +0000
- Flag another curl error as possibly spurious (rust-lang/cargo#9695)
- Add `d` as an alias for `doc` (rust-lang/cargo#9680)
- `cargo fix --edition`: extend warning when on latest edition (rust-lang/cargo#9694)
- Update env_logger requirement from 0.8.1 to 0.9.0 (rust-lang/cargo#9688)
- Document cargo limitation w/ workspaces & configs (rust-lang/cargo#9674)
- Change some warnings to errors (rust-lang/cargo#9689)

3 years agoUpdate cargo
Eric Huss [Fri, 16 Jul 2021 02:27:11 +0000 (19:27 -0700)]
Update cargo

3 years agoAuto merge of #86993 - jackh726:project-gat-binders, r=nikomatsakis
bors [Fri, 16 Jul 2021 01:11:37 +0000 (01:11 +0000)]
Auto merge of #86993 - jackh726:project-gat-binders, r=nikomatsakis

Replace associated item bound vars with placeholders when projecting

Fixes #76407
Fixes #76826

Similar, but more limited, to #85499. This allows us to handle things like `for<'a> <T as Trait>::Assoc<'a>` but not `for<'a> <T as Trait<'a>>::Assoc`, unblocking GATs.

r? `@nikomatsakis`

3 years agoAuto merge of #83319 - tmiasko:packed-aligned, r=jackh726
bors [Thu, 15 Jul 2021 19:51:17 +0000 (19:51 +0000)]
Auto merge of #83319 - tmiasko:packed-aligned, r=jackh726

Layout error instead of an ICE for packed and aligned types

Fixes #83107.

3 years agoAuto merge of #87152 - flip1995:clippyup, r=Manishearth
bors [Thu, 15 Jul 2021 17:10:09 +0000 (17:10 +0000)]
Auto merge of #87152 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

3 years agoAdd regression test for type declaration layout overflow
Guillaume Gomez [Thu, 15 Jul 2021 16:19:25 +0000 (18:19 +0200)]
Add regression test for type declaration layout overflow

3 years agoFix layout overflow in type declaration
Guillaume Gomez [Thu, 15 Jul 2021 16:19:07 +0000 (18:19 +0200)]
Fix layout overflow in type declaration

3 years agoLayout error instead of an ICE for packed and aligned types
Tomasz Miąsko [Sat, 20 Mar 2021 00:00:00 +0000 (00:00 +0000)]
Layout error instead of an ICE for packed and aligned types

3 years agoRemove failed and review comments
jackh726 [Thu, 15 Jul 2021 14:41:35 +0000 (10:41 -0400)]
Remove failed and review comments

3 years agoGet the right place type
Roxane [Thu, 15 Jul 2021 14:33:51 +0000 (10:33 -0400)]
Get the right place type

3 years agoAuto merge of #87156 - JohnTitor:rollup-osuhe53, r=JohnTitor
bors [Thu, 15 Jul 2021 14:29:07 +0000 (14:29 +0000)]
Auto merge of #87156 - JohnTitor:rollup-osuhe53, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #85579 (Added Arc::try_pin)
 - #86478 (Add -Zfuture-incompat-test to assist with testing future-incompat reports.)
 - #86947 (Move assert_matches to an inner module)
 - #87081 (Add tracking issue number to `wasi_ext`)
 - #87127 (Add safety comments in private core::slice::rotate::ptr_rotate function)
 - #87134 (Make SelfInTyParamDefault wording not be specific to type defaults)
 - #87147 (Update cargo)
 - #87154 (Fix misuse of rev attribute on <a> tag)

Failed merges:

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

3 years agoRollup merge of #87154 - GuillaumeGomez:rev-attr-a, r=JohnTitor
Yuki Okushi [Thu, 15 Jul 2021 12:19:22 +0000 (21:19 +0900)]
Rollup merge of #87154 - GuillaumeGomez:rev-attr-a, r=JohnTitor

Fix misuse of rev attribute on <a> tag

The `rev` attribute is supposed to talk about "ownership" as far as I could found out. This attribute seems not very well defined in the HTML spec and its usage in rustdoc is suboptimal.

It was found out in https://github.com/rust-lang/rust/pull/87149.

r? `@JohnTitor`

3 years agoRollup merge of #87147 - ehuss:update-cargo, r=ehuss
Yuki Okushi [Thu, 15 Jul 2021 12:19:21 +0000 (21:19 +0900)]
Rollup merge of #87147 - ehuss:update-cargo, r=ehuss

Update cargo

13 commits in 3ebb5f15a940810f250b68821149387af583a79e..66a6737a0c9f3a974af2dd032a65d3e409c77aac
2021-07-02 20:35:38 +0000 to 2021-07-14 20:54:28 +0000
- Add format option to `cargo tree` to print the lib_name (rust-lang/cargo#9663)
- Prefer patched versions of dependencies (rust-lang/cargo#9639)
- When a dependency does not have a version, git or path, fails directly (rust-lang/cargo#9686)
- Spot the crate typo easily (rust-lang/cargo#9665)
- remove unnecessary 'collect' (rust-lang/cargo#9616)
- Make it easier to run testsuite with a custom toolchain. (rust-lang/cargo#9679)
- Serialize `cargo fix` (rust-lang/cargo#9677)
- Don't recommend filing issues on rust-lang/cargo for Cargo.toml errors. (rust-lang/cargo#9658)
- Update nightly failure notification. (rust-lang/cargo#9657)
- Update Windows env uppercase key check. (rust-lang/cargo#9654)
- Unignore fix_edition_2021. (rust-lang/cargo#9662)
- Warning when using features in patch (rust-lang/cargo#9666)
- Unify cargo and rustc's error reporting (rust-lang/cargo#9655)

3 years agoRollup merge of #87134 - BoxyUwU:cgd-self-ty-error, r=lcnr
Yuki Okushi [Thu, 15 Jul 2021 12:19:20 +0000 (21:19 +0900)]
Rollup merge of #87134 - BoxyUwU:cgd-self-ty-error, r=lcnr

Make SelfInTyParamDefault wording not be specific to type defaults

r? ```@lcnr```

3 years agoRollup merge of #87127 - poliorcetics:ptr-rotate-safety, r=scottmcm
Yuki Okushi [Thu, 15 Jul 2021 12:19:19 +0000 (21:19 +0900)]
Rollup merge of #87127 - poliorcetics:ptr-rotate-safety, r=scottmcm

Add safety comments in private core::slice::rotate::ptr_rotate function

Helps with #66219.

```@rustbot``` label C-cleanup T-compiler T-libs

3 years agoRollup merge of #87081 - a1phyr:add_wasi_ext_tracking_issue, r=dtolnay
Yuki Okushi [Thu, 15 Jul 2021 12:19:18 +0000 (21:19 +0900)]
Rollup merge of #87081 - a1phyr:add_wasi_ext_tracking_issue, r=dtolnay

Add tracking issue number to `wasi_ext`

Feature `wasi_ext` is tracked by #71213 but is was not in the source code.

3 years agoRollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahc
Yuki Okushi [Thu, 15 Jul 2021 12:19:16 +0000 (21:19 +0900)]
Rollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahc

Move assert_matches to an inner module

Fixes #82913

3 years agoRollup merge of #86478 - ehuss:future-incompat-test, r=oli-obk
Yuki Okushi [Thu, 15 Jul 2021 12:19:11 +0000 (21:19 +0900)]
Rollup merge of #86478 - ehuss:future-incompat-test, r=oli-obk

Add -Zfuture-incompat-test to assist with testing future-incompat reports.

This adds a `-Zfuture-incompat-test` cli flag to assist with testing future-incompatible reports. This flag causes all lints to be treated as a future-incompatible lint, and will emit a report for them. This is being added so that Cargo's testsuite can reliably test the reporting infrastructure.  Right now, Cargo relies on using array_into_iter as a test subject. Since the breaking "future incompatible" lints are never intended to last forever, this means Cargo's testsuite would always need to keep changing to choose different lints (for example, #86330 proposed dropping that moniker for array_into_iter). With this flag, Cargo's tests can trigger any lint and check for the report.

3 years agoRollup merge of #85579 - alex:patch-1, r=yaahc
Yuki Okushi [Thu, 15 Jul 2021 12:19:10 +0000 (21:19 +0900)]
Rollup merge of #85579 - alex:patch-1, r=yaahc

Added Arc::try_pin

This helper is in line with other other allocation helpers on Arc.

I didn't think this would require an RFC or broader discussion, let me know if that's incorrect.

3 years agoAdded Arc::try_pin
Alex Gaynor [Sat, 22 May 2021 14:24:50 +0000 (10:24 -0400)]
Added Arc::try_pin

This helper is in line with other other allocation helpers on Arc.

3 years agoFix misuse of rev attribute on <a> tag
Guillaume Gomez [Thu, 15 Jul 2021 11:05:15 +0000 (13:05 +0200)]
Fix misuse of rev attribute on <a> tag

3 years agoMerge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup
flip1995 [Thu, 15 Jul 2021 08:44:10 +0000 (10:44 +0200)]
Merge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup

3 years agoAuto merge of #7468 - flip1995:rustup, r=flip1995
bors [Thu, 15 Jul 2021 08:37:36 +0000 (08:37 +0000)]
Auto merge of #7468 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoBump nightly version -> 2021-07-15
flip1995 [Thu, 15 Jul 2021 08:32:21 +0000 (10:32 +0200)]
Bump nightly version -> 2021-07-15

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 15 Jul 2021 08:21:01 +0000 (10:21 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoUpdate compiler/rustc_typeck/src/expr_use_visitor.rs
Niko Matsakis [Thu, 15 Jul 2021 08:13:20 +0000 (04:13 -0400)]
Update compiler/rustc_typeck/src/expr_use_visitor.rs

3 years agoPR feedback
Aman Arora [Thu, 15 Jul 2021 04:54:18 +0000 (00:54 -0400)]
PR feedback

3 years agoAuto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995
bors [Thu, 15 Jul 2021 07:20:37 +0000 (07:20 +0000)]
Auto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995

add Arc to `redundant_allocation`

 fixes #7303
changelog:  add Arc to `redundant_allocation`

3 years agoUpdate cargo
Eric Huss [Thu, 15 Jul 2021 02:56:42 +0000 (19:56 -0700)]
Update cargo

3 years agoAuto merge of #86876 - jyn514:56935-target-crate-num, r=petrochenkov
bors [Thu, 15 Jul 2021 02:39:38 +0000 (02:39 +0000)]
Auto merge of #86876 - jyn514:56935-target-crate-num, r=petrochenkov

Reuse CrateNum for proc-macro crates even when cross-compiling

Proc-macros are always compiled for the host, so this should be the same
in every way as recompiling the crate.

I am not sure why the previous code special-cased the target, since the
compiler properly gives an error when trying to load a crate for a
different host:

```
error[E0461]: couldn't find crate `dependency` with expected target triple x86_64-unknown-linux-gnu
  --> /home/joshua/rustc4/src/test/ui/cfg-dependent.rs:8:2
   |
LL |     dependency::is_64();
   |     ^^^^^^^^^^
   |
   = note: the following crate versions were found:
           crate `dependency`, target triple i686-unknown-linux-gnu: /home/joshua/rustc4/build/x86_64-unknown-linux-gnu/test/ui/cfg-dependent/auxiliary/libdependency.so
```

I think another possible fix is to remove the check altogether. But I'm
not sure, and this fix works, so I'm not making the larger change here.

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

r? `@petrochenkov` cc `@alexcrichton`

3 years agoReuse CrateNum for proc-macro crates even when cross-compiling
Joshua Nelson [Sun, 4 Jul 2021 03:35:24 +0000 (23:35 -0400)]
Reuse CrateNum for proc-macro crates even when cross-compiling

Proc-macros are always compiled for the host, so this should be the same
in every way as recompiling the crate.

I am not sure why the previous code special-cased the target, since the
compiler properly gives an error when trying to load a crate for a
different host:

```
error[E0461]: couldn't find crate `dependency` with expected target triple x86_64-unknown-linux-gnu
  --> /home/joshua/rustc4/src/test/ui/cfg-dependent.rs:8:2
   |
LL |     dependency::is_64();
   |     ^^^^^^^^^^
   |
   = note: the following crate versions were found:
           crate `dependency`, target triple i686-unknown-linux-gnu: /home/joshua/rustc4/build/x86_64-unknown-linux-gnu/test/ui/cfg-dependent/auxiliary/libdependency.so
```

I think another possible fix is to remove the check altogether. But I'm
not sure, and this fix works, so I'm not making the larger change here.

3 years agoMake --cap-lints and related options leave crate hash alone
Jeremy Fitzhardinge [Wed, 14 Jul 2021 23:39:17 +0000 (16:39 -0700)]
Make --cap-lints and related options leave crate hash alone

Closes: #87144
3 years agoAuto merge of #87137 - richkadel:compiler-builtins-0.1.47, r=tmandry
bors [Wed, 14 Jul 2021 23:58:43 +0000 (23:58 +0000)]
Auto merge of #87137 - richkadel:compiler-builtins-0.1.47, r=tmandry

Update compiler-builtins to 0.1.47

  Bumped to `0.1.47` to resolve missing symbols on `aarch` when linking
  `cargo`. This was due to a recent change in a `cargo` dependency on
  `curl` (upstream C library added code that uses the uncommon `long
  double` type).

r? `@tmandry`

3 years agoredundant_allocation: add Arc; some refractoring.
lyj [Wed, 2 Jun 2021 05:41:52 +0000 (13:41 +0800)]
redundant_allocation: add Arc; some refractoring.

3 years agoAuto merge of #86765 - cuviper:fuse-less-specialized, r=joshtriplett
bors [Wed, 14 Jul 2021 21:17:52 +0000 (21:17 +0000)]
Auto merge of #86765 - cuviper:fuse-less-specialized, r=joshtriplett

Make the specialized Fuse still deal with None

Fixes #85863 by removing the assumption that we'll never see a cleared iterator in the `I: FusedIterator` specialization. Now all `Fuse` methods check for the possibility that `self.iter` is `None`, and the specialization only avoids _setting_ that to `None` in `&mut self` methods.

3 years agoFix tests for i686
Wesley Wiser [Wed, 14 Jul 2021 20:50:11 +0000 (16:50 -0400)]
Fix tests for i686

3 years agoCorrect invariant documentation for `steps_between`
David Thompson [Wed, 14 Jul 2021 20:48:18 +0000 (13:48 -0700)]
Correct invariant documentation for `steps_between`

Given that the previous example involves stepping forward from A to B,
the equivalent example on this line would make most sense as stepping
backward from B to A.

3 years agoUpdate compiler-builtins to 0.1.47
Rich Kadel [Wed, 14 Jul 2021 20:45:16 +0000 (13:45 -0700)]
Update compiler-builtins to 0.1.47

  Bumped to `0.1.47` to resolve missing symbols on `aarch` when linking
  `cargo`. This was due to a recent change in a `cargo` dependency on
  `curl` (upstream C library added code that uses the uncommon `long
  double` type).

3 years agoAuto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen
bors [Wed, 14 Jul 2021 20:29:56 +0000 (20:29 +0000)]
Auto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen

FP fix and documentation for `branches_sharing_code` lint

Closes rust-lang/rust-clippy#7369

Related rust-lang/rust-clippy#7452 I'm still thinking about the best way to fix this. I could simply add another visitor to ensure that the moved expressions don't modify values being used in the condition, but I'm not totally happy with this due to the complexity. I therefore only documented it for now

changelog: [`branches_sharing_code`] fixed false positive where block expressions would sometimes be ignored.

3 years agoFixed `branches_sharing_code` FP with block expressions in else
xFrednet [Tue, 13 Jul 2021 21:27:19 +0000 (23:27 +0200)]
Fixed `branches_sharing_code` FP with block expressions in else

And added `branches_sharing_code` PF note to lint doc for `rust-clippy#7452`

3 years agoOOPS
Ellen [Wed, 14 Jul 2021 18:38:58 +0000 (19:38 +0100)]
OOPS

3 years agoAuto merge of #87133 - GuillaumeGomez:rollup-pfz9jbk, r=GuillaumeGomez
bors [Wed, 14 Jul 2021 18:36:44 +0000 (18:36 +0000)]
Auto merge of #87133 - GuillaumeGomez:rollup-pfz9jbk, r=GuillaumeGomez

Rollup of 6 pull requests

Successful merges:

 - #87027 (expand: Support helper attributes for built-in derive macros)
 - #87056 (Fix codeblocks overflow)
 - #87117 (Shrink the CrateStore dynamic interface.)
 - #87120 (rustdoc: Remove unnecessary `extern crate` aliases)
 - #87125 (Fix Ayu theme `<code>` color)
 - #87130 (Update browser-ui-test package version)

Failed merges:

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

3 years agoChange type param -> generic param
Ellen [Wed, 14 Jul 2021 18:22:32 +0000 (19:22 +0100)]
Change type param -> generic param

3 years agoRollup merge of #87130 - GuillaumeGomez:update-browser-ui-test, r=Mark-Simulacrum
Guillaume Gomez [Wed, 14 Jul 2021 17:53:41 +0000 (19:53 +0200)]
Rollup merge of #87130 - GuillaumeGomez:update-browser-ui-test, r=Mark-Simulacrum

Update browser-ui-test package version

It adds a check to prevent to have empty CSS values in `assert-css` command.

r? `@Mark-Simulacrum`

3 years agoRollup merge of #87125 - GuillaumeGomez:ayu-code-color, r=notriddle
Guillaume Gomez [Wed, 14 Jul 2021 17:53:40 +0000 (19:53 +0200)]
Rollup merge of #87125 - GuillaumeGomez:ayu-code-color, r=notriddle

Fix Ayu theme <code> color

Fixes #87072 (the second regression).

r? `@notriddle`

3 years agoRollup merge of #87120 - jyn514:rustdoc-cleanup, r=CraftSpider
Guillaume Gomez [Wed, 14 Jul 2021 17:53:38 +0000 (19:53 +0200)]
Rollup merge of #87120 - jyn514:rustdoc-cleanup, r=CraftSpider

rustdoc: Remove unnecessary `extern crate` aliases

3 years agoRollup merge of #87117 - cjgillot:cstore, r=petrochenkov
Guillaume Gomez [Wed, 14 Jul 2021 17:53:37 +0000 (19:53 +0200)]
Rollup merge of #87117 - cjgillot:cstore, r=petrochenkov

Shrink the CrateStore dynamic interface.

The information is either accessible through queries or by crates which already depend on rustc_metadata.

3 years agoRollup merge of #87056 - GuillaumeGomez:fix-codeblocks-overflow, r=notriddle
Guillaume Gomez [Wed, 14 Jul 2021 17:53:36 +0000 (19:53 +0200)]
Rollup merge of #87056 - GuillaumeGomez:fix-codeblocks-overflow, r=notriddle

Fix codeblocks overflow

Fixes #87043.

Instead of completely relying on `pulldown-cmark` (and its potential changes), I decided to move the generation of codeblocks HTML directly in rustdoc so we can unify the DOM and the CSS classes.

r? `@Nemo157`

3 years agoRollup merge of #87027 - petrochenkov:builderhelp, r=oli-obk
Guillaume Gomez [Wed, 14 Jul 2021 17:53:35 +0000 (19:53 +0200)]
Rollup merge of #87027 - petrochenkov:builderhelp, r=oli-obk

expand: Support helper attributes for built-in derive macros

This is needed for https://github.com/rust-lang/rust/pull/86735 (derive macro `Default` should have a helper attribute `default`).

With this PR we can specify helper attributes for built-in derives using syntax `#[rustc_builtin_macro(MacroName, attributes(attr1, attr2, ...))]` which mirrors equivalent syntax for proc macros `#[proc_macro_derive(MacroName, attributes(attr1, attr2, ...))]`.
Otherwise expansion infra was already ready for this.
The attribute parsing code is shared between proc macro derives and built-in macros (`fn parse_macro_name_and_helper_attrs`).

3 years agoAdd -Zfuture-incompat-test to assist with testing future-incompat reports.
Eric Huss [Sun, 20 Jun 2021 00:06:46 +0000 (17:06 -0700)]
Add -Zfuture-incompat-test to assist with testing future-incompat reports.

3 years agoAuto merge of #87082 - michaelwoerister:const-in-debuginfo-type-names-fix, r=oli...
bors [Wed, 14 Jul 2021 15:18:27 +0000 (15:18 +0000)]
Auto merge of #87082 - michaelwoerister:const-in-debuginfo-type-names-fix, r=oli-obk,wesleywiser

Handle non-integer const generic parameters in debuginfo type names.

This PR fixes an ICE introduced by https://github.com/rust-lang/rust/pull/85269 which started emitting const generic arguments for debuginfo names but did not cover the case where such an argument could not be evaluated to a flat string of bits.

The fix implemented in this PR is very basic: If `try_eval_bits()` fails for the constant in question, we fall back to generating a stable hash of the constant and emit that instead. This way we get a (virtually) unique name and side step the problem of generating a string representation of a potentially complex value.

The downside is that the generated name will be rather opaque. E.g. the regression test adds a function `const_generic_fn_non_int<()>` which is then rendered as `const_generic_fn_non_int<{CONST#fe3cfa0214ac55c7}>`. I think it's an open question how to deal with this more gracefully.

I'd be interested in ideas on how to do this better.

r? `@wesleywiser`

cc `@dpaoliello` (do you see any problems with this approach?)
cc `@Mark-Simulacrum` & `@nagisa` (who I've seen comment on debuginfo issues recently -- anyone else?)

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

3 years agoAuto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995
bors [Wed, 14 Jul 2021 15:15:28 +0000 (15:15 +0000)]
Auto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995

suggest `&mut` for redundant FnMut closures

fixes #6903

changelog: suggest `&mut` for redundant FnMut closures

3 years agosuggest `&mut` for redundant FnMut closures
Elliot Bobrow [Sat, 3 Jul 2021 03:25:55 +0000 (20:25 -0700)]
suggest `&mut` for redundant FnMut closures

3 years agoShrink the CrateStore dynamic interface.
Camille GILLOT [Mon, 12 Jul 2021 19:20:16 +0000 (21:20 +0200)]
Shrink the CrateStore dynamic interface.

3 years agoUpdate browser-ui-test package version
Guillaume Gomez [Wed, 14 Jul 2021 14:28:15 +0000 (16:28 +0200)]
Update browser-ui-test package version

3 years agoHandle non-integer const generic parameters in debuginfo type names.
Michael Woerister [Mon, 12 Jul 2021 13:12:49 +0000 (15:12 +0200)]
Handle non-integer const generic parameters in debuginfo type names.

3 years agoAdd safety comments in private core::slice::rotate::ptr_rotate function
Alexis Bourget [Wed, 14 Jul 2021 13:31:12 +0000 (15:31 +0200)]
Add safety comments in private core::slice::rotate::ptr_rotate function

3 years agoAdd GUI test to check ayu <code> colors
Guillaume Gomez [Wed, 14 Jul 2021 13:00:12 +0000 (15:00 +0200)]
Add GUI test to check ayu <code> colors

3 years agoAuto merge of #87118 - JohnTitor:rollup-8ltidsq, r=JohnTitor
bors [Wed, 14 Jul 2021 12:49:45 +0000 (12:49 +0000)]
Auto merge of #87118 - JohnTitor:rollup-8ltidsq, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #87085 (Search result colors)
 - #87090 (Make BTreeSet::split_off name elements like other set methods do)
 - #87098 (Unignore some pretty printing tests)
 - #87099 (Upgrade `cc` crate to 1.0.69)
 - #87101 (Suggest a path separator if a stray colon is found in a match arm)
 - #87102 (Add GUI test for "go to first" feature)

Failed merges:

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

3 years agoFix color for <code> which are not in doc blocks
Guillaume Gomez [Wed, 14 Jul 2021 12:47:54 +0000 (14:47 +0200)]
Fix color for <code> which are not in doc blocks

3 years agoAuto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk
bors [Wed, 14 Jul 2021 10:10:14 +0000 (10:10 +0000)]
Auto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk

fix 5707

changelog: ``[`redundant_clone`]``, fix #5707

# Root problem of #5707 :
```
&2:&mut HashMap = &mut _4;
&3:&str = & _5;
_1 = HashMap::insert(move _2,move _3, _);
```

generate PossibleBorrower(_2,_1) and PossibleBorrower(_3,_1).

However, it misses PossibleBorrower(_3,_2).

# My solution to #5707 :

When meet a function call, we should:
1. build PossibleBorrower between borrow parameters and return value (currently)
2. build PossibleBorrower between immutable borrow parameters and mutable borrow parameters (*add*)
3. build PossibleBorrower inside mutable borrow parameters (*add*)

For example:
```
_2: &mut _22;
_3: &mut _;
_4: & _;
_5: & _;
_1 = call(move _2, move _3, move _4, move _5);
```
we need to build
1. return value with parameter(current implementataion)
 PossibleBorrower(_2,_1)
 PossibleBorrower(_3,_1)
 PossibleBorrower(_4,_1)
 PossibleBorrower(_5,_1)

2. between mutable borrow and immutable borrow
PossibleBorrower(_4,_2)
PossibleBorrower(_5,_2)
PossibleBorrower(_4,_3)
PossibleBorrower(_5,_3)

3. between mutable borrow and mutable borrow
PossibleBorrower(_3,_2)
PossibleBorrower(_2,_3)

  But that's not enough.
 Modification to _2 actually apply to _22.
  So I write a `PossibleBorrowed` visitor, which tracks (borrower => possible borrowed) relation.
  For example (_2 => _22).
  However, a lot of problems exist here.

## Known Problems:
  1. not sure all `&mut`'s origin are collected.
  I'm not sure how to deal with `&mut` when meet a function call, so I didn't do it currently.
  Also, my implement is not flow sensitive, so it's not accurate.

```
foo(_2:&mut _, _3: &_)
```
This pr doesn't count _3 as origin of _2.

 2. introduce false negative
`foo(_2, _3)` will  emit PossibleBorrower(_3,_2) in this pr, but _3 and _2 may not have relation.
Clippy may feel that _3 is still in use because of _2, but actually, _3 is on longer needed and can be moved.

## Insight
  The key problem is determine where every `&mut` come from accurately.
  I think Polonius is an elegant solution to it. Polonius is flow sensitive and accurate.
  But I'm uncertain about whether we can import Polonius in rust-clippy currently.
  This pr actually is part of Polonius' functionality, I think.

# TODO
1. `cargo test` can't pass yet due to similar variable name

3 years agoAdd test for codeblocks overflow
Guillaume Gomez [Sun, 11 Jul 2021 11:06:48 +0000 (13:06 +0200)]
Add test for codeblocks overflow

3 years agoFix display for non-rust code blocks
Guillaume Gomez [Sun, 11 Jul 2021 10:40:31 +0000 (12:40 +0200)]
Fix display for non-rust code blocks

3 years agoExprUseVisitor::Delegate consume only when moving
Aman Arora [Wed, 14 Jul 2021 06:21:08 +0000 (02:21 -0400)]
ExprUseVisitor::Delegate consume only when moving

3 years agoAdd test for copy type in move closure
Aman Arora [Wed, 14 Jul 2021 04:27:39 +0000 (00:27 -0400)]
Add test for copy type in move closure

3 years agorename possible_borrowed to possible_origin; pass dogfood
lyj [Wed, 14 Jul 2021 03:29:39 +0000 (11:29 +0800)]
rename possible_borrowed to possible_origin; pass dogfood

3 years agoAuto merge of #86211 - tlyu:option-result-overviews, r=joshtriplett
bors [Wed, 14 Jul 2021 05:10:57 +0000 (05:10 +0000)]
Auto merge of #86211 - tlyu:option-result-overviews, r=joshtriplett

create method overview docs for core::option and core::result

The `Option` and `Result` types have large lists of methods. They each could use an overview page of methods grouped by category. These proposed overviews include "truth tables" for the underappreciated boolean operators/combinators of these types. The methods are already somewhat categorized in the source, but some logical groupings are broken up by the necessities of putting related methods in different `impl` blocks, for example.

This is based on #86209, but those are small changes and unlikely to conflict.

3 years agoRemove useless alias from `rustc_span` to itself
Joshua Nelson [Wed, 14 Jul 2021 01:41:05 +0000 (21:41 -0400)]
Remove useless alias from `rustc_span` to itself

3 years agoRemove renaming of `test` crate
Joshua Nelson [Wed, 14 Jul 2021 01:40:09 +0000 (21:40 -0400)]
Remove renaming of `test` crate

This is leftover from when `doctest` used to be called `test`. Remove it
now, it's unnecessary and makes the code harder to read.

3 years agofix 5707
lyj [Fri, 11 Jun 2021 12:57:11 +0000 (20:57 +0800)]
fix 5707

3 years agoAuto merge of #87106 - Mark-Simulacrum:edition-no-clone, r=petrochenkov
bors [Wed, 14 Jul 2021 01:41:12 +0000 (01:41 +0000)]
Auto merge of #87106 - Mark-Simulacrum:edition-no-clone, r=petrochenkov

Avoid cloning ExpnData to access Span edition

ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In
some cases this may get optimized out, but it's not clear that will always be
the case. Try to avoid that cost.

r? `@ghost` -- opening for a perf run to start with

3 years agoRollup merge of #87102 - GuillaumeGomez:go-to-first-feature, r=Manisheart,notriddle
Yuki Okushi [Wed, 14 Jul 2021 00:35:27 +0000 (09:35 +0900)]
Rollup merge of #87102 - GuillaumeGomez:go-to-first-feature, r=Manisheart,notriddle

Add GUI test for "go to first" feature

It adds a test for #85876 to ensure the feature is working as expected and prevent potential regression.

cc ```@jeanlucthumm```

r? ```@Manishearth```

3 years agoRollup merge of #87101 - FabianWolff:issue-87086, r=estebank
Yuki Okushi [Wed, 14 Jul 2021 00:35:26 +0000 (09:35 +0900)]
Rollup merge of #87101 - FabianWolff:issue-87086, r=estebank

Suggest a path separator if a stray colon is found in a match arm

Attempts to fix #87086.

r? `@estebank`

3 years agoRollup merge of #87099 - JohnTitor:upgrade-cc-crate, r=alexcrichton
Yuki Okushi [Wed, 14 Jul 2021 00:35:25 +0000 (09:35 +0900)]
Rollup merge of #87099 - JohnTitor:upgrade-cc-crate, r=alexcrichton

Upgrade `cc` crate to 1.0.69

This pulls another fix for #83043, i.e., alexcrichton/cc-rs#605.
r? ``@alexcrichton``

3 years agoRollup merge of #87098 - JohnTitor:unignore-some-tests, r=petrochenkov
Yuki Okushi [Wed, 14 Jul 2021 00:35:23 +0000 (09:35 +0900)]
Rollup merge of #87098 - JohnTitor:unignore-some-tests, r=petrochenkov

Unignore some pretty printing tests

Closes #37201
r? ````@petrochenkov````

3 years agoRollup merge of #87090 - ssomers:btree_comments, r=the8472
Yuki Okushi [Wed, 14 Jul 2021 00:35:22 +0000 (09:35 +0900)]
Rollup merge of #87090 - ssomers:btree_comments, r=the8472

Make BTreeSet::split_off name elements like other set methods do

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

3 years agoRollup merge of #87085 - GuillaumeGomez:search-result-colors, r=notriddle
Yuki Okushi [Wed, 14 Jul 2021 00:35:22 +0000 (09:35 +0900)]
Rollup merge of #87085 - GuillaumeGomez:search-result-colors, r=notriddle

Search result colors

Part of  #87072 (fixes the first and fourth regressions and add tests to prevent it from happening again).

cc ````@Nemo157````

r? ````@camelid````

3 years agoSuggest a path separator if a stray colon is found in a match arm
Fabian Wolff [Tue, 13 Jul 2021 11:18:03 +0000 (13:18 +0200)]
Suggest a path separator if a stray colon is found in a match arm

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
3 years agoAuto merge of #87044 - cjgillot:expnhash, r=petrochenkov
bors [Tue, 13 Jul 2021 22:32:58 +0000 (22:32 +0000)]
Auto merge of #87044 - cjgillot:expnhash, r=petrochenkov

Cache expansion hash globally

... instead of computing it multiple times.

Split from #86676
r? `@petrochenkov`

3 years agoCache expansion hash.
Camille GILLOT [Tue, 22 Jun 2021 17:20:25 +0000 (19:20 +0200)]
Cache expansion hash.

3 years agoMove HashStable implementations.
Camille GILLOT [Tue, 22 Jun 2021 17:16:18 +0000 (19:16 +0200)]
Move HashStable implementations.

3 years agoConditionally call normalize_erasing_regions only if polymorhization is enabled
jackh726 [Tue, 13 Jul 2021 19:09:01 +0000 (15:09 -0400)]
Conditionally call normalize_erasing_regions only if polymorhization is enabled

3 years agoexpand: Support helper attributes for built-in derive macros
Vadim Petrochenkov [Sat, 10 Jul 2021 14:16:53 +0000 (17:16 +0300)]
expand: Support helper attributes for built-in derive macros

3 years agoAdd test for "go to first" feature
Guillaume Gomez [Tue, 13 Jul 2021 12:41:19 +0000 (14:41 +0200)]
Add test for "go to first" feature

3 years agoAuto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk
bors [Tue, 13 Jul 2021 15:06:10 +0000 (15:06 +0000)]
Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk

Fix internal `default_hash_types` lint to use resolved path

I run into false positives now and then (mostly in Clippy) when I want to name some util after HashMap.

3 years agoAuto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk
bors [Tue, 13 Jul 2021 15:06:10 +0000 (15:06 +0000)]
Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk

Fix internal `default_hash_types` lint to use resolved path

I run into false positives now and then (mostly in Clippy) when I want to name some util after HashMap.

3 years agoAvoid cloning ExpnData to access Span edition
Mark Rousskov [Tue, 13 Jul 2021 14:57:10 +0000 (10:57 -0400)]
Avoid cloning ExpnData to access Span edition

ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In
some cases this may get optimized out, but it's not clear that will always be
the case. Try to avoid that cost.

3 years agoWIP partial apply fix
jackh726 [Tue, 13 Jul 2021 14:50:40 +0000 (10:50 -0400)]
WIP partial apply fix

3 years agoAuto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995
bors [Tue, 13 Jul 2021 14:31:02 +0000 (14:31 +0000)]
Auto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995

`default_numeric_fallback`: Fix FP with floating literal

Fix #7445

changelog: `default_numeric_fallback`: Fix FP with floating literal

3 years ago`default_numeric_fallback`: Add rustfix tests
Yoshitomo Nakanishi [Tue, 13 Jul 2021 13:57:47 +0000 (22:57 +0900)]
`default_numeric_fallback`: Add rustfix tests

3 years agoAuto merge of #7442 - camsteffen:format-args, r=xFrednet
bors [Tue, 13 Jul 2021 13:58:38 +0000 (13:58 +0000)]
Auto merge of #7442 - camsteffen:format-args, r=xFrednet

Refactor `format_args!` expansion parsing

Introduces `FormatExpn::parse` and `FormatArgsExpn::parse`. Motivated by rust-lang/rust#83302, so I only have to change Clippy in one place. Fixed an FP along the way.

I also allowed `needless_bool` in macros because I often want to do `if_chain! { .. then { true } else { false } }`.

changelog: Fix false positive in `useless_format` when some text is appended or prepended to a single string with some useless formatting params
changelog: Allow `needless_bool` in macros

3 years agoSplit a lint message into help
Cameron Steffen [Mon, 12 Jul 2021 01:30:19 +0000 (20:30 -0500)]
Split a lint message into help

3 years agoReduce redundant code
Cameron Steffen [Mon, 12 Jul 2021 01:21:21 +0000 (20:21 -0500)]
Reduce redundant code

3 years agoRefactor format macro parsing
Cameron Steffen [Tue, 6 Jul 2021 16:51:15 +0000 (11:51 -0500)]
Refactor format macro parsing