Commit Graph

121274 Commits

Author SHA1 Message Date
Ralf Jung
43ae54de9c
Rollup merge of #72521 - Amanieu:fix-72484, r=petrochenkov
Properly handle InlineAsmOperand::SymFn when collecting monomorphized items

Fixes #72484
2020-05-30 13:45:08 +02:00
Ralf Jung
8d64fd80ad
Rollup merge of #72499 - mendess:master, r=dtolnay
Override Box::<[T]>::clone_from

Avoid dropping and reallocating when cloning to an existing box if the lengths are the same.

It would be nice if this could also be specialized for `Copy` but I don't know how that works since it's not on stable. Will gladly look into it if it's deemed as a good idea.

This is my first PR with code, hope I did everything right 😄
2020-05-30 13:45:06 +02:00
Ralf Jung
49ca99de93
Rollup merge of #72441 - doctorn:late-bound-lifetime-ice, r=nikomatsakis
Fix ICE with explicit late-bound lifetimes

Rather than returning an explicit late-bound lifetime as a generic argument count mismatch (which is not necessarily true), this PR propagates the presence of explicit late-bound lifetimes.

This avoids an ICE that can occur due to the presence of explicit late-bound lifetimes when building generic substitutions by explicitly ignoring them.

r? @varkor

cc @davidtwco (this removes a check you introduced in #60892)

Resolves #72278
2020-05-30 13:45:04 +02:00
Ralf Jung
93d45a01e7
Rollup merge of #72368 - CAD97:rangeto, r=dtolnay
Resolve overflow behavior for RangeFrom

This specifies a documented unspecified implementation detail of `RangeFrom` and makes it consistently implement the specified behavior.

Specifically, `(u8::MAX).next()` is defined to cause an overflow, and resolve that overflow in the same manner as the `Step::forward` implementation.

The inconsistency that has existed is `<RangeFrom as Iterator>::nth`. The existing behavior should be plain to see after #69659: the skipping part previously always panicked if it caused an overflow, but the final step (to set up the state for further iteration) has always been debug-checked.

The inconsistency, then, is that `RangeFrom::nth` does not implement the same behavior as the naive (and default) implementation of just calling `next` multiple times. This PR aligns `RangeFrom::nth` to have identical behavior to the naive implementation. It also lines up with the standard behavior of primitive math in Rust everywhere else in the language: debug checked overflow.

cc @Amanieu

---

Followup to #69659. Closes #25708 (by documenting the panic as intended).

The documentation wording is preliminary and can probably be improved.

This will probably need an FCP, as it changes observable stable behavior.
2020-05-30 13:45:02 +02:00
Ralf Jung
35db8196f9
Rollup merge of #72299 - lcnr:sized_help, r=petrochenkov
more `LocalDefId`s
2020-05-30 13:45:00 +02:00
marmeladema
4b7e44f893 rustdoc: remove calls to local_def_id_from_node_id 2020-05-30 12:30:58 +01:00
Oliver Scherer
0aa7f4d2f2 Make TLS accesses explicit in MIR 2020-05-30 12:59:05 +02:00
Bastian Kauschke
49b1b4c438 more LocalDefIds 2020-05-30 12:22:29 +02:00
Ralf Jung
9c627c33dd also expose and use encode_utf16_raw for wtf8 2020-05-30 12:11:21 +02:00
Ralf Jung
3182cdf9ba wtf8: use encode_utf8_raw 2020-05-30 11:53:50 +02:00
Ralf Jung
72d85db6ee expose char::encode_utf8_raw for libstd 2020-05-30 11:49:31 +02:00
Yuki Okushi
77503578e1
Return early to avoid ICE 2020-05-30 18:48:54 +09:00
Ralf Jung
8ef9392828 multiple Return terminators are possible 2020-05-30 11:22:56 +02:00
bors
91fb72a8a9 Auto merge of #72768 - JohnTitor:rollup-6kwokh6, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #72033 (Update RELEASES.md for 1.44.0)
 - #72162 (Add Extend::{extend_one,extend_reserve})
 - #72419 (Miri read_discriminant: return a scalar instead of raw underlying bytes)
 - #72621 (Don't bail out of trait selection when predicate references an error)
 - #72677 (Fix diagnostics for `@ ..` binding pattern in tuples and tuple structs)
 - #72710 (Add test to make sure -Wunused-crate-dependencies works with tests)
 - #72724 (Revert recursive `TokenKind::Interpolated` expansion for now)
 - #72741 (Remove unused mut from long-linker-command-lines test)
 - #72750 (Remove remaining calls to `as_local_node_id`)
 - #72752 (remove mk_bool)

Failed merges:

r? @ghost
2020-05-30 07:56:05 +00:00
Ralf Jung
f8d3805733 miri validation: clarify valid values of 'char' 2020-05-30 09:33:05 +02:00
Felix S. Klock II
5e5a3d5867 Use the virtual name for libstd files in StableSourceFileId and also in the
encoded build artifacts.

Fix #70924.
2020-05-29 23:41:47 -04:00
Felix S. Klock II
da09fd3db0 Split payload of FileName::Real to track both real and virutalized paths.
Such splits arise from metadata refs into libstd.

This way, we can (in a follow on commit) continue to emit the virtual name into
things like the like the StableSourceFileId that ends up in incremetnal build
artifacts, while still using the devirtualized file path when we want to access
the file.

Note that this commit is intended to be a refactoring; the actual fix to the bug
in question is in a follow-on commit.
2020-05-29 23:41:45 -04:00
Yuki Okushi
025058f2aa
Rollup merge of #72752 - lcnr:remove-mk_bool, r=estebank
remove mk_bool
2020-05-30 12:39:24 +09:00
Yuki Okushi
c20a97dd53
Rollup merge of #72750 - marmeladema:remove-as-local-node-id, r=petrochenkov
Remove remaining calls to `as_local_node_id`

Split out from https://github.com/rust-lang/rust/pull/72552

cc https://github.com/rust-lang/rust/issues/50928
2020-05-30 12:39:23 +09:00
Yuki Okushi
990195faf8
Rollup merge of #72741 - tmiasko:unused-mut, r=Mark-Simulacrum
Remove unused mut from long-linker-command-lines test
2020-05-30 12:39:21 +09:00
Yuki Okushi
047b3bd4df
Rollup merge of #72724 - Aaron1011:revert-tokenstream-expand, r=petrochenkov
Revert recursive `TokenKind::Interpolated` expansion for now

The crater run https://github.com/rust-lang/rust/issues/72622 revealed many root regressions, at least one of which is going to take some time to fix.

For now, let's revert https://github.com/rust-lang/rust/pull/72388 to allow the 709 affected crates to continue building on the latest nightly.
2020-05-30 12:39:19 +09:00
Yuki Okushi
875c6b281d
Rollup merge of #72710 - jsgf:unused-deps-test, r=jsgf
Add test to make sure -Wunused-crate-dependencies works with tests

Make sure code in `#[test]` blocks counts as a use of a crate.
2020-05-30 12:39:18 +09:00
Yuki Okushi
ca8640e128
Rollup merge of #72677 - chrissimpkins:fix-72574, r=estebank
Fix diagnostics for `@ ..` binding pattern in tuples and tuple structs

Fixes #72574
Associated https://github.com/rust-lang/rust/pull/72534 https://github.com/rust-lang/rust/issues/72373

Includes a new suggestion with `Applicability::MaybeIncorrect` confidence level.

### Before

#### tuple

```
error: `..` patterns are not allowed here
 --> src/main.rs:4:19
  |
4 |         (_a, _x @ ..) => {}
  |                   ^^
  |
  = note: only allowed in tuple, tuple struct, and slice patterns

error[E0308]: mismatched types
 --> src/main.rs:4:9
  |
3 |     match x {
  |           - this expression has type `({integer}, {integer}, {integer})`
4 |         (_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 2 elements
  |
  = note: expected tuple `({integer}, {integer}, {integer})`
             found tuple `(_, _)`

error: aborting due to 2 previous errors
```

#### tuple struct

```
error: `..` patterns are not allowed here
 --> src/main.rs:6:25
  |
6 |         Binder(_a, _x @ ..) => {}
  |                         ^^
  |
  = note: only allowed in tuple, tuple struct, and slice patterns

error[E0023]: this pattern has 2 fields, but the corresponding tuple struct has 3 fields
 --> src/main.rs:6:9
  |
1 | struct Binder(i32, i32, i32);
  | ----------------------------- tuple struct defined here
...
6 |         Binder(_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^^^^^^^ expected 3 fields, found 2

error: aborting due to 2 previous errors
```

### After

*Note: final output edited during source review discussion, see thread for details*

#### tuple

```
error: `_x @` is not allowed in a tuple
 --> src/main.rs:4:14
  |
4 |         (_a, _x @ ..) => {}
  |              ^^^^^^^ is only allowed in a slice
  |
help: replace with `..` or use a different valid pattern
  |
4 |         (_a, ..) => {}
  |              ^^

error[E0308]: mismatched types
 --> src/main.rs:4:9
  |
3 |     match x {
  |           - this expression has type `({integer}, {integer}, {integer})`
4 |         (_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 1 element
  |
  = note: expected tuple `({integer}, {integer}, {integer})`
             found tuple `(_,)`

error: aborting due to 2 previous errors
```

#### tuple struct

```
error: `_x @` is not allowed in a tuple struct
 --> src/main.rs:6:20
  |
6 |         Binder(_a, _x @ ..) => {}
  |                    ^^^^^^^ is only allowed in a slice
  |
help: replace with `..` or use a different valid pattern
  |
6 |         Binder(_a, ..) => {}
  |                    ^^

error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 3 fields
 --> src/main.rs:6:9
  |
1 | struct Binder(i32, i32, i32);
  | ----------------------------- tuple struct defined here
...
6 |         Binder(_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^^^^^^^ expected 3 fields, found 1

error: aborting due to 2 previous errors
```

r? @estebank
2020-05-30 12:39:16 +09:00
Yuki Okushi
7624ac7dc4
Rollup merge of #72621 - Aaron1011:fix/trait-select-error, r=nikomatsakis
Don't bail out of trait selection when predicate references an error

Fixes #72590

With PR #70551, observing a `ty::Error` guarantees that compilation is
going to fail. Therefore, there are no soundness impliciations to
continuing on when we encounter a `ty::Error` - we can only affect
whether or not additional error messags are emitted.

By not bailing out, we avoid incorrectly determining that types are
`!Sized` when a type error is present, which allows us to avoid emitting
additional spurious error messages.

The original comment mentioned this code being shared by coherence -
howver, this change resulted in no diagnostic changes in any of the
existing tests.
2020-05-30 12:39:14 +09:00
Yuki Okushi
a5fb7fcab3
Rollup merge of #72419 - RalfJung:read-discriminant, r=oli-obk,eddyb
Miri read_discriminant: return a scalar instead of raw underlying bytes

r? @oli-obk @eddyb
2020-05-30 12:39:12 +09:00
Yuki Okushi
3459eae96c
Rollup merge of #72162 - cuviper:extend_one, r=Mark-Simulacrum
Add Extend::{extend_one,extend_reserve}

This adds new optional methods on `Extend`: `extend_one` add a single
element to the collection, and `extend_reserve` pre-allocates space for
the predicted number of incoming elements. These are used in `Iterator`
for `partition` and `unzip` as they shuffle elements one-at-a-time into
their respective collections.
2020-05-30 12:39:10 +09:00
Yuki Okushi
a578ac52ba
Rollup merge of #72033 - XAMPPRocky:relnotes-1.44.0, r=Mark-Simulacrum
Update RELEASES.md for 1.44.0

### [Rendered](https://github.com/XAMPPRocky/rust/blob/relnotes-1.44.0/RELEASES.md)

r? @Mark-Simulacrum
cc @rust-lang/release
2020-05-30 12:39:09 +09:00
Felix S. Klock II
905d738b1a StableSourceFileId::new_from_pieces does not need to be public.
(and I want to discourage further use of it if possible.)
2020-05-29 23:34:20 -04:00
Josh Stone
a51b22a9fd Add extend_one tracking issue 72631 2020-05-29 17:05:17 -07:00
Josh Stone
10efaa37de Remove an old comment from HashMap::extend_reserve 2020-05-29 17:05:17 -07:00
Josh Stone
e4345547b9 Use a canonical name for extend_reserve(additional)
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-05-29 17:05:17 -07:00
Josh Stone
6700e18688 Add Extend::{extend_one,extend_reserve}
This adds new optional methods on `Extend`: `extend_one` add a single
element to the collection, and `extend_reserve` pre-allocates space for
the predicted number of incoming elements. These are used in `Iterator`
for `partition` and `unzip` as they shuffle elements one-at-a-time into
their respective collections.
2020-05-29 17:05:17 -07:00
bors
0e9e408310 Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJung
Rollup of 9 pull requests

Successful merges:

 - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes)
 - #71095 (impl From<[T; N]> for Box<[T]>)
 - #71500 (Make pointer offset methods/intrinsics const)
 - #71804 (linker: Support `-static-pie` and `-static -shared`)
 - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn)
 - #72103 (borrowck `DefId` -> `LocalDefId`)
 - #72407 (Various minor improvements to Ipv6Addr::Display)
 - #72413 (impl Step for char (make Range*<char> iterable))
 - #72439 (NVPTX support for new asm!)

Failed merges:

r? @ghost
2020-05-29 23:43:20 +00:00
Ralf Jung
c4b6224ea4 more type sanity checks in Miri 2020-05-30 00:02:30 +02:00
Alex Crichton
16469a123e Update compiler-builtins
Pulls in a fix for #72758, more details on the linked issue.

[Crate changes included here][changes]

[changes]: https://github.com/rust-lang/compiler-builtins/compare/0.1.28...0.1.31
2020-05-29 13:44:40 -07:00
Chris Simpkins
27ed143ba9
fix diagnostics for @ .. binding pattern in tuples and tuple structs
fix comment


add newline for tidy fmt error...


edit suggestion message


change the suggestion message to better handle cases with binding modes


Apply suggestions from estebank code review

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
edits to address source review


Apply suggestions from estebank code review #2

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
update test files
2020-05-29 16:03:46 -04:00
Ralf Jung
37894559ab
Rollup merge of #72439 - westernmagic:master, r=Amanieu
NVPTX support for new asm!

This PR implements the new `asm!` syntax for the `nvptx64-nvidia-cuda` target.

r? @Amanieu
2020-05-29 21:58:34 +02:00
Ralf Jung
b965196ce0
Rollup merge of #72413 - CAD97:char-range, r=dtolnay
impl Step for char (make Range*<char> iterable)

[[irlo thread]](https://internals.rust-lang.org/t/mini-rfc-make-range-char-work/12392?u=cad97) [[godbolt asm example]](https://rust.godbolt.org/z/fdveKo)

Add an implementation of the `Step` trait for `char`, which has the effect of making `RangeInclusive<char>` (and the other range types) iterable.

I've used the surrogate range magic numbers as magic numbers here rather than e.g. a `const SURROGATE_RANGE = 0xD800..0xE000` because these numbers appear to be used as magic numbers elsewhere and there doesn't exist constants for them yet. These files definitely aren't where surrogate range constants should live.

`ExactSizeIterator` is not implemented because `0x10FFFF` is bigger than fits in a `usize == u16`. However, given we already provide some `ExactSizeIterator` that are not correct on 16 bit targets, we might still want to consider providing it for `Range`[`Inclusive`]`<char>`, as it is definitely _very_ convenient. (At the very least, we want to make sure `.count()` doesn't bother iterating the range.)

The second commit in this PR changes a call to `Step::forward` to use `Step::forward_unchecked` in `RangeInclusive::next`. This is because without this patch, iteration over all codepoints (`'\0'..=char::MAX`) does not successfully optimize out the panicking branch. This was mentioned in the PR that updated `Step` to its current design, but was deemed not yet necessary as it did not impact codegen for integral types.

More of `Range*`'s implementations' calls to `Step` methods will probably want to see if they can use the `_unchecked` version as (if) we open up `Step` to being implemented on more types.

---

cc @rust-lang/libs, this is insta-stable and a fairly significant addition to `Range*`'s capabilities; this is the first instance of a noncontinuous domain being iterable with `Range` (or, well, anything other than primitive integers). I don't think this needs a full RFC, but it should definitely get some decent eyes on it.
2020-05-29 21:58:32 +02:00
Ralf Jung
de561a9d3d
Rollup merge of #72407 - Lucretiel:ipv6-display, r=Mark-Simulacrum
Various minor improvements to Ipv6Addr::Display

Cleaned up `Ipv6Addr::Display`, especially with an eye towards simplifying and reducing duplicated logic. Also added a fast-path optimization, similar to #72399 and #72398.

- Defer to `Ipv4Addr::fmt` when printing an Ipv4 address
- Fast path: write directly to `f` without an intermediary buffer when there are no alignment options
- Simplify finding the inner zeroes-span
2020-05-29 21:58:29 +02:00
Ralf Jung
e229d6e73b
Rollup merge of #72103 - lcnr:borrowck-localdefid, r=jonas-schievink
borrowck `DefId` -> `LocalDefId`

Replaces some `DefId`s which must always be local with `LocalDefId` in `librustc_mir/borrowck`.

cc @marmeladema
2020-05-29 21:58:27 +02:00
Ralf Jung
c442e43b3a
Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, r=nikomatsakis
Implement RFC 2585: unsafe blocks in unsafe fn

Tracking issue: #71668
r? @RalfJung cc @nikomatsakis
2020-05-29 21:58:25 +02:00
Ralf Jung
7aef3a0f6f
Rollup merge of #71804 - petrochenkov:static-pie, r=cuviper
linker: Support `-static-pie` and `-static -shared`

This PR adds support for passing linker arguments for creating statically linked position-independent executables and "statically linked" shared libraries.

Therefore it incorporates the majority of https://github.com/rust-lang/rust/pull/70740 except for the linker rerun hack and actually flipping the "`static-pie` is supported" switch for musl targets.
2020-05-29 21:58:24 +02:00
Ralf Jung
1cfe0e9c63
Rollup merge of #71500 - josephlr:offset, r=oli-obk,RalfJung
Make pointer offset methods/intrinsics const

Implements #71499 using [the implementations from miri](52f5d202bd/src/shims/intrinsics.rs (L96-L112)).

I added some tests what's allowed and what's UB. Let me know if any other cases should be added.

CC: @RalfJung @oli-obk
2020-05-29 21:58:22 +02:00
Ralf Jung
b387a11636
Rollup merge of #71095 - pickfire:box-from-array, r=dtolnay
impl From<[T; N]> for Box<[T]>

Based on https://github.com/rust-lang/rust/pull/68692
2020-05-29 21:58:19 +02:00
Ralf Jung
81207802a0
Rollup merge of #67460 - estebank:named-lts, r=nikomatsakis
Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes

Fix #66406, fix #72106.

```
error: `impl` item signature doesn't match `trait` item signature
  --> $DIR/trait-param-without-lifetime-constraint.rs:14:5
   |
LL |     fn get_relation(&self) -> To;
   |     ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL |     fn get_relation(&self) -> &ProofReader {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
   |
   = note: expected `fn(&Article) -> &ProofReader`
              found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
  --> $DIR/trait-param-without-lifetime-constraint.rs:10:31
   |
LL |     fn get_relation(&self) -> To;
   |                               ^^ consider borrowing this type parameter in the trait
```

r? @nikomatsakis
2020-05-29 21:58:14 +02:00
Vadim Petrochenkov
21755b58c9 rustc_lexer: Optimize shebang detection slightly 2020-05-29 22:55:58 +03:00
bors
4bd32c9804 Auto merge of #72747 - Dylan-DPC:rollup-vvydkgl, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #72310 (Add Peekable::next_if)
 - #72383 (Suggest using std::mem::drop function instead of explicit destructor call)
 - #72398 (SocketAddr and friends now correctly pad its content)
 - #72465 (Warn about unused captured variables)
 - #72568 (Implement total_cmp for f32, f64)
 - #72572 (Add some regression tests)
 - #72591 (librustc_middle: Rename upvar_list to closure_captures)
 - #72701 (Fix grammar in liballoc raw_vec)
 - #72731 (Add missing empty line in E0619 explanation)

Failed merges:

r? @ghost
2020-05-29 19:50:22 +00:00
marmeladema
2f3dd7b187 Remove remaining calls to as_local_node_id 2020-05-29 20:05:44 +01:00
Bastian Kauschke
8f8cb710cc remove trivial mk_predicates 2020-05-29 21:04:01 +02:00
Bastian Kauschke
25bafc24db remove mk_bool 2020-05-29 20:41:26 +02:00