forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#56145 - weiznich:re_rebalance_coherence, r=…
…nikomatsakis Implement the Re-rebalance coherence RFC This is the first time I touch anything in the compiler so just tell me if I got something wrong. Big thanks to @sgrif for the pointers where to look for those things. cc rust-lang#55437
- Loading branch information
Showing
174 changed files
with
1,612 additions
and
263 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/doc/unstable-book/src/language-features/re-rebalance-coherence.md
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,23 @@ | ||
# `re_rebalance_coherence` | ||
|
||
The tracking issue for this feature is: [#55437] | ||
|
||
[#55437]: https://github.com/rust-lang/rust/issues/55437 | ||
|
||
------------------------ | ||
|
||
The `re_rebalance_coherence` feature tweaks the rules regarding which trait | ||
impls are allowed in crates. | ||
The following rule is used: | ||
|
||
Given `impl<P1..=Pn> Trait<T1..=Tn> for T0`, an impl is valid only if at | ||
least one of the following is true: | ||
- `Trait` is a local trait | ||
- All of | ||
- At least one of the types `T0..=Tn` must be a local type. Let `Ti` be the | ||
first such type. | ||
- No uncovered type parameters `P1..=Pn` may appear in `T0..Ti` (excluding | ||
`Ti`) | ||
|
||
|
||
See the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2451-re-rebalancing-coherence.md) for details. |
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
23 changes: 23 additions & 0 deletions
23
src/test/run-pass/coherence/auxiliary/re_rebalance_coherence_lib.rs
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,23 @@ | ||
|
||
pub trait Backend{} | ||
pub trait SupportsDefaultKeyword {} | ||
|
||
impl SupportsDefaultKeyword for Postgres {} | ||
|
||
pub struct Postgres; | ||
|
||
impl Backend for Postgres {} | ||
|
||
pub struct AstPass<DB>(::std::marker::PhantomData<DB>); | ||
|
||
pub trait QueryFragment<DB: Backend> {} | ||
|
||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct BatchInsert<'a, T: 'a, Tab> { | ||
_marker: ::std::marker::PhantomData<(&'a T, Tab)>, | ||
} | ||
|
||
impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab> | ||
where DB: SupportsDefaultKeyword + Backend, | ||
{} |
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
3 changes: 3 additions & 0 deletions
3
src/test/run-pass/coherence/coherence-covered-type-parameter.rs
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
3 changes: 3 additions & 0 deletions
3
src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs
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
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![allow(dead_code)] | ||
#![feature(re_rebalance_coherence)] | ||
|
||
// run-pass | ||
// aux-build:re_rebalance_coherence_lib.rs | ||
|
||
extern crate re_rebalance_coherence_lib as lib; | ||
use lib::*; | ||
|
||
struct Oracle; | ||
impl Backend for Oracle {} | ||
impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {} | ||
|
||
fn main() {} |
23 changes: 23 additions & 0 deletions
23
src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs
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,23 @@ | ||
|
||
pub trait Backend{} | ||
pub trait SupportsDefaultKeyword {} | ||
|
||
impl SupportsDefaultKeyword for Postgres {} | ||
|
||
pub struct Postgres; | ||
|
||
impl Backend for Postgres {} | ||
|
||
pub struct AstPass<DB>(::std::marker::PhantomData<DB>); | ||
|
||
pub trait QueryFragment<DB: Backend> {} | ||
|
||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct BatchInsert<'a, T: 'a, Tab> { | ||
_marker: ::std::marker::PhantomData<(&'a T, Tab)>, | ||
} | ||
|
||
impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab> | ||
where DB: SupportsDefaultKeyword + Backend, | ||
{} |
2 changes: 1 addition & 1 deletion
2
.../ui/coherence/coherence-all-remote.stderr → ...coherence/coherence-all-remote.old.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,11 @@ | ||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) | ||
--> $DIR/coherence-all-remote.rs:9:1 | ||
| | ||
LL | impl<T> Remote1<T> for isize { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | ||
| | ||
= note: only traits defined in the current crate can be implemented for a type parameter | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0210`. |
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,9 +1,13 @@ | ||
// aux-build:coherence_lib.rs | ||
// revisions: old re | ||
|
||
#![cfg_attr(re, feature(re_rebalance_coherence))] | ||
|
||
extern crate coherence_lib as lib; | ||
use lib::Remote1; | ||
|
||
impl<T> Remote1<T> for isize { } | ||
//~^ ERROR E0210 | ||
//[old]~^ ERROR E0210 | ||
//[re]~^^ ERROR E0210 | ||
|
||
fn main() { } |
2 changes: 1 addition & 1 deletion
2
...i/coherence/coherence-bigint-param.stderr → ...herence/coherence-bigint-param.old.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,11 @@ | ||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) | ||
--> $DIR/coherence-bigint-param.rs:11:1 | ||
| | ||
LL | impl<T> Remote1<BigInt> for T { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | ||
| | ||
= note: only traits defined in the current crate can be implemented for a type parameter | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0210`. |
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,11 +1,15 @@ | ||
// aux-build:coherence_lib.rs | ||
// revisions: old re | ||
|
||
#![cfg_attr(re, feature(re_rebalance_coherence))] | ||
|
||
extern crate coherence_lib as lib; | ||
use lib::Remote1; | ||
|
||
pub struct BigInt; | ||
|
||
impl<T> Remote1<BigInt> for T { } | ||
//~^ ERROR type parameter `T` must be used as the type parameter for some local type | ||
//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type | ||
//[re]~^^ ERROR E0210 | ||
|
||
fn main() { } |
4 changes: 2 additions & 2 deletions
4
...conflicts-with-blanket-implemented.stderr → ...licts-with-blanket-implemented.old.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
Oops, something went wrong.