Commit graph

101236 commits

Author SHA1 Message Date
Igor Aleksanov
993b920032 librustc_lexer: Enhance documentation
Apply review suggestions

Apply review suggestions
2019-10-27 20:08:08 +03:00
bors
084edc426f Auto merge of #63812 - eddyb:promo-sanity, r=oli-obk
rustc_mir: double-check const-promotion candidates for sanity.

Previously, const promotion involved tracking information about the value in a MIR local (or any part of the computation leading up to that value), aka "qualifs", in a quite stateful manner, which is hard to extend to arbitrary CFGs without a dataflow pass.

However, the nature of the promotion we do is that it's effectively an SSA-like "tree" (or DAG, really), of assigned-once locals - which is how we can take them from the original MIR in the first place.
This structure means that the subset of the MIR responsible for computing any given part of a const-promoted value is readily analyzable by walking that tree/DAG.

This PR implements such an analysis in `promote_consts`, reusing the `HasMutInterior` / `NeedsDrop` computation from `qualify_consts`, but reimplementing the equivalent of `IsNotPromotable` / `IsNotImplicitlyPromotable`.

Eventually we should be able to remove `IsNotPromotable` / `IsNotImplicitlyPromotable` from `qualify_consts`, which will simplify @ecstatic-morse's dataflow-based const-checking efforts.

But currently this is mainly for a crater check-only run - it will compare the results from the old promotion collection and the new promotion validation and ICE if they don't match.

r? @oli-obk
2019-10-26 00:11:36 +00:00
Eduard-Mihai Burtescu
f2c8628920 rustc_mir: use the new validator's Qualif in promotion. 2019-10-26 01:45:54 +03:00
Eduard-Mihai Burtescu
6c55fb8227 rustc_mir: double-check const-promotion candidates for sanity. 2019-10-26 01:45:53 +03:00
bors
246be7e1a5 Auto merge of #65826 - JohnTitor:rollup-mr6crka, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #65705 (Add {String,Vec}::into_raw_parts)
 - #65749 (Insurance policy in case `iter.size_hint()` lies.)
 - #65799 (Fill tracking issue number for `array_value_iter`)
 - #65800 (self-profiling: Update measureme to 0.4.0 and remove non-RAII methods from profiler.)
 - #65806 (Add [T]::as_ptr_range() and [T]::as_mut_ptr_range().)
 - #65810 (SGX: Clear additional flag on enclave entry)

Failed merges:

r? @ghost
2019-10-25 20:41:28 +00:00
Yuki Okushi
d40c6afba0
Rollup merge of #65810 - raoulstrackx:ac_mitigation, r=nagisa
SGX: Clear additional flag on enclave entry

An attacker could set both the AC flag in CR0 as in rflags. This causes the enclave to perform an AEX upon a misaligned memory access, and an attacker learns some information about the internal enclave state.
The AC flag in rflags is copied from userspace upon an enclave entry. Upon AEX it is copied and later restored. This patch forces the rflag.AC bit to be reset right after an enter.
2019-10-26 02:46:02 +09:00
Yuki Okushi
f0c58e9d85
Rollup merge of #65806 - fusion-engineering-forks:slice-ptr-range, r=Centril
Add [T]::as_ptr_range() and [T]::as_mut_ptr_range().

Implementation of https://github.com/rust-lang/rfcs/pull/2791
2019-10-26 02:46:01 +09:00
Yuki Okushi
574b0780ab
Rollup merge of #65800 - michaelwoerister:measureme-0.4.0, r=wesleywiser
self-profiling: Update measureme to 0.4.0 and remove non-RAII methods from profiler.

This PR removes all non-RAII based profiling methods from `SelfProfilerRef` 🎉
It also delegates the `TimingGuard` implementation to `measureme`, now that that is available there.

r? @wesleywiser
2019-10-26 02:45:59 +09:00
Yuki Okushi
9192f3625d
Rollup merge of #65799 - LukasKalbertodt:fill-array-value-iter-tracking-issue, r=Centril
Fill tracking issue number for `array_value_iter`

Thanks for [noticing](https://github.com/rust-lang/rust/pull/62959#discussion_r338930448)!

r? @Centril
2019-10-26 02:45:58 +09:00
Yuki Okushi
7068c2d4e9
Rollup merge of #65749 - Centril:insurance-policy, r=RalfJung
Insurance policy in case `iter.size_hint()` lies.

Follow up to https://github.com/rust-lang/rust/pull/64949/files#r334235076.
(If the perf impact is bad we can use `debug_assert!` instead.)

The good news is that the UI tests pass locally so `iter.size_hint()` seems to be honest *thus far*.
On the other hand, with the status quo we do not have an insurance policy should that change in some case. This is problematic because a) this could possibly make some program be accepted which shouldn't, b) the compiler itself could have memory unsafety if the correctness of the iterator is assumed in `unsafe { ... }` code (even though the blame lies with the `unsafe { ... }` block in question.)

r? @RalfJung
cc @nnethercote
2019-10-26 02:45:57 +09:00
Yuki Okushi
a808ba374f
Rollup merge of #65705 - shepmaster:vec-into-raw, r=SimonSapin
Add {String,Vec}::into_raw_parts

Aspects to address:

- [x] Create a tracking issue
  - #65816
2019-10-26 02:45:56 +09:00
Mara Bos
381c4425b7 Fix slice::as_ptr_range doctest. 2019-10-25 18:01:31 +02:00
Mazdak Farrokhzad
dfcfca28ad Take out an insurance policy in case iter.size_hint()
lies, underreporting the number of elements.
2019-10-25 17:43:53 +02:00
Jake Goulding
6600cf6040 Add {String,Vec}::into_raw_parts 2019-10-25 11:25:52 -04:00
Jake Goulding
dce8fabc62 Use ManuallyDrop in examples for {Vec,String}::from_raw_parts 2019-10-25 11:22:53 -04:00
Jake Goulding
0d21d257c9 Remove unneeded pointer casting 2019-10-25 11:20:47 -04:00
Raoul Strackx
5aafa98562 forgot pushfq/popqfq: fixed 2019-10-25 16:06:13 +02:00
Mara Bos
de9b660a40 Explain why pointer::add in slice::as_ptr_range is safe. 2019-10-25 15:46:42 +02:00
Raoul Strackx
34f5d5923f cleaning up code 2019-10-25 15:44:07 +02:00
Raoul Strackx
d257c20a1d removed unnecessary push 2019-10-25 15:27:48 +02:00
Mara Bos
f1b69b0a87 Add slice_ptr_range tracking issue number. 2019-10-25 14:33:07 +02:00
Mara Bos
4936f96d42 Add [T]::as_ptr_range() and [T]::as_mut_ptr_range().
See https://github.com/rust-lang/rfcs/pull/2791 for motivation.
2019-10-25 14:09:32 +02:00
bors
23f890f102 Auto merge of #65804 - Centril:rollup-arlxgch, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #64639 (Stabilize `#[non_exhaustive]` (RFC 2008))
 - #65074 (Fix the start/end byte positions in the compiler JSON output)
 - #65315 (Intern place projection)
 - #65685 (Fix check of `statx` and handle EPERM)
 - #65731 (Prevent unnecessary allocation in PathBuf::set_extension.)
 - #65740 (Fix default "disable-shortcuts" feature value)
 - #65787 (move panictry! to where it is used.)
 - #65789 (move Attribute::with_desugared_doc to librustdoc)
 - #65790 (move report_invalid_macro_expansion_item to item.rs)

Failed merges:

r? @ghost
2019-10-25 11:13:30 +00:00
Mazdak Farrokhzad
c0bbb4bcdc
Rollup merge of #65790 - Centril:move-report-invalid, r=davidtwco
move report_invalid_macro_expansion_item to item.rs

From https://github.com/rust-lang/rust/pull/65324.

r? @Mark-Simulacrum
2019-10-25 13:12:55 +02:00
Mazdak Farrokhzad
cbcbba24ac
Rollup merge of #65789 - Centril:with-desugared-doc, r=davidtwco
move Attribute::with_desugared_doc to librustdoc

From https://github.com/rust-lang/rust/pull/65324.

r? @varkor
2019-10-25 13:12:54 +02:00
Mazdak Farrokhzad
0bfe483c5c
Rollup merge of #65787 - Centril:panictry, r=davidtwco
move panictry! to where it is used.

From https://github.com/rust-lang/rust/pull/65324

r? @davidtwco
2019-10-25 13:12:53 +02:00
Mazdak Farrokhzad
07b5c2a46e
Rollup merge of #65740 - GuillaumeGomez:fix-disable-shortcut-feature, r=Dylan-DPC
Fix default "disable-shortcuts" feature value

Follow-up of https://github.com/rust-lang/rust/pull/65656

It fixes the bad handling of the default value of the feature (which would disable shortcut by default, which is bad!).

r? @Dylan-DPC
cc @kinnison
2019-10-25 13:12:51 +02:00
Mazdak Farrokhzad
3e3f21cd0a
Rollup merge of #65731 - fusion-engineering-forks:set-extension, r=dtolnay
Prevent unnecessary allocation in PathBuf::set_extension.

It was allocating a new `OsString` that was immediately dropped after using it with `set_file_name`. Now it directly changes the extension in the original buffer, without touching the rest of the file name or allocating a temporary string.
2019-10-25 13:12:50 +02:00
Mazdak Farrokhzad
f1d747a99d
Rollup merge of #65685 - oxalica:statx-eperm, r=alexcrichton
Fix check of `statx` and handle EPERM

Should fix #65662

https://github.com/rust-lang/rust/issues/65662#issuecomment-544593939
> I think a reasonable solution might be to do something like try to stat AT_CWD initially and if that fails with EPERM or ENOSYS we disable the syscall entirely, otherwise it's cached as always good to use.

r? @alexcrichton
2019-10-25 13:12:48 +02:00
Mazdak Farrokhzad
8bb039fb83
Rollup merge of #65315 - spastorino:intern-place-projection, r=oli-obk
Intern place projection

This should sit on top of https://github.com/rust-lang/rust/pull/65197. After that one merged, I'm gonna rebase on top of it.

The important commits are the last three and there's a bunch of code repetition that I'm going to remove but for that I need to refactor some things that probably need to be added before this PR.

Anyway this work helps as is because we can run perf tests :).

r? @oli-obk /cc @nikomatsakis
2019-10-25 13:12:46 +02:00
Mazdak Farrokhzad
1f93be1bb3
Rollup merge of #65074 - Rantanen:json-byte-pos, r=matklad
Fix the start/end byte positions in the compiler JSON output

Track the changes made during normalization in the `SourceFile` and use this information to correct the `start_byte` and `end_byte` fields in the JSON output.

This should ensure the start/end byte fields can be used to index the original file, even if Rust normalized the source code for parsing purposes. Both CRLF to LF and BOM removal are handled with this one.

The rough plan was discussed with @matklad in rust-lang-nursery/rustfix#176 - although I ended up going with `u32` offset tracking so I wouldn't need to deal with `u32 + i32` arithmetics when applying the offset to the span byte positions.

Fixes #65029
2019-10-25 13:12:45 +02:00
Mazdak Farrokhzad
959b6e324c
Rollup merge of #64639 - davidtwco:rfc-2008-stabilization, r=Centril
Stabilize `#[non_exhaustive]` (RFC 2008)

Fixes #44109.

This pull request stabilizes the `#[non_exhaustive]` attribute, which is used to indicate that a type will have more fields / variants added in the future. It can be applied to `struct`s, `enum`s and `enum` variants. See https://github.com/rust-lang/rust/issues/44109#issuecomment-533356866 for the stabilization report.

r? @Centril
2019-10-25 13:12:43 +02:00
Lukas Kalbertodt
dcf3436899 Fill tracking issue number for array_value_iter and fix Rust version 2019-10-25 11:37:30 +02:00
Michael Woerister
9c083068e3 self-profiling: Switch query-blocking measurements to RAII-style API. 2019-10-25 11:14:29 +02:00
Mazdak Farrokhzad
9e3e3a470e
with_desugared_doc: correctly refer to attr instead of self
Co-Authored-By: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co>
2019-10-25 10:43:08 +02:00
David Wood
e0590ea76f
RFC 2008: Stabilization
This commit stabilizes RFC 2008 (#44109) by removing the feature gate.

Signed-off-by: David Wood <david@davidtw.co>
2019-10-25 09:34:05 +01:00
bors
85943fd7c8 Auto merge of #65764 - Manishearth:clippyup, r=Manishearth
Update clippy

Fixes #65754

r? @ghost
2019-10-25 07:47:13 +00:00
bors
dd2df8f97d Auto merge of #65793 - Centril:rollup-v40xke9, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #62959 (Add by-value iterator for arrays )
 - #65390 (Add long error explanation for E0576)
 - #65408 (reorder config.toml.example options and add one missing option)
 - #65414 (ignore uninhabited non-exhaustive variant fields)
 - #65666 (Deprecated proc_macro doesn't trigger warning on build library)
 - #65742 (Pre-expansion gate most of the things)
 - #65747 (Adjust the tracking issue for `untagged_unions`.)
 - #65763 (Changed APIT with explicit generic args span to specific arg spans)
 - #65775 (Fix more `ReEmpty` ICEs)

Failed merges:

 - #65519 (trait-based structural match implementation)

r? @ghost
2019-10-25 04:24:40 +00:00
Mazdak Farrokhzad
100c924527
Rollup merge of #65775 - matthewjasper:reempty, r=pnkfelix
Fix more `ReEmpty` ICEs

closes #65553

r? @pnkfelix
2019-10-25 06:18:14 +02:00
Mazdak Farrokhzad
2b7cc64e43
Rollup merge of #65763 - ObsidianMinor:diag/65642, r=varkor
Changed APIT with explicit generic args span to specific arg spans

Fixes #65642.
2019-10-25 06:18:12 +02:00
Mazdak Farrokhzad
8b9661bbb0
Rollup merge of #65747 - Centril:union-issue-fix, r=varkor
Adjust the tracking issue for `untagged_unions`.

Makes https://github.com/rust-lang/rust/issues/55149 the new tracking issue for `untagged_unions`.
Closes https://github.com/rust-lang/rust/issues/32836 which is the old tracking issue.

r? @varkor
2019-10-25 06:18:11 +02:00
Mazdak Farrokhzad
d6a18b6baf
Rollup merge of #65742 - Centril:gate-pre-expansion-subset, r=davidtwco
Pre-expansion gate most of the things

This is a subset of https://github.com/rust-lang/rust/pull/64672. A crater run has already been done and this PR implements conclusions according to https://github.com/rust-lang/rust/pull/64672#issuecomment-542703363.

r? @davidtwco
cc @petrochenkov
2019-10-25 06:18:09 +02:00
Mazdak Farrokhzad
fb602c7e4f
Rollup merge of #65666 - XiangQingW:proc_macro, r=petrochenkov
Deprecated proc_macro doesn't trigger warning on build library

Fix #65189
2019-10-25 06:18:08 +02:00
Mazdak Farrokhzad
50e8c41a81
Rollup merge of #65414 - davidtwco:issue-65157-non-exhaustive-always-useful, r=varkor
ignore uninhabited non-exhaustive variant fields

Fixes #65157.

This PR modifies the uninhabitedness checking so that the fields of
a non-exhaustive variant (which is not local) are ignored if they are
uninhabited. This is an improvement over the previous behaviour which
considered all non-local non-exhaustive variants useful because
unreachable patterns are now detected.

r? @arielb1
cc @varkor
2019-10-25 06:18:06 +02:00
Mazdak Farrokhzad
ee7f9de4c4
Rollup merge of #65408 - guanqun:remove-rust-optimize, r=Mark-Simulacrum
reorder config.toml.example options and add one missing option

r? @Mark-Simulacrum
2019-10-25 06:18:04 +02:00
Mazdak Farrokhzad
e25720f106
Rollup merge of #65390 - GuillaumeGomez:long-err-explanation-E0576, r=matthewjasper,kinnison
Add long error explanation for E0576

Part of #61137.
2019-10-25 06:18:02 +02:00
Mazdak Farrokhzad
a302155344
Rollup merge of #62959 - LukasKalbertodt:array-value-iter, r=scottmcm
Add by-value iterator for arrays

This adds an iterator that can iterate over arrays by value, yielding all elements by value. However, **this PR does _not_ add a corresponding `IntoIterator` impl for arrays**. The `IntoIterator` impl needs some discussion about backwards-compatibility that should take place in a separate PR. With this patch, this code should work (but there is currently still a bug):

```rust
#![feature(array_value_iter)]
use std::array::IntoIter;

let arr = [1, 2, 3];
for x in IntoIter::new(arr) {
    println!("{}", x);
}
```

**TODO**:
- [x] Get initial feedback
- [x] Add tests
- [x] Figure out why stage1 produces weird bugs ([comment](https://github.com/rust-lang/rust/pull/62959#issuecomment-516016524))
- [x] Add UI tests as mentioned [here](https://github.com/rust-lang/rust/pull/62959#discussion_r307061894) (will do that soon-ish)
- [x] Fix [this new bug](https://github.com/rust-lang/rust/pull/62959#issuecomment-544732159)

**Notes for reviewers**
- Is the use of `MaybeUninit` correct here? I think it has to be used due to the `Clone` impl which has to fill the dead array elements with something, but cannot fill it with a correct instance.
- Are the unit tests sufficient?

CC #25725
2019-10-25 06:18:01 +02:00
Mazdak Farrokhzad
5ff7349ef7 move report_invalid_macro_expansion_item to item.rs 2019-10-25 05:26:36 +02:00
Mazdak Farrokhzad
0a5b38f9c3 move Attribute::with_desugared_doc to librustdoc 2019-10-25 04:38:42 +02:00
Mazdak Farrokhzad
d7f6ba83fc move panictry! to where it is used. 2019-10-25 04:29:37 +02:00