Auto merge of #55323 - nikomatsakis:nll-ICE-55219-and-55241, r=pnkfelix
introduce type-op for user-type ascription in NLL Handle user-type ascription in a type operator, which gives us a lot more flexibility around the order in which we resolve things. r? @pnkfelix Fixes #55219 Fixes #55241
This commit is contained in:
commit
3476ac0bee
15 changed files with 367 additions and 126 deletions
20
src/test/ui/nll/user-annotations/issue-55219.rs
Normal file
20
src/test/ui/nll/user-annotations/issue-55219.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Regression test for #55219:
|
||||
//
|
||||
// The `Self::HASH_LEN` here expands to a "self-type" where `T` is not
|
||||
// known. This unbound inference variable was causing an ICE.
|
||||
//
|
||||
// run-pass
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
pub struct Foo<T>(T);
|
||||
|
||||
impl<T> Foo<T> {
|
||||
const HASH_LEN: usize = 20;
|
||||
|
||||
fn stuff() {
|
||||
let _ = Self::HASH_LEN;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
28
src/test/ui/nll/user-annotations/issue-55241.rs
Normal file
28
src/test/ui/nll/user-annotations/issue-55241.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Regression test for #55241:
|
||||
//
|
||||
// The reference to `C::HASHED_NULL_NODE` resulted in a type like `<C
|
||||
// as NodeCodec<_>>::Out`; normalizing this type requires knowing the
|
||||
// value of `_`; solving that requires having normalized, so we can
|
||||
// test against `C: NodeCodec<H>` in the environment.
|
||||
//
|
||||
// run-pass
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
pub trait Hasher {
|
||||
type Out: Eq;
|
||||
}
|
||||
|
||||
pub trait NodeCodec<H: Hasher> {
|
||||
const HASHED_NULL_NODE: H::Out;
|
||||
}
|
||||
|
||||
pub trait Trie<H: Hasher, C: NodeCodec<H>> {
|
||||
/// Return the root of the trie.
|
||||
fn root(&self) -> &H::Out;
|
||||
|
||||
/// Is the trie empty?
|
||||
fn is_empty(&self) -> bool { *self.root() == C::HASHED_NULL_NODE }
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -12,21 +12,6 @@ LL | let z: &'a & usize = &(&y);
|
|||
LL | }
|
||||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/regions-free-region-ordering-caller1.rs:19:27
|
||||
|
|
||||
LL | fn call1<'a>(x: &'a usize) {
|
||||
| -- lifetime `'a` defined here
|
||||
...
|
||||
LL | let z: &'a & usize = &(&y);
|
||||
| ----------- ^^^^ borrowed value does not live long enough
|
||||
| |
|
||||
| type annotation requires that `y` is borrowed for `'a`
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
error: aborting due to previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0597, E0716.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0716`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue