Fix re-rebalance coherence implementation for fundamental types
Fixes #64412
This commit is contained in:
parent
e69d1b67b6
commit
3f004a1bc4
3 changed files with 30 additions and 4 deletions
|
@ -378,7 +378,15 @@ fn orphan_check_trait_ref<'tcx>(
|
|||
// Let Ti be the first such type.
|
||||
// - No uncovered type parameters P1..=Pn may appear in T0..Ti (excluding Ti)
|
||||
//
|
||||
for input_ty in trait_ref.input_types() {
|
||||
fn uncover_fundamental_ty(ty: Ty<'_>) -> Vec<Ty<'_>> {
|
||||
if fundamental_ty(ty) {
|
||||
ty.walk_shallow().flat_map(|ty| uncover_fundamental_ty(ty)).collect()
|
||||
} else {
|
||||
vec![ty]
|
||||
}
|
||||
}
|
||||
|
||||
for input_ty in trait_ref.input_types().flat_map(uncover_fundamental_ty) {
|
||||
debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty);
|
||||
if ty_is_local(tcx, input_ty, in_crate) {
|
||||
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
// compile-flags:--crate-name=test
|
||||
// aux-build:coherence_lib.rs
|
||||
// check-pass
|
||||
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::*;
|
||||
|
@ -11,11 +10,11 @@ use std::rc::Rc;
|
|||
struct Local;
|
||||
|
||||
impl<T> Remote1<Local> for Box<T> {
|
||||
// FIXME(#64412) -- this is expected to error
|
||||
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
|
||||
}
|
||||
|
||||
impl<T> Remote1<Local> for &T {
|
||||
// FIXME(#64412) -- this is expected to error
|
||||
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
|
||||
--> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:12:1
|
||||
|
|
||||
LL | impl<T> Remote1<Local> for Box<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[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
|
||||
--> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:16:1
|
||||
|
|
||||
LL | impl<T> Remote1<Local> 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 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0210`.
|
Loading…
Add table
Reference in a new issue