-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try to recover the non-matching types in projection errors
The type equation in projection takes place under a binder and a snapshot, which we can't easily take types out of. Instead, when encountering a projection error, try to re-do the projection and find the type error then. This fails to produce a sane type error when the failure was a "leak_check" failure. I can't think of a sane way to show *these*, so I just left them use the old crappy representation, and added a test to make sure we don't break them.
- Loading branch information
Showing
3 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/compile-fail/associated-types/higher-ranked-projection.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(rustc_attrs)] | ||
|
||
// revisions: good bad | ||
|
||
trait Mirror { | ||
type Image; | ||
} | ||
|
||
impl<T> Mirror for T { | ||
type Image = T; | ||
} | ||
|
||
#[cfg(bad)] | ||
fn foo<U, T>(_t: T) | ||
where for<'a> &'a T: Mirror<Image=U> | ||
{} | ||
|
||
#[cfg(good)] | ||
fn foo<U, T>(_t: T) | ||
where for<'a> &'a T: Mirror<Image=&'a U> | ||
{} | ||
|
||
#[rustc_error] | ||
fn main() { //[good]~ ERROR compilation successful | ||
foo(()); | ||
//[bad]~^ ERROR type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _` | ||
//[bad]~| expected bound lifetime parameter 'a, found concrete lifetime | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters