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
Copy link
Member

@fmease fmease Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct; the existing logic in report_projection_error "can only deal with" / "is mostly geared to handle" projection mismatches, not arbitrary aliases mismatches.

Still, we currently map unsolved NormalizesTo and AliasRelate goals to FulfillmentErrorCode::Project (in fn fulfillment_error_for_no_solution).

Long term, we should probably rename+generalize FulfillmentErrorCode::Project to account for all AliasTerms and extend downstream code to handle all alias terms better (e.g., give more suggestions).

Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
};

if let Some(lhs) = lhs.to_alias_term()
&& let ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst = lhs.kind(self.tcx)
&& let Some((better_type_err, expected_term)) =
derive_better_type_error(lhs, rhs)
{
Expand All @@ -1615,6 +1616,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
better_type_err,
)
} else if let Some(rhs) = rhs.to_alias_term()
&& let ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst = rhs.kind(self.tcx)
&& let Some((better_type_err, expected_term)) =
derive_better_type_error(rhs, lhs)
{
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ compile-flags: -Znext-solver=globally
#![feature(type_alias_impl_trait)]

type Foo = Vec<impl Send>;

#[define_opaque(Foo)]
fn make_foo() -> Foo {}
//~^ ERROR type mismatch resolving

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0271]: type mismatch resolving `Foo == ()`
--> $DIR/opaque-alias-relate-issue-151331.rs:7:18
|
LL | fn make_foo() -> Foo {}
| ^^^ types differ

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0271`.
Loading