Commit Graph

103403 Commits

Author SHA1 Message Date
Ralf Jung
96ea142c89 make alloc_extra machine hook a bit nicer 2019-12-02 09:03:16 +01:00
Ralf Jung
c8743dbe51 add and use helper method to get SourceInfo of current instruction in frame 2019-12-02 09:03:16 +01:00
Ralf Jung
56356a0745 Miri: add helper fn to allocate string; simplify alloc_caller_location 2019-12-02 08:55:42 +01:00
Ralf Jung
cde17d9158 Add From instances for Pointer -> ScalarMaybeUndef and Pointer -> Immediate 2019-12-02 08:55:42 +01:00
Ralf Jung
a8eea623f5 expose span to M::assert_panic, and provide helper to turn that into CallerLocation 2019-12-02 08:55:42 +01:00
Ralf Jung
b1aa3cac5b Miri: add machine hook for MIR-level assertion panics 2019-12-02 08:55:42 +01:00
bors
f5c81e0a98 Auto merge of #66944 - Centril:rollup-ojsszx6, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #66346 (Replace .unwrap() with ? in std::os::unix::net)
 - #66789 (rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.)
 - #66850 (rustc: hide HirId's fmt::Debug output from -Z span_free_formats.)
 - #66905 (rustc_plugin: Remove some remaining plugin features)
 - #66907 (rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.)
 - #66918 (Add crc and crypto to target feature whitelist on arm)
 - #66926 (add reusable MachineStop variant to Miri engine error enum)

Failed merges:

r? @ghost
2019-12-02 03:09:36 +00:00
Mazdak Farrokhzad
cd47551a0e
Rollup merge of #66926 - RalfJung:miri-stop, r=oli-obk
add reusable MachineStop variant to Miri engine error enum

Replace the Miri-tool-specific `Exit` error variant with something dynamically typed that all clients of the Miri engine can use.

r? @oli-obk
Cc https://github.com/rust-lang/rust/issues/66902
2019-12-02 04:09:07 +01:00
Mazdak Farrokhzad
427e3690f5
Rollup merge of #66918 - makotokato:aarch32-crc-crypto, r=petrochenkov
Add crc and crypto to target feature whitelist on arm

aarch32 (ARMv8 32-bit) supports crc and crypto.
2019-12-02 04:09:06 +01:00
Mazdak Farrokhzad
319064f469
Rollup merge of #66907 - eddyb:br-nicer-named, r=oli-obk
rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.

Context: these `fmt::Debug` impls only get used with `-Z verbose` (which some tests use).

I was going to print the path like in #66850 (or rather, use `DefId`'s `fmt::Debug`, which is close but not as nice), but then I realized that most of the `DefId`s were `crate0:DefIndex(0)`, i.e. the crate root.
As the crate root is not a lifetime, they're clearly dummies of some sort, and we don't have to print anything other than the name for them.

This means that out of all the tests, there's only 5 instances of `BrNamed` that now print the full path to the lifetime parameter, and everything else is shorter instead, which doesn't feel too bad.

cc @nikomatsakis
2019-12-02 04:09:04 +01:00
Mazdak Farrokhzad
90ac08222a
Rollup merge of #66905 - petrochenkov:rmplugin2, r=Centril
rustc_plugin: Remove some remaining plugin features

- Plugin arguments (`#![plugin(my_plugin(args))]`) are no longer supported.
- Registering additional plugins from command line (`-Z extra-plugins=my_plugin`) is no longer supported, `-Z crate-attr=plugin(my_plugin)` can be used instead.
- Lint `plugin_as_library` is removed as mostly useless now, when plugins exist as a compatibility feature with greatly reduced functionality.
- Plugins registering additional LLVM passes (`Registry::register_llvm_pass`) are no longer supported, `-C                   passes=my_passes` can be used instead.

r? @Centril
2019-12-02 04:09:03 +01:00
Mazdak Farrokhzad
dbe880e8ec
Rollup merge of #66850 - eddyb:span-free-formats, r=oli-obk
rustc: hide HirId's fmt::Debug output from -Z span_free_formats.

This replaces the only occurrences of `HirId {...}` from tests with paths, i.e.:
```rust
[closure@HirId { owner: DefIndex(4), local_id: 15 } q:&i32, t:&T]
```
becomes, after this PR:
```rust
[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]
```

r? @oli-obk cc @michaelwoerister
2019-12-02 04:09:01 +01:00
Mazdak Farrokhzad
fd09fad064
Rollup merge of #66789 - eddyb:mir-source-scope-local-data, r=oli-obk
rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.

By having one `ClearCrossCrate<SourceScopeLocalData>` for each scope, as opposed to a single `ClearCrossCrate` for all the `SourceScopeLocalData`s, we can represent the fact that some scopes have `SourceScopeLocalData` associated with them, and some don't.

This is useful when doing MIR inlining across crates, because the `ClearCrossCrate` will be `Clear` for the cross-crate MIR scopes and `Set` for the local ones.

Also see https://github.com/rust-lang/rust/pull/66203#issuecomment-555589574 for some context around this approach.

Fixes #51314.
2019-12-02 04:09:00 +01:00
Mazdak Farrokhzad
a279ebbc91
Rollup merge of #66346 - linkmauve:try-in-docstring, r=Dylan-DPC
Replace .unwrap() with ? in std::os::unix::net

As people like to copy examples, this gives them good habits.
2019-12-02 04:08:55 +01:00
Devin R
e638f7c1ab add grammer fixes 2019-12-01 19:47:54 -05:00
cad97
ac57e1b647
Remove ord lang item 2019-12-01 16:09:07 -05:00
Dylan MacKenzie
ccb4eed352 Incorporate fixes from review 2019-12-01 11:43:24 -08:00
Vadim Petrochenkov
e5944a5a69 rustc_plugin: Some further cleanup
Remove a useless test
2019-12-01 20:53:25 +03:00
Vadim Petrochenkov
279937812a rustc_plugin: Remove support for plugins adding LLVM passes 2019-12-01 20:53:25 +03:00
Vadim Petrochenkov
cf1ffb0355 rustc_lint: Remove lint plugin_as_library 2019-12-01 20:53:25 +03:00
Vadim Petrochenkov
db357a6e3b rustc_plugin: Remove support for adding plugins from command line 2019-12-01 20:53:25 +03:00
Vadim Petrochenkov
55ba05bd0d rustc_plugin: Remove support for plugin arguments 2019-12-01 20:53:25 +03:00
Ralf Jung
4b81dd43e0 add reusable MachineStop variant to Miri engine error enum 2019-12-01 11:49:40 +01:00
Tomasz Miąsko
c703ff2655 Conditional compilation for sanitizers
Configure sanitize option when compiling with a sanitizer to make
it possible to execute different code depending on whether given
sanitizer is enabled or not.
2019-12-01 09:03:35 +01:00
bors
4007d4ef26 Auto merge of #66917 - Centril:rollup-xj2enik, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #66503 (More useful test error messages on should_panic(expected=...) mismatch)
 - #66662 (Miri: run panic-catching tests in liballoc)
 - #66679 (Improve lifetime errors with implicit trait object lifetimes)
 - #66726 (Use recursion_limit for const eval stack limit)
 - #66790 (Do `min_const_fn` checks for `SetDiscriminant`s target)
 - #66832 (const_prop: detect and avoid catching Miri errors that require allocation)
 - #66880 (Add long error code explanation message for E0203)
 - #66890 (Format liballoc with rustfmt)
 - #66896 (pass Queries to compiler callbacks)

Failed merges:

r? @ghost
2019-12-01 06:00:33 +00:00
Mazdak Farrokhzad
bed4c09d21
Rollup merge of #66896 - RalfJung:queries, r=Zoxc
pass Queries to compiler callbacks

https://github.com/rust-lang/rust/pull/66791 made it impossible to access the tcx in the callbacks; this should fix that.

r? @Zoxc
2019-12-01 04:49:32 +01:00
Mazdak Farrokhzad
3db3f156f1
Rollup merge of #66890 - dtolnay:fmt4, r=Dylan-DPC
Format liballoc with rustfmt

Same strategy as #66691 -- as with my previous formatting PRs, I am avoiding causing merge conflicts in other PRs by only touches those files that are not involved in any currently open PR. Files that appear in new PRs between when this PR is opened and when it makes it to the top of the bors queue will be reverted from this PR.

The list of files involved in open PRs is determined by querying GitHub's GraphQL API [with this script](https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8).

With the list of files from the script in outstanding_files, the relevant commands were:

```
$ find src/liballoc -name '*.rs' \
    | xargs rustfmt --edition=2018 --unstable-features --skip-children
$ rg liballoc outstanding_files | xargs git checkout --
```

To confirm no funny business:

```
$ git checkout $THIS_COMMIT^
$ git show --pretty= --name-only $THIS_COMMIT \
    | xargs rustfmt --edition=2018 --unstable-features --skip-children
$ git diff $THIS_COMMIT  # there should be no difference
```

r? @Dylan-DPC
2019-12-01 04:49:31 +01:00
Mazdak Farrokhzad
d4f59564e7
Rollup merge of #66880 - aDotInTheVoid:add-E0203-long, r=GuillaumeGomez
Add long error code explanation message for E0203

Addressed some of #61137

r? @GuillaumeGomez
2019-12-01 04:49:29 +01:00
Mazdak Farrokhzad
d91e63b7a2
Rollup merge of #66832 - RalfJung:const-prop-no-alloc, r=oli-obk
const_prop: detect and avoid catching Miri errors that require allocation

r? @wesleywiser @oli-obk
2019-12-01 04:49:27 +01:00
Mazdak Farrokhzad
75fd413e7b
Rollup merge of #66790 - christianpoveda:check-set-discriminant, r=oli-obk
Do `min_const_fn` checks for `SetDiscriminant`s target

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

r? @oli-obk @ecstatic-morse
2019-12-01 04:49:26 +01:00
Mazdak Farrokhzad
60f4212ee5
Rollup merge of #66726 - CAD97:miri-recursion-limit, r=RalfJung
Use recursion_limit for const eval stack limit

cc https://github.com/rust-lang/miri/issues/643 @orium @RalfJung

I'm really not certain how exactly to handle this change, but it looks like it's that simple.

Reuse `recursion_limit` ("The maximum recursion limit for potentially infinitely recursive operations such as auto-dereference and monomorphization") which is configurable by the user for the const evaluation stack frame limit.

The other option is to make `const_eval_stack_frame_limit` configurable in the same way as `recursion_limit` (but I'm not sure how to do that and it'd be a bigger change).

Fixes https://github.com/rust-lang/miri/issues/643.
2019-12-01 04:49:24 +01:00
Mazdak Farrokhzad
99f9fa3695
Rollup merge of #66679 - mark-i-m:fix-anon-lifetime-errors, r=matthewjasper
Improve lifetime errors with implicit trait object lifetimes

r? @matthewjasper

cc @estebank

I still think the ideal solution would be to construct a `BrAnon`, but that seems like a more invasive change, and can be done later. This at least gets rid of the hack in `OutliveSuggestion` and is slightly more principled.
2019-12-01 04:49:23 +01:00
Mazdak Farrokhzad
cb43d82fd6
Rollup merge of #66662 - RalfJung:miri-test-liballoc, r=dtolnay
Miri: run panic-catching tests in liballoc

I also converted two tests from using `thread::spawn(...).join()` just for catching panics, to `catch_panic`, so that Miri can run them.
2019-12-01 04:49:21 +01:00
Mazdak Farrokhzad
6110d3ebc8
Rollup merge of #66503 - thomasetter:panic-error-msg, r=joshtriplett
More useful test error messages on should_panic(expected=...) mismatch

Fixes  #66304
r? @gilescope

Shows both the actual as well as the expected panic value when a test with `should_panic(expected=...)` fails.
This makes `should_panic` more consistent with `assert_eq`.

I am not sure whether printing the `Any::type_id()` is useful, is there something better that we could print for non-string panic values?
2019-12-01 04:49:19 +01:00
Ximin Luo
0533249fd7 rustbuild: don't clobber RUSTFLAGS, append to it 2019-12-01 00:53:25 +00:00
Ximin Luo
a9dca3b243 rustbuild: fix cross-compile install
although, not sure why this works - it wasn't needed before
2019-12-01 00:53:25 +00:00
bors
135ccbaca8 Auto merge of #66908 - Centril:rollup-26givp6, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #66612 (Initial implementation of or-pattern usefulness checking)
 - #66705 (Atomic as_mut_ptr)
 - #66759 (impl TrustedLen for vec::Drain)
 - #66858 (Use LLVMAddAnalysisPasses instead of Rust's wrapper)
 - #66870 (SimplifyArmIdentity only for locals with the same type)
 - #66883 (rustc_typeck: gate AnonConst's generics on feature(const_generics).)
 - #66889 (Make python-generated source files compatible with rustfmt)
 - #66894 (Remove unneeded prelude imports in libcore tests)
 - #66895 (Feature gating *declarations* => new crate `rustc_feature`)

Failed merges:

 - #66905 (rustc_plugin: Remove some remaining plugin features)

r? @ghost
2019-12-01 00:39:18 +00:00
Devin R
7c3befc7f9 add ";" for let = match 2019-11-30 18:02:19 -05:00
Devin R
c69be483d6 fix doc compile fail 2019-11-30 17:32:49 -05:00
Christian Poveda
2ced9d96e7 Merge match branches 2019-11-30 12:25:45 -05:00
Mazdak Farrokhzad
b772b5b19d
Rollup merge of #66895 - Centril:rustc_feature, r=oli-obk
Feature gating *declarations* => new crate `rustc_feature`

This PR moves the data-oriented parts of feature gating into its own crate, `rustc_feature`.
The parts consist of some data types as well as `accepted`, `active`, `removed`, and `builtin_attrs`.

Feature gate checking itself remains in `syntax::feature_gate::check`. The parts which define how to emit feature gate errors could probably be moved to `rustc_errors` or to the new `rustc_session` crate introduced in #66878. The visitor itself could probably be moved as a pass in `rustc_passes` depending on how the dependency edges work out.

The PR also contains some drive-by cleanup of feature gate checking. As such, the PR probably best read commit-by-commit.

r? @oli-obk
cc @petrochenkov
cc @Mark-Simulacrum
2019-11-30 16:56:58 +01:00
Mazdak Farrokhzad
b4bffcebca
Rollup merge of #66894 - dtolnay:prelude, r=Centril
Remove unneeded prelude imports in libcore tests

These three lines are from c82da7a54b dating back to 2015.

They cause problems when applying rustfmt to the codebase, because reordering wildcard imports can trigger new unused import warnings.

As a minimized example, the following program compiles successfully:

```rust
#![deny(unused_imports)]

use std::fmt::Debug;
use std::marker::Send;

pub mod repro {
    use std::prelude::v1::*;
    use super::*;

    pub type D = dyn Debug;
    pub type S = dyn Send;
}

pub type S = dyn Send;
```

but putting it through rustfmt produces a program that fails to compile:

```rust
#![deny(unused_imports)]

use std::fmt::Debug;
use std::marker::Send;

pub mod repro {
    use super::*;
    use std::prelude::v1::*;

    pub type D = dyn Debug;
    pub type S = dyn Send;
}

pub type S = dyn Send;
```

The error is:

```console
error: unused import: `std::prelude::v1::*`
 --> src/main.rs:8:9
  |
8 |     use std::prelude::v1::*;
  |         ^^^^^^^^^^^^^^^^^^^
```
2019-11-30 16:56:56 +01:00
Mazdak Farrokhzad
2e83c6d114
Rollup merge of #66889 - dtolnay:fmt6, r=rkruppe
Make python-generated source files compatible with rustfmt

This PR adjusts the generators for src/libcore/num/dec2flt/table.rs, src/libcore/unicode/printable.rs, and src/libcore/unicode/tables.rs to make it so running `rustfmt` on the generated files no longer needs to apply any changes.

This involves tweaking the python scripts where reasonable to better match rustfmt's style, and adding `#[rustfmt::skip]` to big constant tables that there's no point having rustfmt rewrap.

r? @Dylan-DPC
2019-11-30 16:56:55 +01:00
Mazdak Farrokhzad
c85f63561e
Rollup merge of #66883 - eddyb:we-cant-have-nice-things, r=oli-obk
rustc_typeck: gate AnonConst's generics on feature(const_generics).

This PR employs the fix for #43408 when `#![feature(const_generics)]` is enabled, making the feature-gate the opt-in for all the possible breakage this may incur.

For example, if this PR lands, this will cause a cycle error (due to #60471):
```rust
#![feature(const_generics)]

fn foo<T: Into<[u8; 4]>>() {}
```
And so will anything with type-level const expressions, in its bounds.
Surprisingly, `impl`s don't seem to be affected (if they were, even libcore wouldn't compile).

One thing I'm worried about is not knowing how much unstable code out there, using const-generics, will be broken. But types like `Foo<{N+1}>` never really worked, and do after this PR, just not in bounds - so ironically, it's type-level const expressions that don't depend on generics, which will break (in bounds).

Also, if we do this, we'll have effectively blocked stabilization of const generics on #60471.

r? @oli-obk cc @varkor @yodaldevoid @nikomatsakis
2019-11-30 16:56:53 +01:00
Mazdak Farrokhzad
472bee260e
Rollup merge of #66870 - tmiasko:simplify-ty, r=oli-obk
SimplifyArmIdentity only for locals with the same type

Fixes #66856
Fixes #66851
2019-11-30 16:56:52 +01:00
Mazdak Farrokhzad
237865181b
Rollup merge of #66858 - 0dvictor:capi, r=rkruppe
Use LLVMAddAnalysisPasses instead of Rust's wrapper

LLVM exposes a C API `LLVMAddAnalysisPasses` and hence Rust's own wrapper `LLVMRustAddAnalysisPasses` is not needed anymore.
2019-11-30 16:56:50 +01:00
Mazdak Farrokhzad
9ae7fb3e71
Rollup merge of #66759 - CAD97:patch-3, r=KodrAus
impl TrustedLen for vec::Drain

The iterator methods just forward to `slice::Iter`, which is `TrustedLen`.

This can probably be applied to other `Drain` structs as well.
2019-11-30 16:56:49 +01:00
Mazdak Farrokhzad
123406cac7
Rollup merge of #66705 - pitdicker:atomic_mut_ptr, r=KodrAus
Atomic as_mut_ptr

I encountered the following pattern a few times: In Rust we use some atomic type like `AtomicI32`, and an FFI interface exposes this as `*mut i32` (or some similar `libc` type).

It was not obvious to me if a just transmuting a pointer to the atomic was acceptable, or if this should use a cast that goes through an `UnsafeCell`. See https://github.com/rust-lang/rust/issues/66136#issuecomment-557802477

Transmuting the pointer directly:
```rust
let atomic = AtomicI32::new(1);
let ptr = &atomic as *const AtomicI32 as *mut i32;
unsafe {
    ffi(ptr);
}
```

A dance with `UnsafeCell`:
```rust
let atomic = AtomicI32::new(1);
unsafe {
    let ptr = (&*(&atomic as *const AtomicI32 as *const UnsafeCell<i32>)).get();
    ffi(ptr);
}
```

Maybe in the end both ways could be valid. But why not expose a direct method to get a pointer from the standard library?

An `as_mut_ptr` method on atomics can be safe, because only the use of the resulting pointer is where things can get unsafe. I documented its use for FFI, and "Doing non-atomic reads and writes on the resulting integer can be a data race."

The standard library could make use this method in a few places in the WASM module.

cc @RalfJung as you answered my original question.
2019-11-30 16:56:47 +01:00
Mazdak Farrokhzad
3af14f994d
Rollup merge of #66612 - Nadrieril:or-patterns-initial, r=varkor
Initial implementation of or-pattern usefulness checking

The title says it all.
I'd like to request a perf run on that, hopefully this doesn't kill performance too much.

cc https://github.com/rust-lang/rust/issues/54883
2019-11-30 16:56:45 +01:00
Eduard-Mihai Burtescu
9034efe3f7 rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl. 2019-11-30 17:29:56 +02:00