forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#65738 - ohadravid:re-rebalance-coherence-al…
…low-fundamental-local, r=nikomatsakis Coherence should allow fundamental types to impl traits when they are local After rust-lang#64414, `impl<T> Remote for Box<T> { }` is disallowed, but it is also disallowed in liballoc, where `Box` is a local type! Enabling `#![feature(re_rebalance_coherence)]` in `liballoc` results in: ``` error[E0210]: type parameter `F` must be used as the type parameter for some local type (e.g., `MyStruct<F>`) --> src\liballoc\boxed.rs:1098:1 | 1098 | impl<F: ?Sized + Future + Unpin> Future for Box<F> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `F` must be used as the type parameter for some local type ``` This PR relaxes `uncover_fundamental_ty` to skip local fundamental types. I didn't add a test since `liballoc` already fails to compile, but I can add one if needed. r? @nikomatsakis cc rust-lang#63599
- Loading branch information
Showing
3 changed files
with
42 additions
and
4 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
16 changes: 16 additions & 0 deletions
16
src/test/ui/coherence/impl-foreign-for-locally-defined-fundamental.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,16 @@ | ||
#![feature(fundamental)] | ||
#![feature(re_rebalance_coherence)] | ||
|
||
// compile-flags:--crate-name=test | ||
// aux-build:coherence_lib.rs | ||
// check-pass | ||
|
||
extern crate coherence_lib as lib; | ||
use lib::*; | ||
|
||
#[fundamental] | ||
struct Local; | ||
|
||
impl Remote for Local {} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/coherence/impl-foreign-for-locally-defined-fundamental[foreign].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,16 @@ | ||
#![feature(fundamental)] | ||
#![feature(re_rebalance_coherence)] | ||
|
||
// compile-flags:--crate-name=test | ||
// aux-build:coherence_lib.rs | ||
// check-pass | ||
|
||
extern crate coherence_lib as lib; | ||
use lib::*; | ||
|
||
#[fundamental] | ||
struct MyBox<T>(T); | ||
|
||
impl<T> Remote for MyBox<T> {} | ||
|
||
fn main() {} |