Commit graph

151683 commits

Author SHA1 Message Date
Guillaume Gomez
41433795e7
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`
2021-07-16 10:08:08 +02:00
Guillaume Gomez
c1b9bbf1e7
Rollup merge of #87145 - jsgf:fix-lint-opt-hash, r=michaelwoerister
Make --cap-lints and related options leave crate hash alone

Closes: #87144
2021-07-16 10:08:07 +02:00
Guillaume Gomez
36de8778fc
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.
2021-07-16 10:08:06 +02:00
Guillaume Gomez
c1ffca0869
Rollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis
ExprUseVisitor: Treat ByValue use of Copy types as ImmBorrow

r? ```@nikomatsakis```
2021-07-16 10:08:05 +02:00
Guillaume Gomez
f4e47ba3f1
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```
2021-07-16 10:07:59 +02:00
bors
a6470c7fa8 Auto merge of #86662 - mockersf:fix-86620-link-unknown-location, r=jyn514
fix dead link for method in trait of blanket impl from third party crate

fix #86620

* changes `href` method to raise the actual error it had instead of an `Option`
* set the href link correctly in case of an error

I did not manage to make a small reproducer, I think it happens in a situation where
* crate A expose a trait with a blanket impl
* crate B use the trait from crate A
* crate C use types from crate B
* building docs for crate C without dependencies

r? `@jyn514`
2021-07-16 06:44:10 +00:00
Jack Huey
f1ab6f93e6 Make GATs no longer incomplete 2021-07-16 00:22:01 -04:00
bors
057050a95b 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)
2021-07-16 04:03:12 +00:00
Deadbeef
8841a426e5
Mark const_trait_impl as active 2021-07-16 11:54:00 +08:00
Eric Huss
7ca38eee66 Update cargo 2021-07-15 19:27:11 -07:00
bors
27e4205881 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`
2021-07-16 01:11:37 +00:00
inquisitivecrystal
7fc4fc747c Stabilize [T; N]::map() 2021-07-15 16:27:08 -07:00
xFrednet
d38f2b0cc1 Added diagnostic items to structs and traits for Clippy 2021-07-15 23:57:02 +02:00
xFrednet
1a900042ab Added diagnostic items to functions for Clippy 2021-07-15 23:47:03 +02:00
Cameron Steffen
1537cd4fb1 Remove refs from pat slices 2021-07-15 16:09:57 -05:00
Ralf Jung
4e28065618 tweak pointer out-of-bounds error message 2021-07-15 22:47:11 +02:00
Guillaume Gomez
868ffd03ed Add test for sidebar display value on mobile 2021-07-15 22:21:33 +02:00
Guillaume Gomez
c3c4b9ead6 Do not hide the sidebar on mobile, move it outside of the viewport instead 2021-07-15 22:21:33 +02:00
bors
b1f8e27b74 Auto merge of #83319 - tmiasko:packed-aligned, r=jackh726
Layout error instead of an ICE for packed and aligned types

Fixes #83107.
2021-07-15 19:51:17 +00:00
Ralf Jung
bd874a9d5d make check_ptr_access_align work on function pointer allocations 2021-07-15 19:48:52 +02:00
Camille GILLOT
c2d43e1329 Simplify metadata decoding. 2021-07-15 19:31:47 +02:00
Camille GILLOT
47ea2ae933 Separate encoding paths.
The two paths will be modified independently in the next few commits.
2021-07-15 19:31:46 +02:00
bors
26366828a4 Auto merge of #87152 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2021-07-15 17:10:09 +00:00
Guillaume Gomez
25e74037e8 Add regression test for type declaration layout overflow 2021-07-15 18:19:25 +02:00
Guillaume Gomez
59103d1a25 Fix layout overflow in type declaration 2021-07-15 18:19:07 +02:00
Tomasz Miąsko
d49f977ed9 Layout error instead of an ICE for packed and aligned types 2021-07-15 18:17:27 +02:00
Ralf Jung
adbe7554d7 enable Miri to fix the bytes in an allocation (since ptr offsets have different meanings there) 2021-07-15 18:03:22 +02:00
Ralf Jung
f4b61ba509 adjustions and cleanup to make Miri build again 2021-07-15 17:14:11 +02:00
jackh726
cf001dc889 Remove failed and review comments 2021-07-15 10:58:49 -04:00
Roxane
9fe470b620 Get the right place type 2021-07-15 10:33:51 -04:00
bors
0a6c636c40 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
2021-07-15 14:29:07 +00:00
Alik Aslanyan
b69090102e
Suggest full enum variant for local modules 2021-07-15 16:34:49 +04:00
Yuki Okushi
262a4f99c1
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`
2021-07-15 21:19:22 +09:00
Yuki Okushi
20b363cb49
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)
2021-07-15 21:19:21 +09:00
Yuki Okushi
6d0d80e181
Rollup merge of #87134 - BoxyUwU:cgd-self-ty-error, r=lcnr
Make SelfInTyParamDefault wording not be specific to type defaults

r? ```@lcnr```
2021-07-15 21:19:20 +09:00
Yuki Okushi
dc464f20a1
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
2021-07-15 21:19:19 +09:00
Yuki Okushi
b99f7edad2
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.
2021-07-15 21:19:18 +09:00
Yuki Okushi
a5acb7b4ba
Rollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahc
Move assert_matches to an inner module

Fixes #82913
2021-07-15 21:19:16 +09:00
Yuki Okushi
98130137d9
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.
2021-07-15 21:19:11 +09:00
Yuki Okushi
10f335fed1
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.
2021-07-15 21:19:10 +09:00
Alex Gaynor
a214911b77 Added Arc::try_pin
This helper is in line with other other allocation helpers on Arc.
2021-07-15 07:32:05 -04:00
Guillaume Gomez
9bab94f045 Fix misuse of rev attribute on <a> tag 2021-07-15 13:23:20 +02:00
flip1995
e7bc41176e
Merge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup 2021-07-15 10:44:10 +02:00
bors
54a20a02ec Auto merge of #7468 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-07-15 08:37:36 +00:00
flip1995
43b0121fa7
Bump nightly version -> 2021-07-15 2021-07-15 10:32:21 +02:00
flip1995
69fbd64e2a
Merge remote-tracking branch 'upstream/master' into rustup 2021-07-15 10:32:06 +02:00
Niko Matsakis
75291ee924
Update compiler/rustc_typeck/src/expr_use_visitor.rs 2021-07-15 04:13:20 -04:00
Aman Arora
c4ac8369e2 PR feedback 2021-07-15 03:57:50 -04:00
bors
09f5f15d8b Auto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995
add Arc to `redundant_allocation`

 fixes #7303
changelog:  add Arc to `redundant_allocation`
2021-07-15 07:20:37 +00:00
Eric Huss
0c4b2a84c6 Update cargo 2021-07-14 19:56:42 -07:00