Don't ICE for completely unexpandable `impl Trait` types
This commit is contained in:
parent
89e645ace8
commit
707315857a
|
@ -479,10 +479,12 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
let mut skip_add = false;
|
||||
|
||||
if let ty::Opaque(defin_ty_def_id, _substs) = definition_ty.kind {
|
||||
if def_id == defin_ty_def_id {
|
||||
debug!("Skipping adding concrete definition for opaque type {:?} {:?}",
|
||||
opaque_defn, defin_ty_def_id);
|
||||
skip_add = true;
|
||||
if let hir::OpaqueTyOrigin::TypeAlias = opaque_defn.origin {
|
||||
if def_id == defin_ty_def_id {
|
||||
debug!("Skipping adding concrete definition for opaque type {:?} {:?}",
|
||||
opaque_defn, defin_ty_def_id);
|
||||
skip_add = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// Test that an impl trait type that expands to itself is an error.
|
||||
|
||||
fn test() -> impl Sized { //~ ERROR E0720
|
||||
test()
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,11 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type-direct.rs:3:14
|
||||
|
|
||||
LL | fn test() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: type resolves to itself
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0720`.
|
|
@ -1,5 +1,5 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:6:22
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:6:22
|
||||
|
|
||||
LL | fn option(i: i32) -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -7,7 +7,7 @@ LL | fn option(i: i32) -> impl Sized {
|
|||
= note: expanded type is `std::option::Option<(impl Sized, i32)>`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:14:15
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:14:15
|
||||
|
|
||||
LL | fn tuple() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -15,7 +15,7 @@ LL | fn tuple() -> impl Sized {
|
|||
= note: expanded type is `(impl Sized,)`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:18:15
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:18:15
|
||||
|
|
||||
LL | fn array() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -23,7 +23,7 @@ LL | fn array() -> impl Sized {
|
|||
= note: expanded type is `[impl Sized; 1]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:22:13
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:22:13
|
||||
|
|
||||
LL | fn ptr() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -31,7 +31,7 @@ LL | fn ptr() -> impl Sized {
|
|||
= note: expanded type is `*const impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:26:16
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:26:16
|
||||
|
|
||||
LL | fn fn_ptr() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -39,47 +39,47 @@ LL | fn fn_ptr() -> impl Sized {
|
|||
= note: expanded type is `fn() -> impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:30:25
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:30:25
|
||||
|
|
||||
LL | fn closure_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:32:5: 32:19 x:impl Sized]`
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:32:5: 32:19 x:impl Sized]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:35:29
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:35:29
|
||||
|
|
||||
LL | fn closure_ref_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:37:5: 37:20 x:impl Sized]`
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:37:5: 37:20 x:impl Sized]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:40:21
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:40:21
|
||||
|
|
||||
LL | fn closure_sig() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:41:5: 41:21]`
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:41:5: 41:21]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:44:23
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:44:23
|
||||
|
|
||||
LL | fn generator_sig() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:45:5: 45:23]`
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:45:5: 45:23]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:48:27
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:48:27
|
||||
|
|
||||
LL | fn generator_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type.rs:50:5: 50:26 x:impl Sized {()}]`
|
||||
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:26 x:impl Sized {()}]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:53:26
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:53:26
|
||||
|
|
||||
LL | fn substs_change<T>() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -87,15 +87,15 @@ LL | fn substs_change<T>() -> impl Sized {
|
|||
= note: expanded type is `(impl Sized,)`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:57:24
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:57:24
|
||||
|
|
||||
LL | fn generator_hold() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type.rs:58:5: 62:6 {impl Sized, ()}]`
|
||||
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:58:5: 62:6 {impl Sized, ()}]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:69:26
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:69:26
|
||||
|
|
||||
LL | fn mutual_recursion() -> impl Sync {
|
||||
| ^^^^^^^^^ expands to a recursive type
|
||||
|
@ -103,7 +103,7 @@ LL | fn mutual_recursion() -> impl Sync {
|
|||
= note: type resolves to itself
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type.rs:73:28
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:73:28
|
||||
|
|
||||
LL | fn mutual_recursion_b() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
|
@ -1,5 +1,5 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type--through-non-recursize.rs:7:22
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:7:22
|
||||
|
|
||||
LL | fn recursive_id() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -7,7 +7,7 @@ LL | fn recursive_id() -> impl Sized {
|
|||
= note: type resolves to itself
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type--through-non-recursize.rs:11:23
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:11:23
|
||||
|
|
||||
LL | fn recursive_id2() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -15,7 +15,7 @@ LL | fn recursive_id2() -> impl Sized {
|
|||
= note: type resolves to itself
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type--through-non-recursize.rs:17:24
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:17:24
|
||||
|
|
||||
LL | fn recursive_wrap() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
@ -23,7 +23,7 @@ LL | fn recursive_wrap() -> impl Sized {
|
|||
= note: expanded type is `((impl Sized,),)`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
--> $DIR/recursive-impl-trait-type--through-non-recursize.rs:21:25
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:21:25
|
||||
|
|
||||
LL | fn recursive_wrap2() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
Loading…
Reference in New Issue