Emit additional arguments in future_prelude_collision
lint
This commit is contained in:
parent
17ab9c0ff9
commit
3efa5b4b83
3 changed files with 21 additions and 4 deletions
|
@ -941,7 +941,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// no need to check for bot/err -- callee does that
|
// no need to check for bot/err -- callee does that
|
||||||
let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t);
|
let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t);
|
||||||
|
|
||||||
let method = match self.lookup_method(rcvr_t, segment, span, expr, rcvr) {
|
let method = match self.lookup_method(rcvr_t, segment, span, expr, rcvr, args) {
|
||||||
Ok(method) => {
|
Ok(method) => {
|
||||||
// We could add a "consider `foo::<params>`" suggestion here, but I wasn't able to
|
// We could add a "consider `foo::<params>`" suggestion here, but I wasn't able to
|
||||||
// trigger this codepath causing `structuraly_resolved_type` to emit an error.
|
// trigger this codepath causing `structuraly_resolved_type` to emit an error.
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// Given a method call like `foo.bar::<T1,...Tn>(...)`:
|
/// Given a method call like `foo.bar::<T1,...Tn>(a, b + 1, ...)`:
|
||||||
///
|
///
|
||||||
/// * `self`: the surrounding `FnCtxt` (!)
|
/// * `self`: the surrounding `FnCtxt` (!)
|
||||||
/// * `self_ty`: the (unadjusted) type of the self expression (`foo`)
|
/// * `self_ty`: the (unadjusted) type of the self expression (`foo`)
|
||||||
|
@ -182,6 +182,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
/// * `span`: the span for the method call
|
/// * `span`: the span for the method call
|
||||||
/// * `call_expr`: the complete method call: (`foo.bar::<T1,...Tn>(...)`)
|
/// * `call_expr`: the complete method call: (`foo.bar::<T1,...Tn>(...)`)
|
||||||
/// * `self_expr`: the self expression (`foo`)
|
/// * `self_expr`: the self expression (`foo`)
|
||||||
|
/// * `args`: the expressions of the arguments (`a, b + 1, ...`)
|
||||||
#[instrument(level = "debug", skip(self, call_expr, self_expr))]
|
#[instrument(level = "debug", skip(self, call_expr, self_expr))]
|
||||||
pub fn lookup_method(
|
pub fn lookup_method(
|
||||||
&self,
|
&self,
|
||||||
|
@ -190,6 +191,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
span: Span,
|
span: Span,
|
||||||
call_expr: &'tcx hir::Expr<'tcx>,
|
call_expr: &'tcx hir::Expr<'tcx>,
|
||||||
self_expr: &'tcx hir::Expr<'tcx>,
|
self_expr: &'tcx hir::Expr<'tcx>,
|
||||||
|
args: &'tcx [hir::Expr<'tcx>],
|
||||||
) -> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
|
) -> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
|
||||||
debug!(
|
debug!(
|
||||||
"lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
|
"lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
|
||||||
|
@ -199,7 +201,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let pick =
|
let pick =
|
||||||
self.lookup_probe(span, segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope)?;
|
self.lookup_probe(span, segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope)?;
|
||||||
|
|
||||||
self.lint_dot_call_from_2018(self_ty, segment, span, call_expr, self_expr, &pick);
|
self.lint_dot_call_from_2018(self_ty, segment, span, call_expr, self_expr, &pick, args);
|
||||||
|
|
||||||
for import_id in &pick.import_ids {
|
for import_id in &pick.import_ids {
|
||||||
debug!("used_trait_import: {:?}", import_id);
|
debug!("used_trait_import: {:?}", import_id);
|
||||||
|
|
|
@ -20,6 +20,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
call_expr: &'tcx hir::Expr<'tcx>,
|
call_expr: &'tcx hir::Expr<'tcx>,
|
||||||
self_expr: &'tcx hir::Expr<'tcx>,
|
self_expr: &'tcx hir::Expr<'tcx>,
|
||||||
pick: &Pick<'tcx>,
|
pick: &Pick<'tcx>,
|
||||||
|
args: &'tcx [hir::Expr<'tcx>],
|
||||||
) {
|
) {
|
||||||
debug!(
|
debug!(
|
||||||
"lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
|
"lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
|
||||||
|
@ -75,10 +76,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
format!("{}{}{}", autoref, derefs, self_expr)
|
format!("{}{}{}", autoref, derefs, self_expr)
|
||||||
};
|
};
|
||||||
|
let args = args
|
||||||
|
.iter()
|
||||||
|
.skip(1)
|
||||||
|
.map(|arg| {
|
||||||
|
format!(
|
||||||
|
", {}",
|
||||||
|
self.sess().source_map().span_to_snippet(arg.span).unwrap()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<String>();
|
||||||
|
|
||||||
lint.span_suggestion(
|
lint.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"disambiguate the associated function",
|
"disambiguate the associated function",
|
||||||
format!("{}::{}({})", trait_name, segment.ident.name, self_adjusted,),
|
format!(
|
||||||
|
"{}::{}({}{})",
|
||||||
|
trait_name, segment.ident.name, self_adjusted, args
|
||||||
|
),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue