-
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.
Rollup merge of #100386 - compiler-errors:sized-coinductive-redux, r=…
…lcnr Make `Sized` coinductive, again A revival of #83647 --- What exactly makes co-induction sound? Better question: are there any unsoundness risks from this? `Sized` can't be implemented by custom `impl` blocks, nor can it be conditionally implemented based on anything other than child fields being `Sized`, right? r? `@nikomatsakis` for whenever he gets back from vacation
- Loading branch information
Showing
18 changed files
with
118 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
// check-fail | ||
// known-bug: #80626 | ||
|
||
// This should pass, but it requires `Sized` to be coinductive. | ||
// check-pass | ||
|
||
trait Allocator { | ||
type Allocated<T>; | ||
} | ||
|
||
enum LinkedList<A: Allocator> { | ||
Head, | ||
Next(A::Allocated<Self>) | ||
Next(A::Allocated<Self>), | ||
} | ||
|
||
fn main() {} |
15 changes: 0 additions & 15 deletions
15
src/test/ui/generic-associated-types/bugs/issue-80626.stderr
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
14 changes: 4 additions & 10 deletions
14
src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr
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
14 changes: 4 additions & 10 deletions
14
src/test/ui/generic-associated-types/projection-bound-cycle.stderr
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,14 @@ | ||
// check-pass | ||
struct Node<C: Trait>(C::Assoc::<Self>); | ||
|
||
trait Trait { | ||
type Assoc<T>; | ||
} | ||
|
||
impl Trait for Vec<()> { | ||
type Assoc<T> = Vec<T>; | ||
} | ||
|
||
fn main() { | ||
let _ = Node::<Vec<()>>(Vec::new()); | ||
} |
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,14 @@ | ||
// check-pass | ||
struct Node<C: Trait<Self>>(C::Assoc); | ||
|
||
trait Trait<T> { | ||
type Assoc; | ||
} | ||
|
||
impl<T> Trait<T> for Vec<()> { | ||
type Assoc = Vec<T>; | ||
} | ||
|
||
fn main() { | ||
let _ = Node::<Vec<()>>(Vec::new()); | ||
} |
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,28 @@ | ||
// run-pass | ||
struct Node<C: CollectionFactory<Self>> { | ||
_children: C::Collection, | ||
} | ||
|
||
trait CollectionFactory<T> { | ||
type Collection; | ||
} | ||
|
||
impl<T> CollectionFactory<T> for Vec<()> { | ||
type Collection = Vec<T>; | ||
} | ||
|
||
trait Collection<T>: Sized { | ||
fn push(&mut self, v: T); | ||
} | ||
|
||
impl<T> Collection<T> for Vec<T> { | ||
fn push(&mut self, v: T) { | ||
self.push(v) | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = Node::<Vec<()>> { | ||
_children: Vec::new(), | ||
}; | ||
} |
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,10 @@ | ||
// check-pass | ||
trait A { type Assoc; } | ||
|
||
impl A for () { | ||
// FIXME: it would be nice for this to at least cause a warning. | ||
type Assoc = Foo<()>; | ||
} | ||
struct Foo<T: A>(T::Assoc); | ||
|
||
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,13 @@ | ||
// build-fail | ||
//~^ ERROR cycle detected when computing layout of `Foo<()>` | ||
|
||
trait A { type Assoc: ?Sized; } | ||
|
||
impl A for () { | ||
type Assoc = Foo<()>; | ||
} | ||
struct Foo<T: A>(T::Assoc); | ||
|
||
fn main() { | ||
let x: Foo<()>; | ||
} |
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,13 @@ | ||
error[E0391]: cycle detected when computing layout of `Foo<()>` | ||
| | ||
= note: ...which requires computing layout of `<() as A>::Assoc`... | ||
= note: ...which again requires computing layout of `Foo<()>`, completing the cycle | ||
note: cycle used when elaborating drops for `main` | ||
--> $DIR/recursive-type-2.rs:11:1 | ||
| | ||
LL | fn main() { | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0391`. |
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 was deleted.
Oops, something went wrong.