mirror of https://github.com/rust-lang/rust.git
Unwrap an Option that can only be Some, as inherent impls can't overlap
This commit is contained in:
parent
90a43f1406
commit
a9e0e968be
|
@ -1590,12 +1590,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
def_id1: DefId,
|
||||
def_id2: DefId,
|
||||
) -> Option<ImplOverlapKind> {
|
||||
let impl_trait_ref1 = self.impl_trait_ref(def_id1);
|
||||
let impl_trait_ref2 = self.impl_trait_ref(def_id2);
|
||||
let impl_trait_ref1 = self.impl_trait_ref(def_id1).unwrap();
|
||||
let impl_trait_ref2 = self.impl_trait_ref(def_id2).unwrap();
|
||||
// If either trait impl references an error, they're allowed to overlap,
|
||||
// as one of them essentially doesn't exist.
|
||||
if impl_trait_ref1.is_some_and(|tr| tr.instantiate_identity().references_error())
|
||||
|| impl_trait_ref2.is_some_and(|tr| tr.instantiate_identity().references_error())
|
||||
if impl_trait_ref1.instantiate_identity().references_error()
|
||||
|| impl_trait_ref2.instantiate_identity().references_error()
|
||||
{
|
||||
return Some(ImplOverlapKind::Permitted { marker: false });
|
||||
}
|
||||
|
@ -1615,8 +1615,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
};
|
||||
|
||||
let is_marker_overlap = {
|
||||
let is_marker_impl = |trait_ref: Option<EarlyBinder<TraitRef<'_>>>| -> bool {
|
||||
trait_ref.is_some_and(|tr| self.trait_def(tr.skip_binder().def_id).is_marker)
|
||||
let is_marker_impl = |trait_ref: EarlyBinder<TraitRef<'_>>| -> bool {
|
||||
self.trait_def(trait_ref.skip_binder().def_id).is_marker
|
||||
};
|
||||
is_marker_impl(impl_trait_ref1) && is_marker_impl(impl_trait_ref2)
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue