Commit Graph

105324 Commits

Author SHA1 Message Date
Aaron Hill
5896998e76
Don't run const propagation on items with inconsistent bounds
Using `#![feature(trivial_bounds)]`, it's possible to write functions
with unsatisfiable 'where' clauses, making them uncallable. However, the
user can act as if these 'where' clauses are true inside the body of the
function, leading to code that would normally be impossible to write.

Since const propgation can run even without any user-written calls to a
function, we need to explcitly check for these uncallable functions.
2020-01-13 05:00:55 -05:00
bors
e82febc78e Auto merge of #67900 - nikic:prepare-llvm-10, r=nagisa
Prepare for LLVM 10 upgrade

Split off from #67759, this just adds the necessary compatibility bits and updates codegen tests, without performing the actual LLVM upgrade.

r? @alexcrichton
2020-01-13 04:01:00 +00:00
bors
3ebcfa1451 Auto merge of #67831 - mati865:ci-images-upgrade, r=pietroalbini
ci: bump ubuntu 19.04 images to 19.10

Ubuntu 19.04 goes EOL this month.
2020-01-12 14:52:48 +00:00
bors
59c1db0339 Auto merge of #67901 - matthewjasper:split-mir-build, r=nagisa
Split MIR building into its own crate

This moves `rustc_mir::{build, hair, lints}` to `rustc_mir_build`.
The new crate only has a `provide` function as it's public API.

Based on #67898

cc @Centril @rust-lang/compiler
r? @oli-obk
2020-01-12 09:44:55 +00:00
Matthew Jasper
b358929251 Split rustc_mir::{build, hair, lints} into their own crate 2020-01-12 09:39:26 +00:00
bors
0b6c116a84 Auto merge of #68142 - Centril:rollup-dl232e9, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #67494 (Constify more of alloc::Layout)
 - #67867 (Correctly check for opaque types in `assoc_ty_def`)
 - #67948 (Galloping search for binary_search_util)
 - #68045 (Move more of `rustc::lint` into `rustc_lint`)
 - #68089 (Unstabilize `Vec::remove_item`)
 - #68108 (Add suggestions when encountering chained comparisons)

Failed merges:

r? @ghost
2020-01-12 02:28:48 +00:00
Mazdak Farrokhzad
82c19b4388
Rollup merge of #68108 - varkor:chained-comparison-suggestions, r=Centril
Add suggestions when encountering chained comparisons

Ideally, we'd also prevent the type error, which is just extra noise, but that will require moving the error from the parser, and I think the suggestion makes things clear enough for now.

Fixes https://github.com/rust-lang/rust/issues/65659.
2020-01-12 03:28:02 +01:00
Mazdak Farrokhzad
bbd210e6c5
Rollup merge of #68089 - lzutao:revert-remote_item, r=sfackler
Unstabilize `Vec::remove_item`

As concerned by @kornelski, @LukasKalbertodt, and @gnzlbg in #40062.
Reverts #67727
2020-01-12 03:28:00 +01:00
Mazdak Farrokhzad
cc51d0350e
Rollup merge of #68045 - Centril:liberate-lints, r=Mark-Simulacrum
Move more of `rustc::lint` into `rustc_lint`

Based on https://github.com/rust-lang/rust/pull/67806.

Here we try to consolidate more of the linting infra into `rustc::lint`. Some high-level notes:

- We now store an `Lrc<dyn Any + Send + Sync>` as opposed to `Lrc<LintStore>` in the `GlobalCtxt`. This enables us to avoid referring to the type, breaking a cyclic dependency, and so we can move things from `rustc::lint` to `rustc_lint`.

- `in_derive_expansion` is, and needs to, be moved as a method on `Span`.

- We reduce the number of ways on `tcx` to emit a lint so that the developer UX is more streamlined.

- `LintLevelsBuilder` is moved to `rustc_lint::levels`, leaving behind `LintLevelMap/Set` in a purified form due to current constraints (hopefully fixable in the future after https://github.com/rust-lang/rust/pull/68133).

- `struct_lint_level` is moved to `rustc::lint` due to current dependency constraints.

- `rustc::lint::context` is moved to `rustc_lint::context`.

- The visitors in `rustc::lint` are moved to `rustc_lint::passes`.
2020-01-12 03:27:59 +01:00
Mazdak Farrokhzad
1b208b12f8
Rollup merge of #67948 - llogiq:gallop, r=Mark-Simulacrum
Galloping search for binary_search_util

This is unlikely to improve perf much unless for synthetic benchmarks, but I figure it likely won't hurt either.
2020-01-12 03:27:57 +01:00
Mazdak Farrokhzad
1d9c69fb89
Rollup merge of #67867 - matthewjasper:opaque-assoc-lookup, r=oli-obk
Correctly check for opaque types in `assoc_ty_def`

Closes #67856
2020-01-12 03:27:56 +01:00
Mazdak Farrokhzad
019790c72a
Rollup merge of #67494 - lukaslueg:const_alloc, r=oli-obk
Constify more of alloc::Layout

Making more methods of `alloc::Layout` const would allow us to compute alignment/size information for arbitrary (sized) types at compile-time, including placing the information in associated constants. While `mem::size_of` and `mem::align_of` are already const and `Layout` is solely based on those, there is no guarantee in the implementation that a const derived from these functions will be exactly the same as what `Layout` uses and is subsequently used in a call to `alloc::alloc`. Constifying `Layout` makes this possible.

First contribution to core, excuse my ignorance.
2020-01-12 03:27:54 +01:00
Andre Bogus
0e1cd59547 Galloping search for binary_search_util 2020-01-12 01:38:07 +01:00
bors
f363745872 Auto merge of #67458 - pnkfelix:fix-66530-by-propagating-fatal-error-from-worker, r=matthewjasper
When a codegen worker has a FatalError, propagate it instead of ICE'ing.

Fix #66530
2020-01-11 21:01:02 +00:00
Lukas Lueg
c5a9a14c9f Constify alloc::Layout
Tracking issue #67521, Layout::new in #66254
2020-01-11 16:59:15 +01:00
bors
1389494ac1 Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
Promote references to constants instead of statics

r? @oli-obk
2020-01-11 14:46:17 +00:00
Oliver Scherer
e51eccd2ef Make codegen tests wordsize independent 2020-01-11 14:40:07 +01:00
bors
bfd04876b9 Auto merge of #68126 - Centril:rollup-cz5u7xx, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #67756 (Collector tweaks)
 - #67889 (Compile some CGUs in parallel at the start of codegen)
 - #67930 (Rename Result::as_deref_ok to as_deref)
 - #68018 (feature_gate: Remove `GateStrength`)
 - #68070 (clean up E0185 explanation)
 - #68072 (Fix ICE #68058)
 - #68114 (Don't require `allow_internal_unstable` unless `staged_api` is enabled.)
 - #68120 (Ban `...X` pats, harden tests, and improve diagnostics)

Failed merges:

r? @ghost
2020-01-11 11:36:39 +00:00
Mazdak Farrokhzad
4eee796679
Rollup merge of #68120 - Centril:ban-range-to-dotdotdot, r=oli-obk
Ban `...X` pats, harden tests, and improve diagnostics

Follow up to https://github.com/rust-lang/rust/pull/67258#issuecomment-565656155 and https://github.com/rust-lang/rust/pull/67258#discussion_r357879932.

r? @cramertj @oli-obk
2020-01-11 12:36:15 +01:00
Mazdak Farrokhzad
50d76d6471
Rollup merge of #68114 - ecstatic-morse:fix-feature-gating, r=Centril
Don't require `allow_internal_unstable` unless `staged_api` is enabled.

#63770 changed `qualify_min_const_fn` to require `allow_internal_unstable` for *all* crates that used an unstable feature, regardless of whether `staged_api` was enabled or the `fn` that used that feature was stably const. In practice, this meant that every crate in the ecosystem that wanted to use nightly features added `#![feature(const_fn)]`, which skips `qualify_min_const_fn` entirely.

After this PR, crates that do not have `#![feature(staged_api)]` will only need to enable the feature they are interested in. For example, `#![feature(const_if_match)]` will be enough to enable `if` and `match` in constants. Crates with `staged_api` (e.g., `libstd`) require `#[allow_internal_unstable]` to be added to a function if it uses nightly features unless that function is also marked `#[rustc_const_unstable]`. This prevents proliferation of `#[allow_internal_unstable]` into functions that are not callable in a `const` context on stable.

r? @oli-obk (author of #63770)
cc @Centril
2020-01-11 12:36:14 +01:00
Mazdak Farrokhzad
f02f338ee0
Rollup merge of #68072 - JohnTitor:fix-macro-ice, r=petrochenkov
Fix ICE #68058

Fixes #68058

r? @petrochenkov
2020-01-11 12:36:12 +01:00
Mazdak Farrokhzad
34231d6c0b
Rollup merge of #68070 - GuillaumeGomez:clean-up-e0185, r=Dylan-DPC
clean up E0185 explanation

r? @Dylan-DPC
2020-01-11 12:36:10 +01:00
Mazdak Farrokhzad
31d7ffa1e0
Rollup merge of #68018 - petrochenkov:nosoft, r=Centril
feature_gate: Remove `GateStrength`

The "soft feature gating" from `feature_gate/check.rs` is unused, and even if it were used, hardcoded warning is not a good solution and [deny-by-default lint](https://github.com/rust-lang/rust/issues/64266) would be a better way to do this.

cc https://github.com/rust-lang/rust/pull/67806#discussion_r363091701
r? @Centril
2020-01-11 12:36:09 +01:00
Mazdak Farrokhzad
29a1cf2876
Rollup merge of #67930 - lzutao:result-as_deref, r=dtolnay
Rename Result::as_deref_ok to as_deref

Addresses https://github.com/rust-lang/rust/issues/50264#issuecomment-533952247
r? @dtolnay
2020-01-11 12:36:07 +01:00
Mazdak Farrokhzad
7b741fb68e
Rollup merge of #67889 - Zoxc:parallel-cgus, r=michaelwoerister
Compile some CGUs in parallel at the start of codegen

This brings the compilation time for `syntex_syntax` from 11.542s to 10.453s with 6 threads in non-incremental debug mode. Just compiling `n` CGUs in parallel at the beginning of codegen seems sufficient to get rid of the staircase effect, at least for `syntex_syntax`.

Based on https://github.com/rust-lang/rust/pull/67777.

r? @michaelwoerister
cc @alexcrichton @Mark-Simulacrum
2020-01-11 12:36:06 +01:00
Mazdak Farrokhzad
cd47af1881
Rollup merge of #67756 - Zoxc:collector-tweaks, r=Mark-Simulacrum
Collector tweaks

r? @Mark-Simulacrum
2020-01-11 12:36:04 +01:00
Vadim Petrochenkov
8e35c4f74c feature_gate: Remove GateStrength 2020-01-11 11:55:09 +03:00
Mazdak Farrokhzad
883932c6ba Ban ...X pats, harden tests, and improve diagnostics.
Also fix a bug with the span passed in `mk_range`.
2020-01-11 08:58:58 +01:00
Mazdak Farrokhzad
51078ceb44 fix ui-fulldeps & tests fallout 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
8be2a04c7e pacify the parallel compiler 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
b59235975e lints: move a comment 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
f58db20362 move rustc::lint::{context, passes} to rustc_lint.
Also do some cleanup of the interface.
2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
8c12c424e2 {rustc::lint -> rustc_lint}::internal 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
03dfa642d9 lints: promote levels.rs to lint.rs & extract passes.rs 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
16bf2783b5 inline maybe_lint_level_root 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
eee84fe396 move struct_lint_level to levels.rs 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
f577b44712 move LintSource to levels 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
03bdfe9db3 move logic to LintLevelsBuilder 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
6f1a79cabe GlobalCtxt: Erase LintStore type. 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
c151782d76 reduce diversity in linting methods 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
b93addba7a move in_derive_expansion as Span method 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
3a2af3242c canonicalize some lint imports 2020-01-11 07:42:15 +01:00
bors
543b7d97d0 Auto merge of #65912 - estebank:variants-orig, r=petrochenkov
Point at the span for the definition of crate foreign ADTs

Follow up to #65421. Partially addresses #65386. Blocked on #53081.
2020-01-11 06:15:59 +00:00
ecstatic-morse
fc30825c8b
Expand comment
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-01-10 19:29:16 -08:00
Lzu Tao
c2c2d3b32b Update test after renaming Result::as_deref 2020-01-11 03:26:09 +00:00
Lzu Tao
a5f42397be Rename Result::as_deref_ok to as_deref 2020-01-11 03:08:40 +00:00
Lzu Tao
7ba25acd7a Revert "Rollup merge of #67727 - Dylan-DPC:stabilise/remove_item, r=alexcrichton"
This reverts commit 4ed415b547, reversing
changes made to 3cce950743.
2020-01-11 03:04:39 +00:00
bors
88d1109600 Auto merge of #68115 - Centril:rollup-e2fszdv, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #67666 (make use of pointer::is_null)
 - #67806 (Extract `rustc_ast_passes`, move gating, & refactor linting)
 - #68043 (Add some missing timers)
 - #68074 (Add `llvm-skip-rebuild` flag to `x.py`)
 - #68079 (Clarify suggestion for E0013)
 - #68084 (Do not ICE on unicode next point)
 - #68102 (Inline some conversion methods around OsStr)
 - #68106 (Fix issue with using `self` module via indirection)

Failed merges:

r? @ghost
2020-01-11 03:03:42 +00:00
Mazdak Farrokhzad
04a340f61f
Rollup merge of #68106 - varkor:self_self_use, r=estebank
Fix issue with using `self` module via indirection

Fixes https://github.com/rust-lang/rust/issues/68103.
2020-01-11 04:02:31 +01:00
Mazdak Farrokhzad
c960c3e057
Rollup merge of #68102 - lzutao:inline, r=alexcrichton
Inline some conversion methods around OsStr

Diff on the assembly of this snippet before and after this PR: https://www.diffchecker.com/NeGMjaJ2
```rust
use std::env;
use std::io;
use std::path::{Path, PathBuf};

pub fn cargo_home_with_cwd(cwd: &Path) -> io::Result<PathBuf> {
    match env::var_os("CARGO_HOME").filter(|h| !h.is_empty()) {
        Some(home) => {
            let home = PathBuf::from(home);
            if home.is_absolute() {
                Ok(home)
            } else {
                Ok(cwd.join(&home))
            }
        }
        _ => env::home_dir()
            .map(|p| p.join(".cargo"))
            .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "could not find cargo home dir")),
    }
}
```
2020-01-11 04:02:30 +01:00