Skip to content

ty::Error does not match other types for region constraints #100688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion compiler/rustc_infer/src/infer/outlives/test_type_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/regions/outlives-with-missing.rs
Original file line number Diff line number Diff line change
@@ -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() {}
12 changes: 12 additions & 0 deletions src/test/ui/regions/outlives-with-missing.stderr
Original file line number Diff line number Diff line change
@@ -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`.