Commit Graph

124689 Commits

Author SHA1 Message Date
Nicholas Nethercote
d6fa011f62 Remove some unnecessary uses of Option.
These arguments are never `None`.
2020-08-08 12:02:45 +10:00
bors
f3a9de9b08 Auto merge of #75048 - eggyal:force-no-tco-start-backtrace-frame, r=Mark-Simulacrum
Prevent `__rust_begin_short_backtrace` frames from being tail-call optimised away

I've stumbled across some situations where there (unexpectedly) was no `__rust_begin_short_backtrace` frame on the stack during unwinding.

On closer examination, it appeared that the calls to that function had been tail-call optimised away.

This PR follows [@bjorn3's suggestion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Disabling.20tail.20call.20optimisation.3F/near/205699133), by adding calls to `black_box` that hint to rustc not to perform TCO.

Fixes #47429
2020-08-08 00:00:52 +00:00
bors
c2d1b0d980 Auto merge of #75071 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
BTreeMap: enforce the panic rule imposed by `replace`

Also, reveal the unsafe parts in the closures fed to it.

r? @Mark-Simulacrum
2020-08-07 21:48:32 +00:00
Alan Egerton
5792840bf5 Prevent __rust_begin_short_backtrace frames from being tail-call optimised away 2020-08-07 19:31:25 +01:00
bors
09f4c9f508 Auto merge of #75255 - davidtwco:polymorphisation-symbol-mangling-v0-upvar-closures, r=lcnr
instance: polymorphize upvar closures/generators

This PR modifies how instances are polymorphized so that closures and generators have any closures or generators captured within their upvars also polymorphized.

With the new symbol mangling, a fully polymorphised closure will produce the same symbol regardless of what it was instantiated with. However, when that polymorphised closure captures another closure as an upvar, then the type of that other closure in the upvar substitution wouldn't have been polymorphised. The other closure will still refer to the initial substitutions. Therefore, the polymorphised closure will end up hashing differently but producing the same symbol - triggering `assert_symbols_are_distinct` in MIR partitioning. The old mangling scheme had a hash at the end that meant this didn't happen (this would still have been an issue, we just didn't have a way to notice).

See [this Zulip discussion for further elaboration](https://rust-lang.zulipchat.com/#narrow/stream/216091-t-compiler.2Fwg-polymorphization/topic/symbol.20mangling.20v0.20.E2.9C.95.20polymorphisation/near/206152008).

r? @eddyb
cc @lcnr
2020-08-07 17:57:30 +00:00
Stein Somers
734fc0477c BTreeMap: enforce the panic rule imposed by replace 2020-08-07 19:51:26 +02:00
David Wood
ac50d61785
instance: polymorphize FnDef substs
This commit extends previous polymorphization of substs to polymorphize
`FnDef`.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-07 18:41:45 +01:00
David Wood
4ccaf6f38c
instance: avoid unnecessary mk_ calls
This commit avoids unnecessary calls to `mk_closure` and `mk_generator`
by checking if the polymorphized substs match the original substs.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-07 18:41:43 +01:00
David Wood
5827b5a4bd
ty: add MAY_POLYMORPHIZE flag
This commit adds a `MAY_POLYMORPHIZE` which checks for closures and
generators so that polymorphization of substs does not need to traverse
every substs.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-07 18:41:42 +01:00
David Wood
0d9924a87b
instance: always polymorphize substs
By always polymorphizing substitutions, functions which take closures as
arguments (e.g. `impl Fn()`) can have fewer mono items when some of the
argument closures can be polymorphized.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-07 18:41:41 +01:00
David Wood
d9decede35
instance: polymorphize upvar closures/generators
This commit modifies how instances are polymorphized so that closures
and generators have any closures or generators captured within their
upvars also polymorphized - this avoids symbol clashes with the new
symbol mangling scheme.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-07 18:41:39 +01:00
bors
4d4342347b Auto merge of #74821 - oli-obk:const_eval_read_uninit_fast_path, r=wesleywiser
Check whether locals are too large instead of whether accesses into them are too large

Essentially this stops const prop from attempting to optimize

```rust
let mut x = [0_u8; 5000];
x[42] = 3;
```

I don't expect this to be a perf improvement without #73656 (which is also where the lack of this PR will be a perf regression).

r? @wesleywiser
2020-08-07 15:28:07 +00:00
bors
64f99b4cfb Auto merge of #74627 - petrochenkov:docbeauty2, r=Aaron1011
rustc_ast: Stop using "string typing" for doc comment tokens

Explicitly store their kind and style retrieved during lexing in the `token::DocComment`.

Also don't "beautify" doc comments before converting them to `#[doc]` attributes when passing them to macros (both declarative and procedural).
The trimming of empty lines, lines containing only `*`s, etc is purely a rustdoc's job as a part of its presentation of doc strings to users, rustc must not do this and must pass tokens as precisely as possible internally.
2020-08-07 13:29:25 +00:00
bors
1e0e618cfb Auto merge of #73842 - euclio:doctest-expn, r=GuillaumeGomez
Use outermost invocation span for doctest names

Fixes #70090.

This PR also allows using aux-build files in rustdoc-ui tests.
2020-08-07 11:38:17 +00:00
bors
8b26609481 Auto merge of #70052 - Amanieu:hashbrown7, r=Mark-Simulacrum
Update hashbrown to 0.8.1

This update includes:
- https://github.com/rust-lang/hashbrown/pull/146, which improves the performance of `Clone` and implements `clone_from`.
- https://github.com/rust-lang/hashbrown/pull/159, which reduces the size of `HashMap` by 8 bytes.
- https://github.com/rust-lang/hashbrown/pull/162, which avoids creating small 1-element tables.

Fixes #28481
2020-08-07 08:36:15 +00:00
bors
d4c940f082 Auto merge of #75244 - Manishearth:rollup-dzfyjva, r=Manishearth
Rollup of 4 pull requests

Successful merges:

 - #74774 (adds [*mut|*const] ptr::set_ptr_value)
 - #75079 (Disallow linking to items with a mismatched disambiguator)
 - #75203 (Make `IntoIterator` lifetime bounds of `&BTreeMap` match with `&HashMap` )
 - #75227 (Fix ICE when using asm! on an unsupported architecture)

Failed merges:

r? @ghost
2020-08-07 06:40:53 +00:00
Amanieu d'Antras
e46bb17936 Fix natvis tests 2020-08-07 07:19:13 +01:00
Manish Goregaokar
9ab750d05d
Rollup merge of #75227 - Amanieu:fix_asm_arch, r=Mark-Simulacrum
Fix ICE when using asm! on an unsupported architecture

Fixes #75220
2020-08-06 23:04:07 -07:00
Manish Goregaokar
25c8e9ac17
Rollup merge of #75203 - canova:btreemap-into-iter, r=dtolnay
Make `IntoIterator` lifetime bounds of `&BTreeMap` match with `&HashMap`

This is a pretty small change on the lifetime bounds of `IntoIterator` implementations of both `&BTreeMap` and `&mut BTreeMap`. This is loosening the lifetime bounds, so more code should be accepted with this PR. This is lifetime bounds will still be implicit since we have `type Item = (&'a K, &'a V);` in the implementation. This change will make the HashMap and BTreeMap share the same signature, so we can share the same function/trait with both HashMap and BTreeMap in the code.

Fixes #74034.
r? @dtolnay hey, I was touching this file on my previous PR and wanted to fix this on the way. Would you mind taking a look at this, or redirecting it if you are busy?
2020-08-06 23:04:05 -07:00
Manish Goregaokar
5b1ed09df0
Rollup merge of #75079 - jyn514:disambiguator, r=Manishearth
Disallow linking to items with a mismatched disambiguator

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

r? @Manishearth
2020-08-06 23:04:03 -07:00
Manish Goregaokar
5f331c0585
Rollup merge of #74774 - oliver-giersch:set_data_ptr, r=dtolnay
adds [*mut|*const] ptr::set_ptr_value

I propose the addition of these two functions to `*mut T` and `*const T`, respectively. The motivation for this is primarily byte-wise pointer arithmetic on (potentially) fat pointers, i.e. for types with a `T: ?Sized` bound. A concrete use-case has been discussed in [this](https://internals.rust-lang.org/t/byte-wise-fat-pointer-arithmetic/12739) thread.
TL;DR: Currently, byte-wise pointer arithmetic with potentially fat pointers in not possible in either stable or nightly Rust without making assumptions about the layout of fat pointers, which is currently still an implementation detail and not formally stabilized. This PR adds one function to `*mut T` and `*const T` each, allowing to circumvent this restriction without exposing any internal implementation details.
One possible alternative would be to add specific byte-wise pointer arithmetic functions to the two pointer types in addition to the already existing count-wise functions. However, I feel this fairly niche use case does not warrant adding a whole set of new functions like `add_bytes`, `offset_bytes`, `wrapping_offset_bytes`, etc. (times two, one for each pointer type) to `libcore`.
2020-08-06 23:04:02 -07:00
MaulingMonkey
122c03745e Handle new HashMap layout in CDB, MSVC, WinDbg, etc. 2020-08-07 07:03:15 +01:00
Amanieu d'Antras
e3283e0331 Handle new HashMap layout in GDB and LLDB 2020-08-07 07:03:15 +01:00
Amanieu d'Antras
d51b7b229a Update hashbrown to 0.8.1 2020-08-07 07:03:12 +01:00
bors
98922795f6 Auto merge of #75121 - tmiasko:str-slicing, r=Mark-Simulacrum
Avoid `unwrap_or_else` in str indexing

This provides a small reduction of generated LLVM IR, and leads to a
simpler assembly code.

Closes #68874.
2020-08-07 04:51:04 +00:00
Joshua Nelson
9914f73f14 Add doc-comment for kind_side_channel 2020-08-06 23:17:15 -04:00
bors
63e34422bb Auto merge of #75233 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/74999
Cc @rust-lang/miri r? @ghost
2020-08-07 03:04:38 +00:00
bors
6396dbbd62 Auto merge of #75238 - JohnTitor:rollup-llbk0sq, r=JohnTitor
Rollup of 12 pull requests

Successful merges:

 - #74888 (compiletest: ignore-endian-big, fixes #74829, fixes #74885)
 - #75175 (Make doctests of Ipv4Addr::from(u32) easier to read)
 - #75179 (Remove unused FromInner impl for Ipv4Addr)
 - #75181 (Fix typo in  `librustc_feature/active.rs`)
 - #75183 (Label rustfmt toolstate issues with A-rustfmt)
 - #75188 (Handle fieldless tuple structs in diagnostic code)
 - #75190 (Clean up E0746 explanation)
 - #75210 (Change the type of `AssertModuleSource::available_cgus`.)
 - #75211 (Note about endianness of returned value of {integer}::from_be_bytes and friends)
 - #75217 (Clean up E0747 explanation)
 - #75232 (Fix typo "TraitObligatiom" -> "TraitObligation")
 - #75236 (Fix typo "biset" -> "bitset")

Failed merges:

r? @ghost
2020-08-07 01:16:47 +00:00
Yuki Okushi
3c131d6738
Rollup merge of #75236 - syntacticsugarglider:patch-1, r=jonas-schievink
Fix typo "biset" -> "bitset"
2020-08-07 09:35:31 +09:00
Yuki Okushi
6f2fa1ef51
Rollup merge of #75232 - leijurv:patch-1, r=jonas-schievink
Fix typo "TraitObligatiom" -> "TraitObligation"
2020-08-07 09:35:29 +09:00
Yuki Okushi
76086a2d76
Rollup merge of #75217 - GuillaumeGomez:cleanup-e0747, r=Dylan-DPC
Clean up E0747 explanation

r? @Dylan-DPC
2020-08-07 09:35:28 +09:00
Yuki Okushi
26705d5bcb
Rollup merge of #75211 - lzutao:native-endian-notes, r=lcnr
Note about endianness of returned value of {integer}::from_be_bytes and friends

[`u32::from_be`](https://doc.rust-lang.org/nightly/src/core/num/mod.rs.html#2883-2892) documents about endianness of returned value.

I was confused by endianness of `from_be_bytes` in #75086 .
2020-08-07 09:35:26 +09:00
Yuki Okushi
19d4e1dcac
Rollup merge of #75210 - nnethercote:change-type-of-available_cgus, r=ecstatic-morse
Change the type of `AssertModuleSource::available_cgus`.

It's currently a `BTreeSet<Symbol>`, which is a strange type. The
`BTreeSet` suggests that element order is important, but `Symbol` is a
type whose ordering isn't useful to humans. The ordering of the
collection only manifests in an obscure error message ("no module named
`...`") that doesn't appear in any tests.

This commit changes the `Symbol` to a `String`, which is more
typical.
2020-08-07 09:35:24 +09:00
Yuki Okushi
f49e47348d
Rollup merge of #75190 - GuillaumeGomez:cleanup-e0746, r=Dylan-DPC
Clean up E0746 explanation

r? @Dylan-DPC
2020-08-07 09:35:23 +09:00
Yuki Okushi
665138c977
Rollup merge of #75188 - Aaron1011:fix/fieldless-tuple-error, r=varkor
Handle fieldless tuple structs in diagnostic code

Fixes #75062
2020-08-07 09:35:21 +09:00
Yuki Okushi
5542fba2d3
Rollup merge of #75183 - Aaron1011:toolstate/a-rustfmt, r=nikomatsakis
Label rustfmt toolstate issues with A-rustfmt

This makes it easier to filter toolstate issues by the tool involved.
2020-08-07 09:35:19 +09:00
Yuki Okushi
d36087bdac
Rollup merge of #75181 - WaffleLapkin:patch-2, r=ecstaticmorse
Fix typo in  `librustc_feature/active.rs`
2020-08-07 09:35:18 +09:00
Yuki Okushi
1b61fd3ccf
Rollup merge of #75179 - lzutao:unsed-ipv4-frominner, r=alexcrichton
Remove unused FromInner impl for Ipv4Addr

The removed is a unused unstable implementation.
2020-08-07 09:35:16 +09:00
Yuki Okushi
c9c7048038
Rollup merge of #75175 - lzutao:doctest-ipv4-fromu32, r=cuviper
Make doctests of Ipv4Addr::from(u32) easier to read

There are many zeroes in `0x0d0c0b0au32` which makes it hard to read.
2020-08-07 09:35:14 +09:00
Yuki Okushi
9d5bd597ac
Rollup merge of #74888 - infinity0:ignore-endian-big, r=nikomatsakis
compiletest: ignore-endian-big, fixes #74829, fixes #74885

See discussion on #74829

I tested it on a Debian s390x machine, works well.
2020-08-07 09:35:13 +09:00
Izzy Swart
b809f453ca
Fix typo "biset" -> "bitset" 2020-08-06 16:13:29 -07:00
Joshua Nelson
17263bc2da Remove dead code 2020-08-06 18:57:56 -04:00
Joshua Nelson
d240490229 Fix outdated code 2020-08-06 18:53:12 -04:00
Joshua Nelson
ef54cde625 Improve tests 2020-08-06 18:33:29 -04:00
Joshua Nelson
0c99d806ea Use the proper kind for associated items
See comments in the diff; this is such a hack.

The reason this can't be done properly in `register_res` is because
there's no way to get back the parent type: calling
`tcx.parent(assoc_item)` gets you the _impl_, not the type.
You can call `tcx.impl_trait_ref(impl_).self_ty()`, but there's no way
to go from that to a DefId without unwrapping.
2020-08-06 18:16:10 -04:00
Ralf Jung
854d8e8ceb update Miri 2020-08-06 23:55:30 +02:00
Leijurv
6eeae7d420
Fix typo "TraitObligatiom" -> "TraitObligation" 2020-08-06 14:37:32 -07:00
Joshua Nelson
f05e9da493 Still print help even if there's no span 2020-08-06 17:10:52 -04:00
Nicholas Nethercote
ebbf07a154 Change the type of AssertModuleSource::available_cgus.
It's currently a `BTreeSet<Symbol>`, which is a strange type. The
`BTreeSet` suggests that element order is important, but `Symbol` is a
type whose ordering isn't useful to humans. The ordering of the
collection only manifests in an obscure error message ("no module named
`...`") that doesn't appear in any tests.

This commit changes the `Symbol` to a `String`, which is more
typical.
2020-08-07 06:58:14 +10:00
bors
71f8d0c8f1 Auto merge of #75228 - tmiasko:keep-stdout-open, r=ecstatic-morse
Keep stdout open in limit_vector_count test
2020-08-06 20:22:20 +00:00