-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Coherence should allow fundamental types to impl traits when they are local #65738
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Coherence should allow fundamental types to impl traits when they are local #65738
Conversation
f36742a
to
67953fd
Compare
Heh, good catch @ohadravid -- I'm torn about the test. You're right that we don't need one in some sense but I think if you don't mind adding one it would help us to prevent similar oversights in the future. |
67953fd
to
8f988bd
Compare
@nikomatsakis I added two tests which should prevent a regression. BTW I can also open the stabilization PR for Original failures are:
and
|
@bors r+ |
📌 Commit 8f988bd has been approved by |
@ohadravid thanks! And yes, a stabilization PR would be great! Please explicitly add |
…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
…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
…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
Rollup of 6 pull requests Successful merges: - #65566 (Use heuristics to suggest assignment) - #65738 (Coherence should allow fundamental types to impl traits when they are local) - #65777 (Don't ICE for completely unexpandable `impl Trait` types) - #65834 (Remove lint callback from driver) - #65839 (Clean up `check_consts` now that new promotion pass is implemented) - #65855 (Add long error explaination for E0666) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #65869) made this pull request unmergeable. Please resolve the merge conflicts. |
After #64414,
impl<T> Remote for Box<T> { }
is disallowed, but it is also disallowed in liballoc, whereBox
is a local type!Enabling
#![feature(re_rebalance_coherence)]
inliballoc
results in: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 #63599