Skip to content

Commit 3c4bc8c

Browse files
Ignore trait implementations with negative polarity when suggesting trait implementations in diagnostics
1 parent 4cbda82 commit 3c4bc8c

File tree

1 file changed

+11
-1
lines changed
  • compiler/rustc_trait_selection/src/traits/error_reporting

1 file changed

+11
-1
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1310,10 +1310,20 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
13101310
return None;
13111311
}
13121312
}
1313+
if self.tcx.impl_polarity(def_id) == ty::ImplPolarity::Negative {
1314+
return None;
1315+
}
13131316
Some(imp)
13141317
})
13151318
.collect(),
1316-
None => all_impls.map(|def_id| self.tcx.impl_trait_ref(def_id).unwrap()).collect(),
1319+
None => all_impls
1320+
.filter_map(|def_id| {
1321+
if self.tcx.impl_polarity(def_id) == ty::ImplPolarity::Negative {
1322+
return None;
1323+
}
1324+
self.tcx.impl_trait_ref(def_id)
1325+
})
1326+
.collect(),
13171327
}
13181328
}
13191329

0 commit comments

Comments
 (0)