-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in associated constant type annotations.
This commit reverses the variance used when relating types from the type annotation of an associated constant - this matches the behaviour of the lexical borrow checker and fixes a bug whereby matching a `&'a str` against a `&'static str` would produce an error.
- Loading branch information
Showing
6 changed files
with
106 additions
and
4 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
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
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
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
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,21 @@ | ||
#![feature(nll)] | ||
|
||
// compile-pass | ||
|
||
trait Foo<'a> { | ||
const C: &'a u32; | ||
} | ||
|
||
impl<'a, T> Foo<'a> for T { | ||
const C: &'a u32 = &22; | ||
} | ||
|
||
fn foo() { | ||
let a = 22; | ||
match &a { | ||
<() as Foo<'static>>::C => { } | ||
&_ => { } | ||
} | ||
} | ||
|
||
fn main() {} |
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,22 @@ | ||
#![feature(nll)] | ||
|
||
// compile-pass | ||
|
||
trait Foo { | ||
const BLAH: &'static str; | ||
} | ||
|
||
struct Placeholder; | ||
|
||
impl Foo for Placeholder { | ||
const BLAH: &'static str = "hi"; | ||
} | ||
|
||
fn foo(x: &str) { | ||
match x { | ||
<Placeholder as Foo>::BLAH => { } | ||
_ => { } | ||
} | ||
} | ||
|
||
fn main() {} |