Skip to content

Commit f72e974

Browse files
authored
Rollup merge of #117655 - compiler-errors:method-tweaks, r=estebank
Method suggestion code tweaks I was rummaging around the method suggestion code after #117006 (comment) and saw a few things to simplify. This is two unrelated commits, both in the same file. Review them separately, if you'd like. r? estebank
2 parents 7552dd1 + 0add056 commit f72e974

12 files changed

+178
-198
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::errors::{
1313
YieldExprOutsideOfCoroutine,
1414
};
1515
use crate::fatally_break_rust;
16-
use crate::method::{MethodCallComponents, SelfSource};
16+
use crate::method::SelfSource;
1717
use crate::type_error_struct;
1818
use crate::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation};
1919
use crate::{
@@ -512,7 +512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
512512
) -> Ty<'tcx> {
513513
let tcx = self.tcx;
514514
let (res, opt_ty, segs) =
515-
self.resolve_ty_and_res_fully_qualified_call(qpath, expr.hir_id, expr.span);
515+
self.resolve_ty_and_res_fully_qualified_call(qpath, expr.hir_id, expr.span, Some(args));
516516
let ty = match res {
517517
Res::Err => {
518518
self.suggest_assoc_method_call(segs);
@@ -1332,7 +1332,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13321332
segment.ident,
13331333
SelfSource::MethodCall(rcvr),
13341334
error,
1335-
Some(MethodCallComponents { receiver: rcvr, args, full_expr: expr }),
1335+
Some(args),
13361336
expected,
13371337
false,
13381338
) {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
797797
qpath: &'tcx QPath<'tcx>,
798798
hir_id: hir::HirId,
799799
span: Span,
800+
args: Option<&'tcx [hir::Expr<'tcx>]>,
800801
) -> (Res, Option<RawTy<'tcx>>, &'tcx [hir::PathSegment<'tcx>]) {
801802
debug!(
802803
"resolve_ty_and_res_fully_qualified_call: qpath={:?} hir_id={:?} span={:?}",
@@ -898,7 +899,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
898899
item_name,
899900
SelfSource::QPath(qself),
900901
error,
901-
None,
902+
args,
902903
Expectation::NoExpectation,
903904
trait_missing_method && span.edition().at_least_rust_2021(), // emits missing method for trait only after edition 2021
904905
) {

compiler/rustc_hir_typeck/src/method/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod prelude2021;
77
pub mod probe;
88
mod suggest;
99

10-
pub use self::suggest::{MethodCallComponents, SelfSource};
10+
pub use self::suggest::SelfSource;
1111
pub use self::MethodError::*;
1212

1313
use crate::errors::OpMethodGenericParams;

0 commit comments

Comments
 (0)