52985: better cycle error for existential types
- Original cycle error diagnostics PR'd against this issue caught
panic-causing error while resolving std::mem::transmute calls
- Now, catch invalid use case of not providing a concrete sized type
behind existential type in definining use case.
- Update relevant test to reflect this new error
52985: revert normalize query changes
- PR 53588 invalidates 53316, causing a correct cycle error to occur
with a good span.
- Don't need to revert the whole merge as the test files are
still fine, just need to revert the normalize query changes.
- It should now be correct that infinite recursion detected during
normalize query type folding is a bug, should have been caught earlier
(when resolving the existential type's defining use cases).
52985: code review impl
- Only cause cycle error if anonymous type resolves to anonymous type
that has the same def id (is the same type) as the original (parent)
type.
- Add test case to cover this case for existential types.
52985: remove Ty prefix from TyAnon
- To align with changes per commit 6f637da50c
This commit is contained in:
parent
b75b0471a8
commit
3045ffa512
4 changed files with 55 additions and 38 deletions
31
src/test/ui/existential_types/nested_existential_types.rs
Normal file
31
src/test/ui/existential_types/nested_existential_types.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2018 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(existential_type)]
|
||||
// compile-pass
|
||||
mod my_mod {
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub existential type Foo: Debug;
|
||||
pub existential type Foot: Debug;
|
||||
|
||||
pub fn get_foo() -> Foo {
|
||||
5i32
|
||||
}
|
||||
|
||||
pub fn get_foot() -> Foot {
|
||||
get_foo()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: my_mod::Foot = my_mod::get_foot();
|
||||
}
|
||||
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
error[E0391]: cycle detected when normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: Foo }`
|
||||
error[E0391]: cycle detected when processing `Foo`
|
||||
--> $DIR/no_inferrable_concrete_type.rs:16:1
|
||||
|
|
||||
LL | existential type Foo: Copy; //~ cycle detected
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: ...which again requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: Foo }`, completing the cycle
|
||||
note: ...which requires processing `bar`...
|
||||
--> $DIR/no_inferrable_concrete_type.rs:19:23
|
||||
|
|
||||
LL | fn bar(x: Foo) -> Foo { x }
|
||||
| ^^^^^
|
||||
= note: ...which again requires processing `Foo`, completing the cycle
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue