Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ fn orphan_check<'tcx>(
}

// (1) Instantiate all generic params with fresh inference vars.
let infcx =
tcx.infer_ctxt().enable_next_solver_overflow_fcw(false).build(TypingMode::Coherence);
let infcx = tcx
.infer_ctxt()
.with_next_trait_solver(tcx.next_trait_solver_in_coherence())
.enable_next_solver_overflow_fcw(false)
.build(TypingMode::Coherence);
let cause = traits::ObligationCause::dummy();
let args = infcx.fresh_args_for_item(cause.span, impl_def_id.to_def_id());
let trait_ref = trait_ref.instantiate(tcx, args).skip_norm_wip();
Expand Down
14 changes: 0 additions & 14 deletions tests/crashes/148621.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ known-bug: #149703
//! Regression test for #149703.
#![feature(const_trait_impl)]
trait Z {
type Assoc;
Expand All @@ -8,5 +8,6 @@ impl<T: const FnOnce()> Z for T {
type Assoc = ();
}
impl<T> From<<A as Z>::Assoc> for T {}
//~^ ERROR type parameter `T` must be used as an argument to some local type

fn main() {}
12 changes: 12 additions & 0 deletions tests/ui/coherence/const-trait-impl-orphanck.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct<T>`)
--> $DIR/const-trait-impl-orphanck.rs:10:6
|
LL | impl<T> From<<A as Z>::Assoc> for T {}
| ^ uncovered type parameter
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0210`.
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/unpin-for-future.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
LL | impl Unpin for MyFut {}
| ^^^^^^^^^^^^^^^-----
| |
| type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate
| `MyFut` is not defined in the current crate
|
= note: impl doesn't have any local type before any uncovered type parameters
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/pin-ergonomics/impl-unpin.tait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
LL | impl Unpin for FooAlias {}
| ^^^^^^^^^^^^^^^--------
| |
| type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate
| `FooAlias` is not defined in the current crate
|
= note: impl doesn't have any local type before any uncovered type parameters
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
Expand All @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
LL | impl Unpin for BarAlias {}
| ^^^^^^^^^^^^^^^--------
| |
| type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate
| `BarAlias` is not defined in the current crate
|
= note: impl doesn't have any local type before any uncovered type parameters
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
Expand Down
15 changes: 0 additions & 15 deletions tests/ui/type-alias-impl-trait/coherence/coherence.classic.stderr

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ui/type-alias-impl-trait/coherence/coherence.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//@ aux-build:foreign-crate.rs
//@ revisions: classic next
//@[next] compile-flags: -Znext-solver
#![feature(type_alias_impl_trait)]

extern crate foreign_crate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence.rs:17:1
--> $DIR/coherence.rs:15:1
|
LL | impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// regression test for #148621
type Foo<V> = impl std::fmt::Debug; //~ ERROR `impl Trait` in type aliases is unstable
//~| ERROR unconstrained opaque type

trait Identity<Q> {
type T;
}

impl<Q> Clone for Foo<<() as Identity<Q>>::T> { //~ ERROR type parameter `Q` must be used as an argument to some local type
//~| ERROR the type parameter `Q` is not constrained by the impl trait, self type, or predicates
fn clone(&self) -> Self {
//~^ ERROR the trait bound `(): Identity<Q>` is not satisfied
loop {}
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
error[E0658]: `impl Trait` in type aliases is unstable
--> $DIR/orphanck-tait-with-projection-arg.rs:2:15
|
LL | type Foo<V> = impl std::fmt::Debug;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0210]: type parameter `Q` must be used as an argument to some local type (e.g., `MyStruct<Q>`)
--> $DIR/orphanck-tait-with-projection-arg.rs:9:6
|
LL | impl<Q> Clone for Foo<<() as Identity<Q>>::T> {
| ^ uncovered type parameter
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter

error[E0207]: the type parameter `Q` is not constrained by the impl trait, self type, or predicates
--> $DIR/orphanck-tait-with-projection-arg.rs:9:6
|
LL | impl<Q> Clone for Foo<<() as Identity<Q>>::T> {
| ^ unconstrained type parameter

error: unconstrained opaque type
--> $DIR/orphanck-tait-with-projection-arg.rs:2:15
|
LL | type Foo<V> = impl std::fmt::Debug;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `Foo` must be used in combination with a concrete type within the same crate

error[E0277]: the trait bound `(): Identity<Q>` is not satisfied
--> $DIR/orphanck-tait-with-projection-arg.rs:11:14
|
LL | fn clone(&self) -> Self {
| ^^^^^ the trait `Identity<Q>` is not implemented for `()`
|
help: this trait has no implementations, consider adding one
--> $DIR/orphanck-tait-with-projection-arg.rs:5:1
|
LL | trait Identity<Q> {
| ^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0207, E0210, E0277, E0658.
For more information about an error, try `rustc --explain E0207`.
Loading