Skip to content

Commit c7a4942

Browse files
authored
Rollup merge of #100688 - compiler-errors:issue-100684, r=wesleywiser
`ty::Error` does not match other types for region constraints Fixes #100684
2 parents 3de034d + fc7fc0f commit c7a4942

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

compiler/rustc_infer/src/infer/outlives/test_type_match.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,14 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
174174

175175
#[instrument(skip(self), level = "debug")]
176176
fn tys(&mut self, pattern: Ty<'tcx>, value: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
177-
if pattern == value { Ok(pattern) } else { relate::super_relate_tys(self, pattern, value) }
177+
if let ty::Error(_) = pattern.kind() {
178+
// Unlike normal `TypeRelation` rules, `ty::Error` does not equal any type.
179+
self.no_match()
180+
} else if pattern == value {
181+
Ok(pattern)
182+
} else {
183+
relate::super_relate_tys(self, pattern, value)
184+
}
178185
}
179186

180187
#[instrument(skip(self), level = "debug")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trait HandlerFamily {
2+
type Target;
3+
}
4+
5+
struct HandlerWrapper<H: HandlerFamily>(H);
6+
7+
impl<H: HandlerFamily> HandlerWrapper<H> {
8+
pub fn set_handler(&self, handler: &H::Target)
9+
where
10+
T: Send + Sync + 'static,
11+
//~^ ERROR cannot find type `T` in this scope
12+
{
13+
}
14+
}
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0412]: cannot find type `T` in this scope
2+
--> $DIR/outlives-with-missing.rs:10:9
3+
|
4+
LL | impl<H: HandlerFamily> HandlerWrapper<H> {
5+
| - similarly named type parameter `H` defined here
6+
...
7+
LL | T: Send + Sync + 'static,
8+
| ^ help: a type parameter with a similar name exists: `H`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)