Skip to content

Commit 40c714c

Browse files
committed
discard eval modulo regions in favor of eval to ok
1 parent 59f551a commit 40c714c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14941494
// will then correctly report an inference error, since the
14951495
// existence of multiple marker trait impls tells us nothing
14961496
// about which one should actually apply.
1497-
!needs_infer
1497+
//
1498+
// If we have two marker trait impls which apply, but one of them
1499+
// has nested region obligations, we prefer the one without any.
1500+
//
1501+
// FIXME(lcnr): If we have 2 impls which only apply modulo regions
1502+
// this may still cause incorrect errors. That's not really something
1503+
// we can easily fix without some more complex refactoring
1504+
// and seems unlikely enough in practice, so lets just ignore that
1505+
// situation for now.
1506+
!(needs_infer
1507+
|| (victim.evaluation.must_apply_considering_regions()
1508+
&& !other.evaluation.must_apply_considering_regions()))
14981509
}
14991510
Some(_) => true,
15001511
None => false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
// Regression test for #84917.
3+
#![feature(marker_trait_attr)]
4+
5+
#[marker]
6+
pub trait F {}
7+
impl<T> F for T where T: Copy {}
8+
impl<T> F for T where T: 'static {}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)