Commit Graph

103246 Commits

Author SHA1 Message Date
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
Nadrieril Feneanar
0f4c5fb20c
Apply suggestions from code review
Co-Authored-By: varkor <github@varkor.com>
2019-11-30 13:35:46 +00:00
bors
d8bdb3fdcb Auto merge of #66887 - dtolnay:rollup-uxowp8d, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #66818 (Format libstd/os with rustfmt)
 - #66819 (Format libstd/sys with rustfmt)
 - #66820 (Format libstd with rustfmt)
 - #66847 (Allow any identifier as format arg name)

Failed merges:

r? @ghost
2019-11-30 12:42:44 +00:00
Paul Dicker
d34090a10a Fill tracking issue 2019-11-30 12:58:15 +01:00
Paul Dicker
4843173a00 Document why as_mut_ptr is safe 2019-11-30 12:57:50 +01:00
Nixon
a52eb05ec6 Address review comments 2019-11-30 11:22:20 +00:00
Makoto Kato
d86d5ab08f Add crc and crypto to target feature whitelist on arm 2019-11-30 18:53:35 +09:00
Ralf Jung
7f20198632 pass Queries to compiler callbacks 2019-11-30 10:16:19 +01:00
Ralf Jung
02b66a1901 libunwind_panic: adjust miri panic hack 2019-11-30 10:13:25 +01:00
David Tolnay
f34990e9b5
Remove unneeded prelude imports in libcore tests
These three lines are from c82da7a54b in
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:

    #![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:

    #![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:

    error: unused import: `std::prelude::v1::*`
     --> src/main.rs:8:9
      |
    8 |     use std::prelude::v1::*;
      |         ^^^^^^^^^^^^^^^^^^^
2019-11-29 23:16:46 -08:00
Mazdak Farrokhzad
ded177a06a derive(Default) for Features 2019-11-30 07:44:50 +01:00
Mazdak Farrokhzad
79077f13ff move GateIssue to rustc_feature & simplify emit_feature_err 2019-11-30 07:40:28 +01:00
Mazdak Farrokhzad
91fcd40ca2 update rustc_feature crate docs 2019-11-30 06:43:32 +01:00
Mazdak Farrokhzad
b756b7d074 tidy: adjust feature gating path 2019-11-30 06:32:49 +01:00
David Tolnay
1c4d453969
Format liballoc with rustfmt 2019-11-29 20:25:07 -08:00
David Tolnay
28eb31f8dc
Make libcore/unicode/tables.rs compatible with rustfmt 2019-11-29 20:17:11 -08:00
David Tolnay
f4cff27792
Make libcore/unicode/printable.rs compatible with rustfmt 2019-11-29 20:17:10 -08:00
David Tolnay
d353a4c267
Make dec2flt_table compatible with rustfmt 2019-11-29 20:17:09 -08:00
cad97
52426ab42d
Use recursion_limit for const eval stack limit 2019-11-29 22:49:39 -05:00
David Tolnay
b14d9c2120
Rollup merge of #66847 - dtolnay:_fmt, r=joshtriplett
Allow any identifier as format arg name

Previously:

```console
error: invalid format string: invalid argument name `_x`
 --> src/main.rs:2:16
  |
2 |     println!("{_x}", _x=0);
  |                ^^ invalid argument name in format string
  |
  = note: argument names cannot start with an underscore
```

Not supporting identifiers starting with underscore appears to have been an arbitrary limitation from 2013 in code that was most likely never reviewed: https://github.com/rust-lang/rust/pull/8245/files#diff-0347868ef389c805e97636623e4a4ea6R277

The error message was dutifully improved in #50610 but is there any reason that leading underscore would be a special case?

This commit updates the format_args parser to accept identifiers with leading underscores.
2019-11-29 18:46:09 -08:00
David Tolnay
27710d28b7
Rollup merge of #66820 - dtolnay:fmt3, r=Dylan-DPC
Format libstd with rustfmt

(Same strategy as #66691.)

This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts, and are not part of libstd/os (#66818) or libstd/sys (#66819). The list of files involved in open PRs was 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/libstd -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of most of the rest of libstd.

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
2019-11-29 18:46:08 -08:00
David Tolnay
77b5a05026
Rollup merge of #66819 - dtolnay:fmt2, r=kennytm
Format libstd/sys with rustfmt

(Same strategy as #66691.)

This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd/sys *that are not involved in any currently open PR* to minimize merge conflicts. The list of files involved in open PRs was 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/libstd/sys -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd/sys outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of most of the rest of the files.

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
2019-11-29 18:46:06 -08:00
David Tolnay
34f2c2def4
Rollup merge of #66818 - dtolnay:fmt1, r=Dylan-DPC
Format libstd/os with rustfmt

(Same strategy as #66691.)

This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd/os *that are not involved in any currently open PR* to minimize merge conflicts. The list of files involved in open PRs was 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/libstd/os -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd/os outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of most of the rest of the files.

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
2019-11-29 18:46:05 -08:00
David Tolnay
9ad0850707
Bless ui test for libstd reformat 2019-11-29 18:43:27 -08:00
David Tolnay
4436c9d354
Format libstd with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd *that are not involved in any currently open PR* to
minimize merge conflicts. THe list of files involved in open PRs was
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/libstd -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of libstd.

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
2019-11-29 18:43:27 -08:00
David Tolnay
c34fbfaad3
Format libstd/sys with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd/sys *that are not involved in any currently open PR*
to minimize merge conflicts. THe list of files involved in open PRs was
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/libstd/sys -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd/sys outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of the files.

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
2019-11-29 18:37:58 -08:00
David Tolnay
60091ee826
Format libstd/os with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd/os *that are not involved in any currently open PR*
to minimize merge conflicts. THe list of files involved in open PRs was
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/libstd/os -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd/os outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of the files.

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
2019-11-29 18:32:46 -08:00
Mazdak Farrokhzad
9626181494 check.rs: inline a constant 2019-11-30 03:30:49 +01:00
bors
8f1bbd69e1 Auto merge of #66873 - RalfJung:miri-args, r=dtolnay
really_init cmdline args on Miri

r? @joshtriplett

Closes #66862.
2019-11-30 02:12:19 +00:00
Mazdak Farrokhzad
b45f21d38e move UnstableFeatures -> rustc_feature 2019-11-30 02:50:47 +01:00
Mazdak Farrokhzad
db89679ebc inline two explanation constants 2019-11-30 02:40:45 +01:00
Mazdak Farrokhzad
70234f16df builtin_attrs.rs -> rustc_feature 2019-11-30 02:34:18 +01:00
Mazdak Farrokhzad
d04b838a44 move is_builtin_attr to syntax::attr 2019-11-30 02:20:07 +01:00
Mazdak Farrokhzad
4d9fde59ae builtin_attrs: inline some strings 2019-11-30 02:03:32 +01:00
Mazdak Farrokhzad
6cab02cf14 simplify gated cfgs logic 2019-11-30 01:57:53 +01:00
Mazdak Farrokhzad
8ad4d15f38 move AttributeTemplate to builtin_attrs 2019-11-30 00:56:46 +01:00
Mazdak Farrokhzad
048201fa7a move Stability to rustc_feature 2019-11-30 00:39:51 +01:00
Eduard-Mihai Burtescu
a9976d89ed rustc: move mir::SourceScopeLocalData to a field of SourceScopeData. 2019-11-30 01:37:42 +02:00
Eduard-Mihai Burtescu
78d85fcf52 rustc_mir: fix inliner to also copy over source_scope_local_data. 2019-11-30 01:36:51 +02:00
Eduard-Mihai Burtescu
30a9978c6c rustc: move MIR source_scope_local_data's ClearCrossCrate to be around elements. 2019-11-30 01:36:51 +02:00
Mazdak Farrokhzad
3d080a4a77 introduce crate rustc_feature and move active, accepted, and removed to it 2019-11-30 00:25:40 +01:00
Eduard-Mihai Burtescu
584ede5f30 rustc_typeck: gate AnonConst's generics on feature(const_generics). 2019-11-30 01:15:15 +02:00
Eduard-Mihai Burtescu
de30d31976 rustc: fix ty::Const::eval's handling of inference variables. 2019-11-30 01:13:47 +02:00