Skip to content

Commit 72fee12

Browse files
Merge pull request #22617 from ada4a/push-mtxzotmzskkx
fix(implements_trait_unique_with_infcx): only forbid the self type from being an error type
2 parents d1cfbe2 + 236121b commit 72fee12

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

crates/hir-ty/src/traits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use hir_expand::name::Name;
2020
use intern::sym;
2121
use rustc_type_ir::{
2222
TypeVisitableExt, TypingMode,
23-
inherent::{BoundExistentialPredicates, GenericArg as _, IntoKind, Ty as _},
23+
inherent::{BoundExistentialPredicates, IntoKind, Ty as _},
2424
};
2525

2626
use crate::{
@@ -153,10 +153,10 @@ pub fn implements_trait_unique_with_infcx<'db>(
153153
let infcx = interner.infer_ctxt().build(TypingMode::non_body_analysis());
154154

155155
let args = create_args(&infcx);
156-
if args.iter().filter_map(|it| it.as_type()).any(|ty| ty.is_ty_error()) {
156+
let trait_ref = rustc_type_ir::TraitRef::new_from_args(interner, trait_.into(), args);
157+
if trait_ref.self_ty().is_ty_error() {
157158
return false;
158159
}
159-
let trait_ref = rustc_type_ir::TraitRef::new_from_args(interner, trait_.into(), args);
160160

161161
let obligation = Obligation::new(interner, ObligationCause::dummy(), env.param_env, trait_ref);
162162
infcx.predicate_must_hold_modulo_regions(&obligation)

0 commit comments

Comments
 (0)