Skip to content

Improve errors after re rebalance coherence - #66253

Merged
bors merged 2 commits into
rust-lang:masterfrom
ohadravid:improve-errors-after-re-rebalance-coherence
Nov 14, 2019
Merged

Improve errors after re rebalance coherence#66253
bors merged 2 commits into
rust-lang:masterfrom
ohadravid:improve-errors-after-re-rebalance-coherence

Conversation

@ohadravid

Copy link
Copy Markdown
Contributor

Following #65247, I noticed that some error messages should be updated to reflect the changes of re_rebalance_coherence (also there was a note in the RFC about it).

First, error message E0210 was updated to match the RFC, and I also tried to improve a little the error when the "order" of types is problematic.

For code like this:

#![feature(re_rebalance_coherence)] // Now stable
struct Wrap<T>(T);
impl<T> From<Wrap<T>> for T {
fn from(x: Wrap<T>) -> T {
x.0
}
}

The old error was:

error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> src/lib.rs:5:6
|
5 | impl<T> From<Wrap<T>> for T {
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

and the new error is:

error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
--> main.rs:66:6
|
66 | impl<T> From<Wrap<T>> for T {
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
|
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last

I tried to point at the uncovered T, but couldn't get something which was reliable (but I'll be happy to try if someone points me in the right direction).

r? @estebank
cc @nikomatsakis

Fixes#65247

@rust-highfive

Copy link
Copy Markdown
Contributor

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 9, 2019
Comment threadsrc/librustc_typeck/coherence/orphan.rs Outdated
Comment threadsrc/librustc_typeck/coherence/orphan.rs Outdated
@CentrilCentril added the F-re_rebalance_coherence `#![feature(re_rebalance_coherence)]` label Nov 10, 2019
@ohadravid
ohadravidforce-pushed the improve-errors-after-re-rebalance-coherence branch 3 times, most recently from 6cea880 to a5a8410CompareNovember 10, 2019 10:02
Comment threadsrc/librustc_typeck/error_codes.rs Outdated
Comment threadsrc/librustc_typeck/error_codes.rs Outdated
Comment threadsrc/librustc_typeck/error_codes.rs Outdated
Comment threadsrc/librustc_typeck/error_codes.rs Outdated
@ohadravid
ohadravidforce-pushed the improve-errors-after-re-rebalance-coherence branch from a5a8410 to 64cf59dCompareNovember 10, 2019 13:59
@rust-highfive

This comment has been minimized.

@ohadravid
ohadravidforce-pushed the improve-errors-after-re-rebalance-coherence branch from 64cf59d to 2db744cCompareNovember 10, 2019 15:26
@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 2db744c has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 14, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 14, 2019
…ebalance-coherence, r=estebank
Improve errors after re rebalance coherence
Following rust-lang#65247, I noticed that some error messages should be updated to reflect the changes of `re_rebalance_coherence` (also there was a [note](https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html#teaching-users) in the RFC about it).
First, error message `E0210` was updated to match the RFC, and I also tried to improve a little the error when the "order" of types is problematic.
For code like this:
```
#![feature(re_rebalance_coherence)] // Now stable
struct Wrap<T>(T);
impl<T> From<Wrap<T>> for T {
fn from(x: Wrap<T>) -> T {
x.0
}
}
```
The old error was:
```
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> src/lib.rs:5:6
|
5 | impl<T> From<Wrap<T>> for T {
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
```
and the new error is:
```
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
--> main.rs:66:6
|
66 | impl<T> From<Wrap<T>> for T {
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
|
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
```
I tried to point at the uncovered `T`, but couldn't get something which was reliable (but I'll be happy to try if someone points me in the right direction).
r? @estebank
cc @nikomatsakisFixesrust-lang#65247
@JohnTitorJohnTitor mentioned this pull request Nov 14, 2019
bors added a commit that referenced this pull request Nov 14, 2019
Rollup of 9 pull requests
Successful merges:
- #66253 (Improve errors after re rebalance coherence)
- #66264 (fix an ICE in macro's diagnostic message)
- #66349 (expand source_util macros with def-site context)
- #66351 (Tweak non-char/numeric in range pattern diagnostic)
- #66360 (Fix link to Exten in Vec::set_len)
- #66361 (parser: don't use `unreachable!()` in `fn unexpected`.)
- #66363 (Improve error message in make_tests)
- #66369 (compiletest: Obtain timestamps for common inputs only once)
- #66372 (Fix broken links in Ipv4Addr::is_benchmarking docs)
Failed merges:
r? @ghost
@bors
bors merged commit 2db744c into rust-lang:masterNov 14, 2019
@ohadravid
ohadravid deleted the improve-errors-after-re-rebalance-coherence branch November 14, 2019 15:54
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-re_rebalance_coherence`#![feature(re_rebalance_coherence)]`S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing error message when trying to implement From<GenericLocalType<T>> for Option<T>

6 participants

@ohadravid@rust-highfive@estebank@bors@Centril@GuillaumeGomez