Skip to content

Commit de0e695

Browse files
committed
Check the substituted return type in return type suggestions.
Fixes #43420.
1 parent 6c11b47 commit de0e695

File tree

5 files changed

+205
-120
lines changed

5 files changed

+205
-120
lines changed

src/librustc_typeck/check/method/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pub enum MethodError<'tcx> {
5959
// Found a `Self: Sized` bound where `Self` is a trait object, also the caller may have
6060
// forgotten to import a trait.
6161
IllegalSizedBound(Vec<DefId>),
62+
63+
// Found a match, but the return type is wrong
64+
BadReturnType,
6265
}
6366

6467
// Contains a list of static methods that may apply, a list of unsatisfied trait predicates which
@@ -111,6 +114,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
111114
Err(Ambiguity(..)) => true,
112115
Err(PrivateMatch(..)) => allow_private,
113116
Err(IllegalSizedBound(..)) => true,
117+
Err(BadReturnType) => {
118+
bug!("no return type expectations but got BadReturnType")
119+
}
120+
114121
}
115122
}
116123

0 commit comments

Comments
 (0)