Commit Graph

172 Commits

Author SHA1 Message Date
Markus Westerlind b61a28b2a1 Rebase and use ena 0.14 2020-05-05 11:25:12 +02:00
Markus Westerlind f45d852dcc perf: Merge region_obligations snapshotting into the undo log 2020-05-05 11:24:36 +02:00
Markus Westerlind 0c5d833812 Move projection_cache into the combined undo log 2020-05-05 11:24:23 +02:00
Dylan DPC 679431f741 Rollup merge of #71038 - lcnr:dyn_trait_structural_match, r=pnkfelix
forbid `dyn Trait` in patterns

Do not allow `&dyn Trait` as a generic const parameters.
This also changes dyn trait in pattern from ICE to error.

closes #63322
closes #70972

r? @eddyb
2020-05-04 16:15:24 +02:00
bors d6823ba166 Auto merge of #71108 - estebank:suggest-proj-type-mismatch-constraint, r=oli-obk
On type mismatch involving associated type, suggest constraint

When an associated type is found when a specific type was expected, if
possible provide a structured suggestion constraining the associated
type in a bound.

```
error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
  --> $DIR/associated-types-multiple-types-one-trait.rs:13:5
   |
LL |     want_y(t);
   |     ^^^^^^ expected `i32`, found associated type
...
LL | fn want_y<T:Foo<Y=i32>>(t: &T) { }
   |                 ----- required by this bound in `want_y`
   |
   = note:         expected type `i32`
           found associated type `<T as Foo>::Y`
help: consider constraining the associated type `<T as Foo>::Y` to `i32`
   |
LL | fn have_x_want_y<T:Foo<X=u32, Y = i32>>(t: &T)
   |                             ^^^^^^^^^
```

```
error[E0308]: mismatched types
  --> $DIR/trait-with-missing-associated-type-restriction.rs:12:9
   |
LL |     qux(x.func())
   |         ^^^^^^^^ expected `usize`, found associated type
   |
   = note:         expected type `usize`
           found associated type `<impl Trait as Trait>::A`
help: consider constraining the associated type `<impl Trait as Trait>::A` to `usize`
   |
LL | fn foo(x: impl Trait<A = usize>) {
   |                     ^^^^^^^^^^
```

Fix #71035. Related to #70908.
2020-05-04 06:32:49 +00:00
Dylan DPC ffe0a1c9fd Rollup merge of #71314 - mibac138:cfg-version, r=petrochenkov
Implement RFC 2523, `#[cfg(version(..))]`

Hi! This is my first contribution to rust, I hope I didn't miss anything. I tried to implement this feature so that `#[cfg(version(1.44.0))]` works but the parser was printing an error that I wasn't sure how to fix so I just opted for implementing `#[cfg(version("1.44.0"))]` (note the quotes).

Tracking issue: #64796
2020-05-03 14:18:00 +05:30
Esteban Küber 299bd12fe5 Point at associated types when they have a default type
Associated types with a default type in a trait can't be relied upon to
remain of that default type when in use, so literals of that type can't
be used in the trait's items. Point at the associated type and state
that information.

Reduce verbosity for associated consts of the wrong type.
2020-05-02 18:24:07 -07:00
mibac138 90aa62a1bf Implement RFC 2523, #[cfg(version(..))] 2020-05-03 02:42:07 +02:00
Dylan DPC 97cf378f54 Rollup merge of #71787 - tshepang:rustdoc-warnings, r=varkor
fix rustdoc warnings
2020-05-02 18:27:52 +02:00
bors 7184d137f6 Auto merge of #71795 - RalfJung:rollup-yqxfi5a, r=RalfJung
Rollup of 6 pull requests

Successful merges:

 - #71712 (Miri: port error backtraces to std::backtrace)
 - #71736 (bootstrap: also apply unused-attributes hack without deny_warnings)
 - #71738 (remove AllocId generalization of Pointer)
 - #71739 (remove obsolete comment)
 - #71781 (Uncomment test code for failure to use `Box::pin`)
 - #71782 (Use a non-existent test path instead of clobbering /dev/null)

Failed merges:

r? @ghost
2020-05-02 10:13:57 +00:00
Tshepang Lekhonkhobe 3be52b5941 fix rustdoc warnings 2020-05-02 10:41:04 +02:00
bors 08dfbfb618 Auto merge of #70170 - eddyb:wf-early-exit, r=nikomatsakis
wf: handle "livelock" checking before reaching `WfPredicates::compute`.

For `wf::obligations`'s "livelock" handling, this PR shouldn't cause any behavioral changes, as the check moved to it should be equivalent to the old one in `WfPredicates::compute`.

However, it fixes #70168 by making *other* users of `WfPredicates::compute` (that is, `wf::predicate_obligations` and `compute`'s own upvar handling) correct for `ty::Infer`, in that they now get a `WellFormed(ty::Infer(_))` obligation instead of silently ignoring the type.

r? @nikomatsakis
2020-05-02 06:51:08 +00:00
Tshepang Lekhonkhobe 8abfb685b3 remove obsolete comment
Referenced was removed in 9f492fefef
2020-05-01 11:45:05 +02:00
bors e94eaa6dce Auto merge of #70674 - cjgillot:query-arena-all, r=matthewjasper
Have the per-query caches store the results on arenas

This PR leverages the cache for each query to serve as storage area for the query results.

It introduces a new cache `ArenaCache`, which moves the result to an arena,
and only stores the reference in the hash map.
This allows to remove a sizeable part of the usage of the global `TyCtxt` arena.

I only migrated queries that already used arenas before.
2020-05-01 01:38:05 +00:00
Eduard-Mihai Burtescu 05a872df2b wf: {Int,Float}Var can only infer to always-WF ints/floats. 2020-04-30 23:01:26 +03:00
Eduard-Mihai Burtescu d1dc2afd05 wf: handle "livelock" checking before reaching WfPredicates::compute. 2020-04-30 23:01:22 +03:00
Dylan DPC 5e53f80d6e Rollup merge of #71449 - ecstatic-morse:free-region-cleanup, r=Mark-Simulacrum
Move `{Free,}RegionRelations` and `FreeRegionMap` to `rustc_infer`

...and out of `rustc_middle`. This is to further #65031, albeit in a very minor way

r? @Mark-Simulacrum
2020-04-30 20:15:24 +02:00
Bastian Kauschke 9f34b82de2 forbid dyn Trait in const generics 2020-04-29 19:29:10 +02:00
Camille GILLOT e56c400432 Use the query system to allocate. 2020-04-28 11:34:17 +02:00
marmeladema de7c9e753d Use LocalDefId in typeck_tables_of and used_trait_imports queries 2020-04-27 21:50:17 +01:00
bors 46ec74e60f Auto merge of #71268 - estebank:devectorize, r=eddyb
Remove some `Vec` allocations to improve performance

This claws back most of the performance lost in https://github.com/rust-lang/rust/pull/69745.
r? @eddyb
2020-04-27 10:00:05 +00:00
Dylan DPC c95bcbc9d5 Rollup merge of #71409 - estebank:point-at-ret-question-mark-op, r=petrochenkov
Point at the return type on `.into()` failure caused by `?`

Fix #35946.
2020-04-27 03:26:13 +02:00
Esteban Küber be90f90810 Point at the return type on .into() failure caused by ?
Fix #35946.
2020-04-26 11:50:58 -07:00
Eduard-Mihai Burtescu 95b3c427d4 Remove Option from the return type of def_kind. 2020-04-24 13:44:07 -05:00
bors 5a59527516 Auto merge of #71215 - marmeladema:issue70853/librustc_middle-local-def-id-2, r=eddyb
Simplify `local_def_id` and `as_local_hir_id`

See #70853
2020-04-24 04:14:20 +00:00
Dylan DPC fa7fb932cc Rollup merge of #71426 - contrun:fix-e0751-explanation, r=estebank
fix error code in E0751.md

reference: https://github.com/rust-lang/rust/issues/71304
2020-04-24 02:47:35 +02:00
marmeladema fe7531579d Address comments from review 2020-04-23 23:14:07 +01:00
marmeladema bfce24aa67 Modify as_local_hir_id to return a bare HirId 2020-04-23 23:14:07 +01:00
marmeladema 6148db719f Modify as_local_hir_id to accept a LocalDefId instead of a DefId 2020-04-23 23:14:07 +01:00
marmeladema 92fb59d7f3 librustc_middle: return LocalDefId instead of DefId in local_def_id 2020-04-23 23:14:07 +01:00
YI baac961fb5 fix error code for E0751 2020-04-23 15:46:05 +08:00
Dylan MacKenzie 46154f28bd Move {Free,}RegionRelations and FreeRegionMap out of rustc_middle 2020-04-22 15:54:10 -07:00
Dylan DPC 7b1ce6e98d Rollup merge of #71203 - csmoe:issue-71137, r=csmoe
Correct await span for async-await error reporting

Closes #71137
r? @tmandry
2020-04-22 12:18:33 +02:00
Dylan DPC 707004c552 Rollup merge of #70970 - eddyb:trait-vs-impl-mismatch, r=oli-obk
Detect mistyped associated consts in `Instance::resolve`.

*Based on #71049 to prevent redundant/misleading downstream errors.*

Fixes #70942 by refusing to resolve an associated `const` if it doesn't have the same type in the `impl` that it does in the `trait` (which we assume had errored, and `delay_span_bug` guards against bugs).
2020-04-22 12:18:31 +02:00
csmoe 00d12ef901 add test for correct await span 2020-04-22 09:51:56 +08:00
Yuki Okushi 24fb393207 Rollup merge of #70998 - estebank:suggest-impl-trait-empty-fn, r=varkor
Suggest `-> impl Trait` and `-> Box<dyn Trait>` on fn that doesn't return

During development, a function could have a return type set that is a
bare trait object by accident. We already suggest using either a boxed
trait object or `impl Trait` if the return paths will allow it. We now
do so too when there are *no* return paths or they all resolve to `!`.
We still don't handle cases where the trait object is *not* the entirety
of the return type gracefully.

Closes #38376.
2020-04-22 10:34:03 +09:00
Dylan DPC e3a514c44a Rollup merge of #71174 - Nokel81:fix-async-main-error, r=petrochenkov
Check that main/start is not async

* Add new error code E0752
* Add span to hir::IsAsync::Yes
* Emit an error if main or the start function is marked as async
* Add two regression tests

This PR fixes #68523.
2020-04-21 00:30:55 +02:00
Esteban Küber e536257061 Ensure tail expression will have a Ty for E0746
When the return type is `!Sized` we look for all the returned
expressions in the body to fetch their types and provide a reasonable
suggestion. The tail expression of the body is normally evaluated after
checking whether the return type is `Sized`. Changing the order of the
evaluation produces undesirable knock down effects, so we detect the
specific case that newcomers are likely to encounter ,returning a single
bare trait object, and only in that case we evaluate the tail
expression's type so that the suggestion will be accurate.
2020-04-20 11:17:03 -07:00
Esteban Küber e7e3001557 Remove some allocations in predicate evaluation 2020-04-20 10:42:25 -07:00
Esteban Küber 6c921c2c5f Use more Iterators instead of Vecs 2020-04-20 10:42:25 -07:00
Esteban Küber faeb0404a5 Remove unnecessary allocation 2020-04-20 10:42:25 -07:00
Esteban Küber 2000f91f68 Remove some Vec allocations in an effort to improve perf 2020-04-20 10:42:25 -07:00
Esteban Küber d3c96f03b5 Suggest -> impl Trait and -> Box<dyn Trait> on fn that doesn't return
During development, a function could have a return type set that is a
bare trait object by accident. We already suggest using either a boxed
trait object or `impl Trait` if the return paths will allow it. We now
do so too when there are *no* return paths or they all resolve to `!`.
We still don't handle cases where the trait object is *not* the entirety
of the return type gracefully.
2020-04-20 09:24:41 -07:00
Sebastian Malton 6120acec87 Check that main/start is not async
* Add new error code E0752
* Add span to hir::IsAsync::Yes
* Emit an error if main or the start function is marked as async
* Add two regression tests

Fix formatting errors and bless test outputs
* move tests to ui/async-await

fix test error text

remove span from IsAsync
2020-04-20 09:37:11 -04:00
Josh Stone 7b005c5fcb Dogfood more or_patterns in the compiler 2020-04-19 07:33:58 -07:00
bors e7497a8ccb Auto merge of #69793 - estebank:predicate-obligations-4, r=nikomatsakis
Maintain chain of derived obligations

When evaluating the derived obligations from super traits, maintain a
reference to the original obligation in order to give more actionable
context in the output.

Continuation (and built on) #69745, subset of #69709.

r? @eddyb
2020-04-19 06:42:51 +00:00
Esteban Küber d9a5419ef4 Add label to item source of bound obligation 2020-04-18 17:19:53 -07:00
Esteban Küber ce936e9336 Do not emit note for projected derived obligations 2020-04-18 16:37:08 -07:00
Esteban Küber 6bc55c701f Remove AssocTypeBound and propagate bound Spans 2020-04-18 16:37:08 -07:00
Esteban Küber ad1c23c993 Maintain chain of derived obligations
When evaluating the derived obligations from super traits, maintain a
reference to the original obligation in order to give more actionable
context in the output.
2020-04-18 16:37:08 -07:00