Fix an ICE on #96738
This commit is contained in:
parent
30f3860875
commit
436c0e129c
@ -367,8 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
if self.is_fn_ty(rcvr_ty, span) {
|
||||
if let SelfSource::MethodCall(expr) = source {
|
||||
let suggest = if let ty::FnDef(def_id, _) = rcvr_ty.kind() {
|
||||
let local_id = def_id.expect_local();
|
||||
let suggest = if let ty::FnDef(def_id, _) = rcvr_ty.kind() && let Some(local_id) = def_id.as_local() {
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(local_id);
|
||||
let node = tcx.hir().get(hir_id);
|
||||
let fields = node.tuple_fields();
|
||||
|
3
src/test/ui/typeck/issue-96738.rs
Normal file
3
src/test/ui/typeck/issue-96738.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
Some.nonexistent_method(); //~ ERROR: no method named `nonexistent_method` found
|
||||
}
|
11
src/test/ui/typeck/issue-96738.stderr
Normal file
11
src/test/ui/typeck/issue-96738.stderr
Normal file
@ -0,0 +1,11 @@
|
||||
error[E0599]: no method named `nonexistent_method` found for fn item `fn(_) -> Option<_> {Option::<_>::Some}` in the current scope
|
||||
--> $DIR/issue-96738.rs:2:10
|
||||
|
|
||||
LL | Some.nonexistent_method();
|
||||
| ---- ^^^^^^^^^^^^^^^^^^ method not found in `fn(_) -> Option<_> {Option::<_>::Some}`
|
||||
| |
|
||||
| this is a function, perhaps you wish to call it
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
Loading…
x
Reference in New Issue
Block a user