diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-17 17:23:52 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-17 17:23:52 +0000 |
| commit | fc7fc0fae5079bc433a6e377b163a2a0757d65cd (patch) | |
| tree | 57b3f3fbe1847c1eb54ec002edebcec36742743f | |
| parent | 86c6ebee8fa0a5ad1e18e375113b06bd2849b634 (diff) | |
| download | rust-fc7fc0fae5079bc433a6e377b163a2a0757d65cd.tar.gz rust-fc7fc0fae5079bc433a6e377b163a2a0757d65cd.zip | |
ty::Error does not match other types for region constraints
| -rw-r--r-- | compiler/rustc_infer/src/infer/outlives/test_type_match.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/regions/outlives-with-missing.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/regions/outlives-with-missing.stderr | 12 |
3 files changed, 36 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index 772e297b7b4..be03c8b5bae 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -174,7 +174,14 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> { #[instrument(skip(self), level = "debug")] fn tys(&mut self, pattern: Ty<'tcx>, value: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - if pattern == value { Ok(pattern) } else { relate::super_relate_tys(self, pattern, value) } + if let ty::Error(_) = pattern.kind() { + // Unlike normal `TypeRelation` rules, `ty::Error` does not equal any type. + self.no_match() + } else if pattern == value { + Ok(pattern) + } else { + relate::super_relate_tys(self, pattern, value) + } } #[instrument(skip(self), level = "debug")] diff --git a/src/test/ui/regions/outlives-with-missing.rs b/src/test/ui/regions/outlives-with-missing.rs new file mode 100644 index 00000000000..29d89718b58 --- /dev/null +++ b/src/test/ui/regions/outlives-with-missing.rs @@ -0,0 +1,16 @@ +trait HandlerFamily { + type Target; +} + +struct HandlerWrapper<H: HandlerFamily>(H); + +impl<H: HandlerFamily> HandlerWrapper<H> { + pub fn set_handler(&self, handler: &H::Target) + where + T: Send + Sync + 'static, + //~^ ERROR cannot find type `T` in this scope + { + } +} + +fn main() {} diff --git a/src/test/ui/regions/outlives-with-missing.stderr b/src/test/ui/regions/outlives-with-missing.stderr new file mode 100644 index 00000000000..e204c918724 --- /dev/null +++ b/src/test/ui/regions/outlives-with-missing.stderr @@ -0,0 +1,12 @@ +error[E0412]: cannot find type `T` in this scope + --> $DIR/outlives-with-missing.rs:10:9 + | +LL | impl<H: HandlerFamily> HandlerWrapper<H> { + | - similarly named type parameter `H` defined here +... +LL | T: Send + Sync + 'static, + | ^ help: a type parameter with a similar name exists: `H` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. |
