Commit Graph

9421 Commits

Author SHA1 Message Date
Yuki Okushi
27a810c719 Add test for issue-66473 2020-01-15 23:41:37 +09:00
Yuki Okushi
ce8fed65f5 Add test for issue-65918 2020-01-15 23:41:37 +09:00
Yuki Okushi
406049df49 Add test for issue-64848 2020-01-15 23:41:37 +09:00
Yuki Okushi
610ea80710 Rollup merge of #68219 - oli-obk:fix_miri, r=RalfJung,wesleywiser
Untangle ZST validation from integer validation and generalize it to all zsts

cc @RalfJung

r? @wesleywiser
2020-01-15 21:51:50 +09:00
Yuki Okushi
89b065dbd2 Rollup merge of #67914 - Aaron1011:fix/const-prop-impossible, r=matthewjasper,oli-obk
Don't run const propagation on items with inconsistent bounds

Fixes #67696

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-15 21:51:43 +09:00
Oliver Scherer
10f439a011 Promoteds can contain raw pointers, but these must still only point to immutable allocations 2020-01-15 10:48:22 +01:00
Oliver Scherer
0e14b9ff26 Add tests 2020-01-15 10:30:26 +01:00
csmoe
4eb47ded54 wrap expr id into GeneratorInteriorTypeCause 2020-01-15 15:13:51 +08:00
bors
4b172cc73f Auto merge of #68118 - skinny121:eager_lit_eval, r=varkor
perf: Eagerly convert literals to consts

Previousely even literal constants were being converted to an `Unevaluted` constant for evaluation later. This seems unecessary as no more information is needed to be able to convert the literal to a mir constant.

Hopefully this will also minimise the performance impact of #67717, as far less constant evaluations are needed.
2020-01-15 00:56:53 +00:00
Esteban Küber
268a1ff3fb Account for Paths on is_suggestable_infer_ty
Fix #68162.
2020-01-14 16:18:21 -08:00
Ben Lewis
583a4fc827 Fix normalizing 32bit symbol hash. 2020-01-15 06:59:26 +13:00
csmoe
5ad8b9e394 update async-await send/sync test 2020-01-15 00:45:08 +08:00
Ben Lewis
30dba97540 Normalize symbol hash in ui test for legacy symbol mangling, as it's dependent on the
number of bits within consts.
2020-01-14 20:41:14 +13:00
Yuki Okushi
d7e599203c Rollup merge of #68143 - skinny121:const-param-type-elided-lifetime, r=petrochenkov
Forbid elided lifetimes within const generic parameter types

Disallows `fn foo<const T: &u32>()`, the lifetime must be explicitly given, i.e. `fn foo<const T: &'static u32>()`.

Fixes #67883
2020-01-14 14:02:23 +09:00
Ben Lewis
a6c4025fac perf: eagerly convert literals to consts, this avoids creating loads on unevaluated consts
which requires a lot of unnecessary work to evaluate them further down the line.
2020-01-14 07:47:45 +13:00
Aaron Hill
6a0bb1867b Add "--emit=link"
This avoids a strange linker error that we get with only "--emit=mir"
and "check-pass"
2020-01-13 05:00:56 -05:00
Aaron Hill
7df8ca2954 Convert test to check-pass 2020-01-13 05:00:56 -05:00
Aaron Hill
e1fc22c4eb Add additional regression test 2020-01-13 05:00:55 -05:00
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
Wesley Wiser
7f65475d00 Turn off const propagation of ref taking
Fixes #67529
Fixes #67640
Fixes #67641
Fixes #67862
2020-01-12 22:27:39 -05:00
Mark Mansi
a804868bbf Get rid of RegionErrorNamingContext 2020-01-12 19:43:00 -06:00
Yuki Okushi
27b99d4050 Fix crate paths in comments 2020-01-13 01:07:43 +09:00
varkor
1faa05daac Update output-default.json and rustdoc test 2020-01-12 15:37:50 +00:00
varkor
117443ec0a Appease tidy 2020-01-12 15:37:50 +00:00
varkor
3de9b8a3b7 Fix formatting ellipses at the end of some diagnostics 2020-01-12 15:37:50 +00:00
varkor
e84248921b Add backticks in appropriate places 2020-01-12 15:37:50 +00:00
varkor
8461fa5119 Diagnostics should not end with a full stop 2020-01-12 15:37:50 +00:00
varkor
0810210bcb Diagnostics should start lowercase 2020-01-12 15:36:40 +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
Ben Lewis
82b90bd993 Update test benchmark file 2020-01-12 20:41:03 +13:00
Ben Lewis
9e46ddc7a2 Added comment about behaviour. 2020-01-12 17:32:50 +13:00
Ben Lewis
b4fddf0f08 Forbid elided lifetimes within const generic parameter types. 2020-01-12 15:59:18 +13: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
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
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
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
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
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
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
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
Lzu Tao
c2c2d3b32b Update test after renaming Result::as_deref 2020-01-11 03:26:09 +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
cacda2d7a0 Rollup merge of #68084 - estebank:ice-68000, r=varkor
Do not ICE on unicode next point

Use `shrink_to_hi` instead of `next_point` and fix `next_point`.

Fix #68000, fix #68091, fix #68092.
2020-01-11 04:02:28 +01:00
Mazdak Farrokhzad
ba14f9429a Rollup merge of #68079 - varkor:E0013-clarify, r=Centril
Clarify suggestion for E0013

Fixes https://github.com/rust-lang/rust/issues/68038.
2020-01-11 04:02:27 +01:00
Dylan MacKenzie
1d418a1191 Test that stable const fn requires allow_internal_unstable 2020-01-10 18:51:42 -08:00
Dylan MacKenzie
09b5c854de Remove unnecessary const_fn feature gates
This flag opts out of the min-const-fn checks entirely, which is usually
not what we want. The few cases where the flag is still necessary have
been annotated.
2020-01-10 18:51:12 -08:00
varkor
088a1808d2 Add suggestions when encountering chained comparisons 2020-01-11 01:56:25 +00:00