Commit Graph

88936 Commits

Author SHA1 Message Date
Vardhan Thigle
99fbd1bf11 Fix breakage from #56988 and workaround for #57569 2019-01-13 13:07:45 +05:30
Vardhan Thigle
4a957b320d Adding Build automation for x86_64-fortanix-unknown-sgx 2019-01-13 13:07:45 +05:30
Taiki Endo
da933cca1a Change #[must_use] message of Iterator in documentation 2019-01-13 15:17:57 +09:00
Taiki Endo
a6535d78dc Change #[must_use] message of Iterator 2019-01-13 14:46:42 +09:00
Mazdak Farrokhzad
6d7a4a6e4c stabilize transpose_result in 1.33 2019-01-13 06:15:44 +01:00
Mazdak Farrokhzad
3e2dcf95ce
Rollup merge of #57564 - varkor:update-const_fn-tracking-issue, r=Centril
Update the const fn tracking issue to the new metabug

The new `const fn` tracking issue is #57563. We don't want to point to a closed issue in the diagnostics (or FIXMEs), so these have been updated (from the old issue, #24111).

r? @Centril
2019-01-13 05:27:01 +01:00
Mazdak Farrokhzad
33c5874966
Rollup merge of #57560 - petrochenkov:selfinmac, r=alexreg
hygiene: Do not treat `Self` ctor as a local variable

Fixes https://github.com/rust-lang/rust/issues/57523
2019-01-13 05:27:00 +01:00
Mazdak Farrokhzad
c04d6fa084
Rollup merge of #57557 - petrochenkov:ecused, r=varkor
resolve: Mark extern crate items as used in more cases

Fixes https://github.com/rust-lang/rust/issues/57421
2019-01-13 05:26:59 +01:00
Mazdak Farrokhzad
8c1813d3e1
Rollup merge of #57547 - Xanewok:ptr-eq, r=petrochenkov
Use `ptr::eq` where applicable

Stumbled upon a few of `A as *const _ as usize == B as *const as usize`, so I decided to follow the programming boy scout rule (😄) and replaced the pattern with more widely used `ptr::eq`.
2019-01-13 05:26:58 +01:00
Mazdak Farrokhzad
8f11da4bfc
Rollup merge of #57508 - DebugSteven:inline-extern, r=GuillaumeGomez
rustdoc: Allow inlining of reexported crates and crate items

Fixes #46296

This PR checks for when a `pub extern crate` statement has a `#[doc(inline)]` attribute & inlines its contents. Code is based off of the inlining statements for `pub use` statements.
2019-01-13 05:26:57 +01:00
Mazdak Farrokhzad
ce448f364a
Rollup merge of #57496 - steveklabnik:gh32934, r=Centril
re-do docs for core::cmp

Fixes #32934
2019-01-13 05:26:55 +01:00
Mazdak Farrokhzad
4d6fd9cfb7
Rollup merge of #57494 - dotdash:expand, r=nikomatsakis
Speed up item_bodies for large match statements involving regions

These changes don't change anything about the complexity of the algorithms, but use some easy shortcuts or modifications to cut down some overhead.

The first change, which incrementally removes the constraints from the set we're iterating over probably introduces some overhead for small to medium sized constraint sets, but it's not big enough for me to observe it in any project I tested against (not that many though).

Though most other crates probably won't improve much at all, because huge matches aren't that common, the changes seemed simple enough for me to make them.

Ref #55528

cc unicode-rs/unicode-normalization#29

r? @nikomatsakis
2019-01-13 05:26:54 +01:00
Mazdak Farrokhzad
edec83835a
Rollup merge of #57474 - emilio:save-analysis-path, r=nrc
save-analysis: Get path def from parent in case there's no def for the path itself.

This fixes #57462.

The relevant part from the hir type collector is:

```
DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(32) => Entry { parent: NodeId(33), dep_node: 4294967040, node: Expr(expr(32: <Foo>::new)) }
DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(48) => Entry { parent: NodeId(32), dep_node: 4294967040, node: Ty(type(Foo)) }
DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(30) => Entry { parent: NodeId(48), dep_node: 4294967040, node: PathSegment(PathSegment { ident: Foo#0, id: Some(NodeId(30)), def: Some(Err), args: None, infer_types: true }) }
DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(31) => Entry { parent: NodeId(32), dep_node: 4294967040, node: PathSegment(PathSegment { ident: new#0, id: Some(NodeId(31)), def: Some(Err), args: None, infer_types: true }) }
```

We have the right ID when looking for NodeId(31) and try with NodeId(32) (which
is the right thing to look for) from get_path_data. But not when we look from `write_sub_paths_truncated`

Basically process_path takes an id which is always the parent, and that we
fall back to in get_path_data(), so we get the right result for the last path
segment, but not for the other segments that get written to from
write_sub_paths_truncated.

I think we can stop passing the explicit `id` around to get_path_data as a followup.
2019-01-13 05:26:53 +01:00
Mazdak Farrokhzad
b3290fd14c
Rollup merge of #57473 - alexcrichton:hex-display-on-windows, r=Kimundi
std: Render large exit codes as hex on Windows

On Windows process exit codes are never signals but rather always 32-bit
integers. Most faults like segfaults and such end up having large
integers used to represent them, like STATUS_ACCESS_VIOLATION being
0xC0000005. Currently, however, when an `ExitStatus` is printed this
ends up getting rendered as 3221225477 which is somewhat more difficult
to debug.

This commit adds a branch in `Display for ExitStatus` on Windows which
handles exit statuses where the high bit is set and prints those exit
statuses as hex instead of with decimals. This will hopefully preserve
the current display for small exit statuses (like `exit code: 22`), but
assist in quickly debugging segfaults/access violations/etc. I've
found at least that the hex codes are easier to search for than decimal.

I wasn't able to find any official documentation saying that all system
exit codes have the high bit set, but I figure it's a good enough
heuristic for now.
2019-01-13 05:26:52 +01:00
Mazdak Farrokhzad
0c53b45e85
Rollup merge of #57461 - nnethercote:ParseResult-Failure-static-str, r=simulacrum
Change `String` to `&'static str` in `ParseResult::Failure`.

This avoids 770,000 allocations when compiling the `html5ever`
benchmark, reducing instruction counts by up to 2%.
2019-01-13 05:26:51 +01:00
Mazdak Farrokhzad
b7093e51c9
Rollup merge of #57454 - sinkuu:fmt_cleanup, r=joshtriplett
Some cleanups for core::fmt
2019-01-13 05:26:49 +01:00
Mazdak Farrokhzad
36c7cde9e0
Rollup merge of #57453 - cuviper:python3-thread, r=nikomatsakis
lldb_batchmode.py: try `import _thread` for Python 3

None
2019-01-13 05:26:48 +01:00
Mazdak Farrokhzad
8e3980b8e8
Rollup merge of #57436 - Xanewok:save-analysis-access-ice-fix, r=nikomatsakis
save-analysis: use a fallback when access levels couldn't be computed

Fixing an RLS regression I introduced in https://github.com/rust-lang/rust/pull/57343 😢

I missed a case where we get [called back with analysis when type checking fails](9d54812829/src/librustc_driver/driver.rs (L1264)). Since privacy checking normally is done afterwards, when we execute the `privacy_access_levels` query inside the save_analysis callback we'll calculate it for the first time and since typeck info isn't complete, we'll crash there.

Double-checked locally and it seems to have fixed the problem.

r? @nikomatsakis
2019-01-13 05:26:47 +01:00
Mazdak Farrokhzad
d3cb51c870
Rollup merge of #57412 - JohnTitor:improve-the-wording-1, r=varkor
Improve the wording

I'm sorry but re-opened the PR because I failed to squash commits(#57397).

Fixes #55752.
r? @varkor
2019-01-13 05:26:46 +01:00
Mazdak Farrokhzad
5560d4d6d7
Rollup merge of #57353 - huonw:faster-finiteness-checks, r=KodrAus
Optimise floating point `is_finite` (2x) and `is_infinite` (1.6x).

These can both rely on IEEE754 semantics to be made faster, by folding
away the sign with an abs (left private for now), and then comparing
to infinity, letting the NaN semantics of a direct float comparison
handle NaN input properly.

The `abs` bit-fiddling is simple (a single and), and so these new
forms compile down to a few instructions, without branches, e.g. for
f32:

```asm
is_infinite:
        andps   xmm0, xmmword ptr [rip + .LCPI2_0] ; 0x7FFF_FFFF
        ucomiss xmm0, dword ptr [rip + .LCPI2_1]   ; 0x7F80_0000
        setae   al
        ret

is_finite:
        andps   xmm0, xmmword ptr [rip + .LCPI1_0] ; 0x7FFF_FFFF
        movss   xmm1, dword ptr [rip + .LCPI1_1]   ; 0x7F80_0000
        ucomiss xmm1, xmm0
        seta    al
        ret
```

When used in loops/repeatedly, they get even better: the memory
operations (loading the mask 0x7FFFFFFF for abs, and infinity
0x7F80_0000) are likely to be hoisted out of the individual calls, to
be shared, and the `seta`/`setae` are likely to be collapsed into
conditional jumps or moves (or similar).

The old `is_infinite` did two comparisons, and the old `is_finite` did
three (with a branch), and both of them had to check the flags after
every one of those comparison. These functions have had that old
implementation since they were added in
6284190ef9
7 years ago.

Benchmark (`abs` is the new form, `std` is the old):

```
test f32_is_finite_abs            ... bench:          55 ns/iter (+/- 10)
test f32_is_finite_std            ... bench:         118 ns/iter (+/- 5)

test f32_is_infinite_abs          ... bench:          53 ns/iter (+/- 1)
test f32_is_infinite_std          ... bench:          84 ns/iter (+/- 6)

test f64_is_finite_abs            ... bench:          52 ns/iter (+/- 12)
test f64_is_finite_std            ... bench:         128 ns/iter (+/- 25)

test f64_is_infinite_abs          ... bench:          54 ns/iter (+/- 5)
test f64_is_infinite_std          ... bench:          93 ns/iter (+/- 23)
```

```rust
 #![feature(test)]
extern crate test;

use std::{f32, f64};
use test::Bencher;

const VALUES_F32: &[f32] = &[0.910, 0.135, 0.735, -0.874, 0.518, 0.150, -0.527, -0.418, 0.449, -0.158, -0.064, -0.144, -0.948, -0.103, 0.225, -0.104, -0.795, 0.435, 0.860, 0.027, 0.625, -0.848, -0.454, 0.359, -0.930, 0.067, 0.642, 0.976, -0.682, -0.035, 0.750, 0.005, -0.825, 0.731, -0.850, -0.740, -0.118, -0.972, 0.888, -0.958, 0.086, 0.237, -0.580, 0.488, 0.028, -0.552, 0.302, 0.058, -0.229, -0.166, -0.248, -0.430, 0.789, -0.122, 0.120, -0.934, -0.911, -0.976, 0.882, -0.410, 0.311, -0.611, -0.758, 0.786, -0.711, 0.378, 0.803, -0.068, 0.932, 0.483, 0.085, 0.247, -0.128, -0.839, -0.737, -0.605, 0.637, -0.230, -0.502, 0.231, -0.694, -0.400, -0.441, 0.142, 0.174, 0.681, -0.763, -0.608, 0.848, -0.550, 0.883, -0.212, 0.876, 0.186, -0.909, 0.401, -0.533, -0.961, 0.539, -0.298, -0.448, 0.223, -0.307, -0.594, 0.629, -0.534, 0.959, 0.349, -0.926, -0.523, -0.895, -0.157, -0.074, -0.060, 0.513, -0.647, -0.649, 0.428, 0.401, 0.391, 0.426, 0.700, 0.880, -0.101, 0.862, 0.493, 0.819, -0.597];

 #[bench]
fn f32_is_infinite_std(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F32).iter().any(|x| x.is_infinite()));
}
 #[bench]
fn f32_is_infinite_abs(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F32).iter().any(|x| x.abs()== f32::INFINITY));
}
 #[bench]
fn f32_is_finite_std(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F32).iter().all(|x| x.is_finite()));
}
 #[bench]
fn f32_is_finite_abs(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F32).iter().all(|x| x.abs() < f32::INFINITY));
}

const VALUES_F64: &[f64] = &[0.910, 0.135, 0.735, -0.874, 0.518, 0.150, -0.527, -0.418, 0.449, -0.158, -0.064, -0.144, -0.948, -0.103, 0.225, -0.104, -0.795, 0.435, 0.860, 0.027, 0.625, -0.848, -0.454, 0.359, -0.930, 0.067, 0.642, 0.976, -0.682, -0.035, 0.750, 0.005, -0.825, 0.731, -0.850, -0.740, -0.118, -0.972, 0.888, -0.958, 0.086, 0.237, -0.580, 0.488, 0.028, -0.552, 0.302, 0.058, -0.229, -0.166, -0.248, -0.430, 0.789, -0.122, 0.120, -0.934, -0.911, -0.976, 0.882, -0.410, 0.311, -0.611, -0.758, 0.786, -0.711, 0.378, 0.803, -0.068, 0.932, 0.483, 0.085, 0.247, -0.128, -0.839, -0.737, -0.605, 0.637, -0.230, -0.502, 0.231, -0.694, -0.400, -0.441, 0.142, 0.174, 0.681, -0.763, -0.608, 0.848, -0.550, 0.883, -0.212, 0.876, 0.186, -0.909, 0.401, -0.533, -0.961, 0.539, -0.298, -0.448, 0.223, -0.307, -0.594, 0.629, -0.534, 0.959, 0.349, -0.926, -0.523, -0.895, -0.157, -0.074, -0.060, 0.513, -0.647, -0.649, 0.428, 0.401, 0.391, 0.426, 0.700, 0.880, -0.101, 0.862, 0.493, 0.819, -0.597];

 #[bench]
fn f64_is_infinite_std(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F64).iter().any(|x| x.is_infinite()));
}
 #[bench]
fn f64_is_infinite_abs(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F64).iter().any(|x| x.abs() == f64::INFINITY));
}
 #[bench]
fn f64_is_finite_std(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F64).iter().all(|x| x.is_finite()));
}
 #[bench]
fn f64_is_finite_abs(b: &mut Bencher) {
    b.iter(|| test::black_box(VALUES_F64).iter().all(|x| x.abs() < f64::INFINITY));
}
```
2019-01-13 05:26:44 +01:00
Mazdak Farrokhzad
035eff1c1f
Rollup merge of #57351 - oli-obk:cheap_const_ops, r=RalfJung
Don't actually create a full MIR stack frame when not needed

r? @dotdash

This should significantly reduce overhead during const propagation and reduce overhead *after* copy propagation (cc https://github.com/rust-lang/rust/issues/36673)
2019-01-13 05:26:43 +01:00
Alexander Regueiro
b172e89c14 Minor cosmetic changes 2019-01-13 04:58:18 +01:00
Esteban Küber
10fbdbf949 Update documentation comment 2019-01-12 19:36:28 -08:00
Esteban Küber
486ecc5e27 Don't add label to the match expr when the type is not fully realized 2019-01-12 19:36:28 -08:00
Esteban Küber
72d965f7b7 Reword label as per review comment 2019-01-12 19:36:28 -08:00
Esteban Küber
f9e10f1aee tidy fix 2019-01-12 19:36:28 -08:00
Esteban Küber
a873337f21 Point at the match discriminant when arm pattern has a type mismatch 2019-01-12 19:36:28 -08:00
Esteban Küber
28ea03e114 Suggest correct location for lifetime parameters in use 2019-01-12 19:25:03 -08:00
Mazdak Farrokhzad
2b234f61c6 const stabilize . 2019-01-13 04:00:03 +01:00
varkor
1e4a8a01c4 Update the const fn tracking issue to the new metabug 2019-01-13 01:55:44 +00:00
Esteban Küber
db740313e0 Remove unrelated errors from parse stderr tests 2019-01-12 17:12:41 -08:00
Eric Huss
0a3f178ab1 Update cargo 2019-01-12 15:26:02 -08:00
Vadim Petrochenkov
805099cf3e hygiene: Do not treat Self ctor as a local variable 2019-01-13 02:18:53 +03:00
Vadim Petrochenkov
6aa7856369 resolve: Mark extern crate items as used in more cases 2019-01-13 01:50:53 +03:00
Vadim Petrochenkov
f8028b0b6c privacy: Fix private-in-public check for existential types 2019-01-13 00:41:11 +03:00
Vadim Petrochenkov
ebdd072e3b resolve: Add a test for issue #57539 2019-01-13 00:15:23 +03:00
bors
75a369c5b1 Auto merge of #56759 - petrochenkov:prestabuni, r=nikomatsakis
Stabilize `uniform_paths`

Address all the things described in https://github.com/rust-lang/rust/issues/56417.

Assign visibilities to `macro_rules` items - `pub` to `macro_export`-ed macros and `pub(crate)` to non-exported macros, these visibilities determine how far these macros can be reexported with `use`.

Prohibit use of reexported inert attributes and "tool modules", after renaming (e.g. `use inline as imported_inline`) their respective tools and even compiler passes won't be able to recognize and properly check them.

Also turn use of uniform paths in 2015 macros into an error, I'd prefer to neither remove nor stabilize them right away because I still want to make some experiments in this area (uniform path fallback was added to 2015 macros used on 2018 edition in https://github.com/rust-lang/rust/pull/56053#issuecomment-441405140).

UPDATE: The last commit also stabilizes the feature `uniform_paths`.

Closes https://github.com/rust-lang/rust/issues/53130
Closes https://github.com/rust-lang/rust/issues/55618
Closes https://github.com/rust-lang/rust/issues/56326
Closes https://github.com/rust-lang/rust/issues/56398
Closes https://github.com/rust-lang/rust/issues/56417
Closes https://github.com/rust-lang/rust/issues/56821
Closes https://github.com/rust-lang/rust/issues/57252
Closes https://github.com/rust-lang/rust/issues/57422
2019-01-12 20:11:36 +00:00
Taiki Endo
6d442938e0 Add #[must_use] message to Iterator and Future 2019-01-13 02:57:27 +09:00
Corey Farwell
0394dce788
whitespace 2019-01-12 11:19:02 -05:00
Corey Farwell
1445a065de
bring back the example i removed, also add symmetry and simplify impl 2019-01-12 11:17:49 -05:00
Corey Farwell
423a5bb5c4
add comment explaining what the derive does 2019-01-12 11:00:14 -05:00
Igor Matuszewski
7948b18414 Use ptr::eq where applicable 2019-01-12 16:18:55 +01:00
Vadim Petrochenkov
250935d0c7 Fix a hole in generic parameter import future-proofing
Add some tests for buggy derive helpers
2019-01-12 16:18:55 +03:00
Vadim Petrochenkov
79134c0517 Stabilize uniform_paths 2019-01-12 16:18:55 +03:00
Vadim Petrochenkov
2f3db49c3d resolve: Prohibit use of imported tool modules 2019-01-12 16:18:20 +03:00
Vadim Petrochenkov
bf1e70cd1f resolve: Prohibit use of imported non-macro attributes 2019-01-12 16:18:20 +03:00
Vadim Petrochenkov
e1d1487fc4 resolve: Prohibit use of uniform paths in macros originating from 2015 edition
...while still keeping ambiguity errors future-proofing for uniform paths.
This corner case is not going to be stabilized for 1.32 and needs some more general experiments about retrofitting 2018 import rules to 2015 edition
2019-01-12 16:17:26 +03:00
Vadim Petrochenkov
099b3d86f9 resolve: Assign pub and pub(crate) visibilities to macro_rules items 2019-01-12 16:17:26 +03:00
bors
d6525ef539 Auto merge of #57542 - Centril:rollup, r=Centril
Rollup of 26 pull requests

Successful merges:

 - #56425 (Redo the docs for Vec::set_len)
 - #56906 (Issue #56905)
 - #57042 (Don't call `FieldPlacement::count` when count is too large)
 - #57175 (Stabilize `let` bindings and destructuring in constants and const fn)
 - #57192 (Change std::error::Error trait documentation to talk about `source` instead of `cause`)
 - #57296 (Fixed the link to the ? operator)
 - #57368 (Use CMAKE_{C,CXX}_COMPILER_LAUNCHER for ccache)
 - #57400 (Rustdoc: update Source Serif Pro and replace Heuristica italic)
 - #57417 (rustdoc: use text-based doctest parsing if a macro is wrapping main)
 - #57433 (Add link destination for `read-ownership`)
 - #57434 (Remove `CrateNum::Invalid`.)
 - #57441 (Supporting backtrace for x86_64-fortanix-unknown-sgx.)
 - #57450 (actually take a slice in this example)
 - #57459 (Reference tracking issue for inherent associated types in diagnostic)
 - #57463 (docs: Fix some 'second-edition' links)
 - #57466 (Remove outdated comment)
 - #57493 (use structured suggestion when casting a reference)
 - #57498 (make note of one more normalization that Paths do)
 - #57499 (note that FromStr does not work for borrowed types)
 - #57505 (Remove submodule step from README)
 - #57510 (Add a profiles section to the manifest)
 - #57511 (Fix undefined behavior)
 - #57519 (Correct RELEASES.md for 1.32.0)
 - #57522 (don't unwrap unexpected tokens in `format!`)
 - #57530 (Fixing a typographical error.)
 - #57535 (Stabilise irrefutable if-let and while-let patterns)

Failed merges:

r? @ghost
2019-01-12 11:22:20 +00:00
Shotaro Yamada
038d837224 Fix simple formatting optimization
name                        old2 ns/iter  new2 ns/iter  diff ns/iter   diff %  speedup
fmt::write_str_macro1       12,295        12,308                  13    0.11%   x 1.00
fmt::write_str_macro2       24,079        21,451              -2,628  -10.91%   x 1.12
fmt::write_str_macro_debug  238,363       230,807             -7,556   -3.17%   x 1.03
fmt::write_str_ref          6,203         6,064                 -139   -2.24%   x 1.02
fmt::write_str_value        6,225         6,075                 -150   -2.41%   x 1.02
fmt::write_vec_macro1       17,144        17,121                 -23   -0.13%   x 1.00
fmt::write_vec_macro2       29,845        26,703              -3,142  -10.53%   x 1.12
fmt::write_vec_macro_debug  248,840       242,117             -6,723   -2.70%   x 1.03
fmt::write_vec_ref          5,954         6,438                  484    8.13%   x 0.92
fmt::write_vec_value        5,959         6,439                  480    8.06%   x 0.93
2019-01-12 19:15:41 +09:00