On recursive ADT, provide indirection structured suggestion

This commit is contained in:
Esteban Küber 2020-05-29 09:24:59 -07:00
parent bb8674837a
commit c29b3fa148
27 changed files with 315 additions and 66 deletions

View file

@ -6,7 +6,14 @@ LL | enum MList { Cons(isize, MList), Nil }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `MList` representable
help: insert some indirection to make `MList` representable
|
LL | enum MList { Cons(isize, Box<MList>), Nil }
| ^^^^ ^
LL | enum MList { Cons(isize, Rc<MList>), Nil }
| ^^^ ^
LL | enum MList { Cons(isize, &MList), Nil }
| ^
error[E0391]: cycle detected when computing drop-check constraints for `MList`
--> $DIR/infinite-tag-type-recursion.rs:1:1

View file

@ -2,11 +2,18 @@ error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-1.rs:1:1
|
LL | struct Foo { foo: Option<Option<Foo>> }
| ^^^^^^^^^^ ------------------------ recursive without indirection
| ^^^^^^^^^^ ------------------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | struct Foo { foo: Box<Option<Option<Foo>>> }
| ^^^^ ^
LL | struct Foo { foo: Rc<Option<Option<Foo>>> }
| ^^^ ^
LL | struct Foo { foo: &Option<Option<Foo>> }
| ^
error: aborting due to previous error

View file

@ -2,21 +2,35 @@ error[E0072]: recursive type `Baz` has infinite size
--> $DIR/issue-17431-2.rs:1:1
|
LL | struct Baz { q: Option<Foo> }
| ^^^^^^^^^^ -------------- recursive without indirection
| ^^^^^^^^^^ ----------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Baz` representable
help: insert some indirection to make `Baz` representable
|
LL | struct Baz { q: Box<Option<Foo>> }
| ^^^^ ^
LL | struct Baz { q: Rc<Option<Foo>> }
| ^^^ ^
LL | struct Baz { q: &Option<Foo> }
| ^
error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-2.rs:4:1
|
LL | struct Foo { q: Option<Baz> }
| ^^^^^^^^^^ -------------- recursive without indirection
| ^^^^^^^^^^ ----------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | struct Foo { q: Box<Option<Baz>> }
| ^^^^ ^
LL | struct Foo { q: Rc<Option<Baz>> }
| ^^^ ^
LL | struct Foo { q: &Option<Baz> }
| ^
error: aborting due to 2 previous errors

View file

@ -2,11 +2,18 @@ error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-3.rs:3:1
|
LL | struct Foo { foo: Mutex<Option<Foo>> }
| ^^^^^^^^^^ ----------------------- recursive without indirection
| ^^^^^^^^^^ ------------------ recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | struct Foo { foo: Box<Mutex<Option<Foo>>> }
| ^^^^ ^
LL | struct Foo { foo: Rc<Mutex<Option<Foo>>> }
| ^^^ ^
LL | struct Foo { foo: &Mutex<Option<Foo>> }
| ^
error: aborting due to previous error

View file

@ -2,11 +2,18 @@ error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-4.rs:3:1
|
LL | struct Foo<T> { foo: Option<Option<Foo<T>>>, marker: marker::PhantomData<T> }
| ^^^^^^^^^^^^^ --------------------------- recursive without indirection
| ^^^^^^^^^^^^^ ---------------------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | struct Foo<T> { foo: Box<Option<Option<Foo<T>>>>, marker: marker::PhantomData<T> }
| ^^^^ ^
LL | struct Foo<T> { foo: Rc<Option<Option<Foo<T>>>>, marker: marker::PhantomData<T> }
| ^^^ ^
LL | struct Foo<T> { foo: &Option<Option<Foo<T>>>, marker: marker::PhantomData<T> }
| ^
error: aborting due to previous error

View file

@ -2,11 +2,18 @@ error[E0072]: recursive type `Bar` has infinite size
--> $DIR/issue-17431-5.rs:5:1
|
LL | struct Bar<T> { x: Bar<Foo> , marker: marker::PhantomData<T> }
| ^^^^^^^^^^^^^ ----------- recursive without indirection
| ^^^^^^^^^^^^^ -------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Bar` representable
help: insert some indirection to make `Bar` representable
|
LL | struct Bar<T> { x: Box<Bar<Foo>> , marker: marker::PhantomData<T> }
| ^^^^ ^
LL | struct Bar<T> { x: Rc<Bar<Foo>> , marker: marker::PhantomData<T> }
| ^^^ ^
LL | struct Bar<T> { x: &Bar<Foo> , marker: marker::PhantomData<T> }
| ^
error: aborting due to previous error

View file

@ -6,7 +6,14 @@ LL | enum Foo { X(Mutex<Option<Foo>>) }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | enum Foo { X(Box<Mutex<Option<Foo>>>) }
| ^^^^ ^
LL | enum Foo { X(Rc<Mutex<Option<Foo>>>) }
| ^^^ ^
LL | enum Foo { X(&Mutex<Option<Foo>>) }
| ^
error: aborting due to previous error

View file

@ -6,7 +6,14 @@ LL | enum Foo { Voo(Option<Option<Foo>>) }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | enum Foo { Voo(Box<Option<Option<Foo>>>) }
| ^^^^ ^
LL | enum Foo { Voo(Rc<Option<Option<Foo>>>) }
| ^^^ ^
LL | enum Foo { Voo(&Option<Option<Foo>>) }
| ^
error: aborting due to previous error

View file

@ -7,7 +7,14 @@ LL | pub struct Pong(SendPacket<Ping>);
| | recursive without indirection
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `pingpong::Pong` representable
help: insert some indirection to make `pingpong::Pong` representable
|
LL | pub struct Pong(Box<SendPacket<Ping>>);
| ^^^^ ^
LL | pub struct Pong(Rc<SendPacket<Ping>>);
| ^^^ ^
LL | pub struct Pong(&SendPacket<Ping>);
| ^
error: aborting due to previous error

View file

@ -7,7 +7,14 @@ LL | enum Bar {
LL | BarSome(Bar)
| --- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Bar` representable
help: insert some indirection to make `Bar` representable
|
LL | BarSome(Box<Bar>)
| ^^^^ ^
LL | BarSome(Rc<Bar>)
| ^^^ ^
LL | BarSome(&Bar)
| ^
error: aborting due to previous error

View file

@ -2,11 +2,18 @@ error[E0072]: recursive type `Bar` has infinite size
--> $DIR/issue-3008-2.rs:2:1
|
LL | struct Bar { x: Bar }
| ^^^^^^^^^^ ------ recursive without indirection
| ^^^^^^^^^^ --- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Bar` representable
help: insert some indirection to make `Bar` representable
|
LL | struct Bar { x: Box<Bar> }
| ^^^^ ^
LL | struct Bar { x: Rc<Bar> }
| ^^^ ^
LL | struct Bar { x: &Bar }
| ^
error: aborting due to previous error

View file

@ -6,7 +6,14 @@ LL | enum E2<T> { V2(E2<E1>, marker::PhantomData<T>), }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `E2` representable
help: insert some indirection to make `E2` representable
|
LL | enum E2<T> { V2(Box<E2<E1>>, marker::PhantomData<T>), }
| ^^^^ ^
LL | enum E2<T> { V2(Rc<E2<E1>>, marker::PhantomData<T>), }
| ^^^ ^
LL | enum E2<T> { V2(&E2<E1>, marker::PhantomData<T>), }
| ^
error: aborting due to previous error

View file

@ -8,7 +8,10 @@ LL | Plus(Expr, Expr),
| |
| recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Expr` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Expr` representable
|
LL | Plus(Box<Expr>, Box<Expr>),
| ^^^^ ^ ^^^^ ^
error: aborting due to previous error

View file

@ -5,9 +5,16 @@ LL | struct S {
| ^^^^^^^^ recursive type has infinite size
LL |
LL | element: Option<S>
| ------------------ recursive without indirection
| --------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `S` representable
help: insert some indirection to make `S` representable
|
LL | element: Box<Option<S>>
| ^^^^ ^
LL | element: Rc<Option<S>>
| ^^^ ^
LL | element: &Option<S>
| ^
error: aborting due to previous error

View file

@ -7,7 +7,14 @@ LL | Class(ClassTypeSignature),
LL | Array(TypeSignature),
| ------------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ObjectType` representable
help: insert some indirection to make `ObjectType` representable
|
LL | Array(Box<TypeSignature>),
| ^^^^ ^
LL | Array(Rc<TypeSignature>),
| ^^^ ^
LL | Array(&TypeSignature),
| ^
error[E0072]: recursive type `TypeSignature` has infinite size
--> $DIR/issue-57271.rs:19:1
@ -18,7 +25,14 @@ LL | Base(BaseType),
LL | Object(ObjectType),
| ---------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `TypeSignature` representable
help: insert some indirection to make `TypeSignature` representable
|
LL | Object(Box<ObjectType>),
| ^^^^ ^
LL | Object(Rc<ObjectType>),
| ^^^ ^
LL | Object(&ObjectType),
| ^
error: aborting due to 2 previous errors

View file

@ -6,7 +6,14 @@ LL | enum List<T> { Cons(T, List<T>), Nil }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `List` representable
help: insert some indirection to make `List` representable
|
LL | enum List<T> { Cons(T, Box<List<T>>), Nil }
| ^^^^ ^
LL | enum List<T> { Cons(T, Rc<List<T>>), Nil }
| ^^^ ^
LL | enum List<T> { Cons(T, &List<T>), Nil }
| ^
error: aborting due to previous error

View file

@ -2,21 +2,35 @@ error[E0072]: recursive type `Baz` has infinite size
--> $DIR/sized-cycle-note.rs:9:1
|
LL | struct Baz { q: Option<Foo> }
| ^^^^^^^^^^ -------------- recursive without indirection
| ^^^^^^^^^^ ----------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Baz` representable
help: insert some indirection to make `Baz` representable
|
LL | struct Baz { q: Box<Option<Foo>> }
| ^^^^ ^
LL | struct Baz { q: Rc<Option<Foo>> }
| ^^^ ^
LL | struct Baz { q: &Option<Foo> }
| ^
error[E0072]: recursive type `Foo` has infinite size
--> $DIR/sized-cycle-note.rs:11:1
|
LL | struct Foo { q: Option<Baz> }
| ^^^^^^^^^^ -------------- recursive without indirection
| ^^^^^^^^^^ ----------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | struct Foo { q: Box<Option<Baz>> }
| ^^^^ ^
LL | struct Foo { q: Rc<Option<Baz>> }
| ^^^ ^
LL | struct Foo { q: &Option<Baz> }
| ^
error: aborting due to 2 previous errors

View file

@ -5,9 +5,16 @@ LL | struct ListNode {
| ^^^^^^^^^^^^^^^ recursive type has infinite size
LL | head: u8,
LL | tail: Option<ListNode>,
| ---------------------- recursive without indirection
| ---------------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ListNode` representable
help: insert some indirection to make `ListNode` representable
|
LL | tail: Box<Option<ListNode>>,
| ^^^^ ^
LL | tail: Rc<Option<ListNode>>,
| ^^^ ^
LL | tail: &Option<ListNode>,
| ^
error: aborting due to previous error

View file

@ -6,11 +6,18 @@ LL | | ListNode
LL | | {
LL | | head: u8,
LL | | tail: Option<ListNode>,
| | ---------------------- recursive without indirection
| | ---------------- recursive without indirection
LL | | }
| |_^ recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ListNode` representable
help: insert some indirection to make `ListNode` representable
|
LL | tail: Box<Option<ListNode>>,
| ^^^^ ^
LL | tail: Rc<Option<ListNode>>,
| ^^^ ^
LL | tail: &Option<ListNode>,
| ^
error: aborting due to previous error

View file

@ -4,9 +4,16 @@ error[E0072]: recursive type `Foo` has infinite size
LL | struct Foo<'a> {
| ^^^^^^^^^^^^^^ recursive type has infinite size
LL | bar: Bar<'a>,
| ------------ recursive without indirection
| ------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection to make `Foo` representable
|
LL | bar: Box<Bar<'a>>,
| ^^^^ ^
LL | bar: Rc<Bar<'a>>,
| ^^^ ^
LL | bar: &Bar<'a>,
| ^
error[E0072]: recursive type `Bar` has infinite size
--> $DIR/recursive-type-field.rs:8:1
@ -14,18 +21,18 @@ error[E0072]: recursive type `Bar` has infinite size
LL | struct Bar<'a> {
| ^^^^^^^^^^^^^^ recursive type has infinite size
LL | y: (Foo<'a>, Foo<'a>),
| --------------------- recursive without indirection
| ------------------ recursive without indirection
LL | z: Option<Bar<'a>>,
| ------------------ recursive without indirection
| --------------- recursive without indirection
...
LL | d: [Bar<'a>; 1],
| --------------- recursive without indirection
| ------------ recursive without indirection
LL | e: Foo<'a>,
| ---------- recursive without indirection
| ------- recursive without indirection
LL | x: Bar<'a>,
| ---------- recursive without indirection
| ------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Bar` representable
= help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Bar` representable
error: aborting due to 2 previous errors

View file

@ -5,9 +5,16 @@ LL | struct T1 {
| ^^^^^^^^^ recursive type has infinite size
LL | foo: isize,
LL | foolish: T1
| ----------- recursive without indirection
| -- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `T1` representable
help: insert some indirection to make `T1` representable
|
LL | foolish: Box<T1>
| ^^^^ ^
LL | foolish: Rc<T1>
| ^^^ ^
LL | foolish: &T1
| ^
error: aborting due to previous error

View file

@ -5,9 +5,16 @@ LL | union U {
| ^^^^^^^ recursive type has infinite size
LL | a: u8,
LL | b: U,
| ---- recursive without indirection
| - recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `U` representable
help: insert some indirection to make `U` representable
|
LL | b: Box<U>,
| ^^^^ ^
LL | b: Rc<U>,
| ^^^ ^
LL | b: &U,
| ^
error: aborting due to previous error