The lint was introduced in Dec 2016, then made deny-by-default in Jun 2017 when crater run found 0 regressions caused by it.
This lint requires some not entirely trivial amount of import resolution logic that (surprisingly or not) interacts with `feature(use_extern_macros)` (https://github.com/rust-lang/rust/issues/35896), so it would be desirable to remove it before stabilizing `use_extern_macros`.
In particular, this PR fixes the failing example in https://github.com/rust-lang/rust/issues/50725 (but not the whole issue, `use std::panic::{self}` still can cause other undesirable errors when `use_extern_macros` is enabled).
bors [Sat, 19 May 2018 07:42:03 +0000 (07:42 +0000)]
Auto merge of #50744 - nikic:mutable-noalias, r=alexcrichton
Emit noalias on &mut parameters by default
This used to be disabled due to LLVM bugs in the handling of
noalias information in conjunction with unwinding. However,
according to #31681 all known LLVM bugs have been fixed by
LLVM 6.0, so it's probably time to reenable this optimization.
-Z no-mutable-noalias is left as an escape-hatch to debug problems
suspected to stem from this change.
bors [Sat, 19 May 2018 03:10:53 +0000 (03:10 +0000)]
Auto merge of #50709 - alexcrichton:revert-musl, r=sfackler
Revert #50105 until regression is fixed
Discovered at https://github.com/rust-lang/rust/pull/50105#issuecomment-388630750 it looks like this caused a regression with i686 musl, so let's revert in the meantime while a fix is worked out
bors [Fri, 18 May 2018 21:49:38 +0000 (21:49 +0000)]
Auto merge of #50319 - nagisa:align_to, r=alexcrichton
Implement [T]::align_to
Note that this PR deviates from what is accepted by RFC slightly by making `align_offset` to return an offset in elements, rather than bytes. This is necessary to sanely support `[T]::align_to` and also simply makes more sense™. The caveat is that trying to align a pointer of ZST is now an equivalent to `is_aligned` check, rather than anything else (as no number of ZST elements will align a misaligned ZST pointer).
It also implements the `align_to` slightly differently than proposed in the RFC to properly handle cases where size of T and U aren’t co-prime.
Furthermore, a promise is made that the slice containing `U`s will be as large as possible (contrary to the RFC) – otherwise the function is quite useless.
The implementation uses quite a few underhanded tricks and takes advantage of the fact that alignment is a power-of-two quite heavily to optimise the machine code down to something that results in as few known-expensive instructions as possible. Currently calling `ptr.align_offset` with an unknown-at-compile-time `align` results in code that has just a single "expensive" modulo operation; the rest is "cheap" arithmetic and bitwise ops.
cc https://github.com/rust-lang/rust/issues/44488 @oli-obk
As mentioned in the commit message for align_offset, many thanks go to Chris McDonald.
bors [Fri, 18 May 2018 17:17:35 +0000 (17:17 +0000)]
Auto merge of #50653 - oli-obk:bad_const, r=cramertj
Make the `const_err` lint `deny`-by-default
At best these things are runtime panics (debug mode) or overflows (release mode). More likely they are public constants that are unused in the crate declaring them.
This is not a breaking change, as dependencies won't break and root crates can `#![warn(const_err)]`, though I don't know why anyone would do that.
bors [Thu, 17 May 2018 21:36:43 +0000 (21:36 +0000)]
Auto merge of #50593 - nikomatsakis:nll-no-location, r=nikomatsakis
stop considering location when computing outlives relationships
This doesn't (yet?) use SEME regions, but it does ignore the location for outlives constraints. This makes (I believe) NLL significantly faster -- but we should do some benchmarks. It regresses the "get-default" family of use cases for NLL, which is a shame, but keeps the other benefits, and thus represents a decent step forward.
iancormac84 [Tue, 8 May 2018 11:52:01 +0000 (07:52 -0400)]
Removed use of TypeIdHasher in debuginfo and replaced it with StableHasher. Also corrected erroneous mention of TypeIdHasher in implementation of HashStable trait.
Nikita Popov [Mon, 14 May 2018 13:20:51 +0000 (15:20 +0200)]
Emit noalias on &mut parameters by default
This used to be disabled due to LLVM bugs in the handling of
noalias information in conjunction with unwinding. However,
according to #31681 all known LLVM bugs have been fixed by
LLVM 6.0, so it's probably time to reenable this optimization.
Noalias annotations will not be emitted by default if either
-C panic=abort (as previously) or LLVM >= 6.0 (new).
-Z mutable-noalias=no is left as an escape-hatch to allow
debugging problems suspected to stem from this change.
Keep only the language item. This removes some indirection and makes
codegen worse for debug builds, but simplifies code significantly, which
is a good tradeoff to make, in my opinion.
Besides, the codegen can be improved even further with some constant
evaluation improvements that we expect to happen in the future.
Mark Simulacrum [Thu, 17 May 2018 19:51:27 +0000 (13:51 -0600)]
Rollup merge of #50818 - nnethercote:faster-normalize, r=nikomatsakis
Speed up `opt_normalize_projection_type`
`opt_normalize_projection_type` is hot in the serde and futures benchmarks in rustc-perf. These two patches speed up the execution of most runs for them by 2--4%.
Mark Simulacrum [Thu, 17 May 2018 19:51:24 +0000 (13:51 -0600)]
Rollup merge of #50790 - bstrie:grammar, r=steveklabnik
Fix grammar documentation wrt Unicode identifiers
The grammar defines identifiers in terms of XID_start and XID_continue,
but this is referring to the unstable non_ascii_idents feature.
The documentation implies that non_ascii_idents is forthcoming, but this
is left over from pre-1.0 documentation; in reality, non_ascii_idents
has been without even an RFC for several years now, and will not be
stabilized anytime soon. Furthermore, according to the tracking issue at
https://github.com/rust-lang/rust/issues/28979 , it's highly
questionable whether or not this feature will use XID_start or
XID_continue even when or if non_ascii_idents is stabilized.
This commit fixes this by respecifying identifiers as the usual
[a-zA-Z_][a-zA-Z0-9_]*
Mark Simulacrum [Thu, 17 May 2018 19:51:21 +0000 (13:51 -0600)]
Rollup merge of #50610 - estebank:fmt-str, r=Kimundi
Improve format string errors
Point at format string position inside the formatting string:
```
error: invalid format string: unmatched `}` found
--> $DIR/format-string-error.rs:21:22
|
LL | let _ = format!("}");
| ^ unmatched `}` in format string
```
Explain that argument names can't start with an underscore:
```
error: invalid format string: invalid argument name `_foo`
--> $DIR/format-string-error.rs:15:23
|
LL | let _ = format!("{_foo}", _foo = 6usize);
| ^^^^ invalid argument name in format string
|
= note: argument names cannot start with an underscore
```
Fix #23476.
The more accurate spans will only be seen when using `format!` directly, when using `println!` the diagnostics machinery makes the span be the entire statement.
This is necessary if we want to implement `[T]::align_to` and is more
useful in general.
This implementation effort has begun during the All Hands and represents
a month of my futile efforts to do any sort of maths. Luckily, I
found the very very nice Chris McDonald (cjm) on IRC who figured out the
core formulas for me! All the thanks for existence of this PR go to
them!
Anyway… Those formulas were mangled by yours truly into the arcane forms
you see here to squeeze out the best assembly possible on most of the
modern architectures (x86 and ARM were evaluated in practice). I mean,
just look at it: *one actual* modulo operation and everything else is
just the cheap single cycle ops! Admitedly, the naive solution might be
faster in some common scenarios, but this code absolutely butchers the
naive solution on the worst case scenario.
Alas, the result of this arcane magic also means that the code pretty
heavily relies on the preconditions holding true and breaking those
preconditions will unleash the UB-est of all UBs! So don’t.
bors [Thu, 17 May 2018 16:44:38 +0000 (16:44 +0000)]
Auto merge of #50629 - Mark-Simulacrum:stage-step, r=alexcrichton
Switch to bootstrapping from 1.27
It's possible the Float trait could be removed from core, but I couldn't tell whether it was intended to be removed or not. @SimonSapin may be able to comment more here; we can presumably also do that in a follow up PR as this one is already quite large.
In #49289, rustc was changed to emit metadata for binaries, which made
it so that the librustc.rmeta file created when compiling librustc was
overwritten by the rustc-main compilation. This commit renames the
rustc-main binary to avoid this problem.
https://github.com/rust-lang/cargo/issues/5524 has also been filed to
see if Cargo can learn to warn on this situation instead of leaving it
for the user to debug.
bors [Thu, 17 May 2018 08:29:11 +0000 (08:29 +0000)]
Auto merge of #50400 - ehuss:compiletest-revisions, r=alexcrichton
compiletest: Run revisions as independent tests.
Fixes #47604.
- The output of each test is now in its own directory.
- "auxiliary" output is now under the respective test directory.
- `stage_id` removed from filenames, and instead placed in the stamp file as a hash. This helps keep path lengths down for Windows.
In brief, the new layout looks like this:
```
<build_base>/<relative_dir>/<testname>.<revision>.<mode>/
stamp
<testname>.err
<testname>.out
a (binary)
auxiliary/lib<auxname>.dylib
auxiliary/<auxname>/<auxname>.err
auxiliary/<auxname>/<auxname>.out
```
(revision and mode are optional)
Eric Huss [Thu, 26 Apr 2018 22:27:31 +0000 (15:27 -0700)]
compiletest: Run revisions as independent tests.
- The output of each test is now in its own directory.
- "auxiliary" output is now under the respective test directory.
- `stage_id` removed from filenames, and instead placed in the stamp file as a hash. This helps keep path lengths down for Windows.
In brief, the new layout looks like this:
```
<build_base>/<relative_dir>/<testname>.<revision>.<mode>/
stamp
<testname>.err
<testname>.out
a (binary)
auxiliary/lib<auxname>.dylib
auxiliary/<auxname>/<auxname>.err
auxiliary/<auxname>/<auxname>.out
```
(revision and mode are optional)
bors [Thu, 17 May 2018 02:05:39 +0000 (02:05 +0000)]
Auto merge of #50807 - kennytm:rollup, r=kennytm
Rollup of 17 pull requests
Successful merges:
- #50170 (Implement From for more types on Cow)
- #50638 (Don't unconditionally set CLOEXEC twice on every fd we open on Linux)
- #50656 (Fix `fn main() -> impl Trait` for non-`Termination` trait)
- #50669 (rustdoc: deprecate `#![doc(passes, plugins, no_default_passes)]`)
- #50726 (read2: Use inner function instead of closure)
- #50728 (Fix rustdoc panic with `impl Trait` in type parameters)
- #50736 (env: remove unwrap in examples in favor of try op)
- #50740 (Remove LazyBTreeMap.)
- #50752 (Add missing error codes in libsyntax-ext asm)
- #50779 (Make mutable_noalias and arg_align_attributes be tracked)
- #50787 (Fix run-make wasm tests)
- #50788 (Fix an ICE when casting a nonexistent const)
- #50789 (Ensure libraries built in stage0 have unique metadata)
- #50793 (tidy: Add a check for empty UI test files)
- #50797 (fix a typo in signed-integer::from_str_radix())
- #50808 (Stabilize num::NonZeroU*)
- #50809 (GitHub: Stop treating Cargo.lock as a generated file.)
Avoid allocations in `opt_normalize_projection_type`.
This patch changes `opt_normalize_project_type` so it appends
obligations to a given obligations vector, instead of returning a new
obligations vector.
This change avoids lots of allocations. In the most extreme case, for a
clean "Check" build of serde it reduces the total number of allocations
by 20%.
Regression fixes:
- rust-lang/cargo#5503 - cargo rustc broken for tests in project with bins
- rust-lang/cargo#5520 - shared proc-macro dependency built incorrectly
Changes:
- rust-lang/cargo#5527 - Point Source Replacement to the Overriding Dependencies section
- rust-lang/cargo#5533 - Detail how to run locally-built nightly cargo
- rust-lang/cargo#5522 - Add option to set user-agent
- rust-lang/cargo#5519 - NFC: fix a couple of typos, found by codespell.
- rust-lang/cargo#5513 - Fix `panic` for binaries built during tests.
- rust-lang/cargo#5512 - simplify build_requirements
- rust-lang/cargo#5301 - Add --build-plan for 'cargo build'
- rust-lang/cargo#5460 - Be more conservative about which files are linked to the output dir.
- rust-lang/cargo#5509 - Use the new stable
- rust-lang/cargo#5507 - Does not print seconds fraction with minutes
- rust-lang/cargo#5498 - Bump to 0.29.0
- rust-lang/cargo#5497 - Mention +nightly in ARCHITECTURE.md
Avoid repeated HashMap lookups in `opt_normalize_projection_type`.
There is a hot path through `opt_normalize_projection_type`:
- `try_start` does a cache lookup (#1).
- The result is a `NormalizedTy`.
- There are no unresolved type vars, so we call `complete`.
- `complete` does *another* cache lookup (#2), then calls
`SnapshotMap::insert`.
- `insert` does *another* cache lookup (#3), inserting the same value
that's already in the cache.
This patch optimizes this hot path by introducing `complete_normalized`,
for use when the value is known in advance to be a `NormalizedTy`. It
always avoids lookup #2. Furthermore, if the `NormalizedTy`'s
obligations are empty (the common case), we know that lookup #3 would be
a no-op, so we avoid it, while inserting a Noop into the `SnapshotMap`'s
undo log.
kennytm [Wed, 16 May 2018 21:24:42 +0000 (05:24 +0800)]
Rollup merge of #50809 - kennytm:show-cargo-lock-diff, r=alexcrichton
GitHub: Stop treating Cargo.lock as a generated file.
We do want to inspect the changes to Cargo.lock, hiding the diff by default would make it easier to miss important details like https://github.com/rust-lang/rust/pull/50629#discussion_r187556602 and https://github.com/rust-lang/rust/pull/50696#pullrequestreview-119648156
kennytm [Wed, 16 May 2018 19:07:35 +0000 (03:07 +0800)]
Rollup merge of #50793 - jrlusby:master, r=petrochenkov
tidy: Add a check for empty UI test files
Check for empty `.stderr` and `.stdout` files in UI test directories.
Empty files could still pass testing for `compile-pass` tests with no output
so they can get into the repo accidentally, but they are not necessary and can
be removed.
This is very much an in progress pull request. I'm having an issue with rustfmt. It wanted to reformat the entire file for almost every file by default. And when I run tidy it just errors out because it catches the empty files that are already in the repo.
My next step is goin got be to remove those empty file and see if running tidy again will actually reformat things outside of the context of `cargo fmt`
kennytm [Wed, 16 May 2018 15:23:02 +0000 (23:23 +0800)]
Rollup merge of #50789 - cuviper:bootstrap-metadata, r=alexcrichton
Ensure libraries built in stage0 have unique metadata
Issue #50786 shows a case with local rebuild where the libraries built
by stage0 had the same suffix as stage0's own, and were accidentally
loaded by that stage0 rustc when compiling `librustc_trans`.
Now we set `__CARGO_DEFAULT_LIB_METADATA` to "bootstrap" during stage0,
rather than the release channel like usual, so the library suffix will
always be completely distinct from the stage0 compiler.