Skip to content

Suggest calling method if fn does not exist #102694

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 3 commits into from
Oct 6, 2022
Merged
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
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
@@ -460,6 +460,7 @@ pub enum StashKey {
ItemNoType,
UnderscoreForArrayLengths,
EarlySyntaxWarning,
CallIntoMethod,
}

fn default_track_diagnostic(_: &Diagnostic) {}
142 changes: 136 additions & 6 deletions compiler/rustc_hir_analysis/src/check/callee.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use super::method::probe::{IsSuggestion, Mode, ProbeScope};
use super::method::MethodCallee;
use super::{DefIdOrName, Expectation, FnCtxt, TupleArgumentsFlag};
use crate::type_error_struct;

use rustc_errors::{struct_span_err, Applicability, Diagnostic};
use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, StashKey};
use rustc_hir as hir;
use rustc_hir::def::{self, Namespace, Res};
use rustc_hir::def_id::DefId;
@@ -60,6 +62,7 @@ pub fn check_legal_trait_for_method_call(
}
}

#[derive(Debug)]
enum CallStep<'tcx> {
Builtin(Ty<'tcx>),
DeferredClosure(LocalDefId, ty::FnSig<'tcx>),
@@ -188,6 +191,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return None;
}

ty::Error(_) => {
return None;
}

_ => {}
}

@@ -394,6 +401,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
ty::FnPtr(sig) => (sig, None),
_ => {
if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &callee_expr.kind
&& let [segment] = path.segments
&& let Some(mut diag) = self
.tcx
.sess
.diagnostic()
.steal_diagnostic(segment.ident.span, StashKey::CallIntoMethod)
{
// Try suggesting `foo(a)` -> `a.foo()` if possible.
if let Some(ty) =
self.suggest_call_as_method(
&mut diag,
segment,
arg_exprs,
call_expr,
expected
)
{
diag.emit();
return ty;
} else {
diag.emit();
}
}

self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);

// This is the "default" function signature, used in case of error.
@@ -441,6 +473,105 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn_sig.output()
}

/// Attempts to reinterpret `method(rcvr, args...)` as `rcvr.method(args...)`
/// and suggesting the fix if the method probe is successful.
fn suggest_call_as_method(
&self,
diag: &mut Diagnostic,
segment: &'tcx hir::PathSegment<'tcx>,
arg_exprs: &'tcx [hir::Expr<'tcx>],
call_expr: &'tcx hir::Expr<'tcx>,
expected: Expectation<'tcx>,
) -> Option<Ty<'tcx>> {
if let [callee_expr, rest @ ..] = arg_exprs {
let callee_ty = self.check_expr(callee_expr);
// First, do a probe with `IsSuggestion(true)` to avoid emitting
// any strange errors. If it's successful, then we'll do a true
// method lookup.
let Ok(pick) = self
.probe_for_name(
call_expr.span,
Mode::MethodCall,
segment.ident,
IsSuggestion(true),
callee_ty,
call_expr.hir_id,
// We didn't record the in scope traits during late resolution
// so we need to probe AllTraits unfortunately
ProbeScope::AllTraits,
) else {
return None;
};

let pick = self.confirm_method(
call_expr.span,
callee_expr,
call_expr,
callee_ty,
pick,
segment,
);
if pick.illegal_sized_bound.is_some() {
return None;
}

let up_to_rcvr_span = segment.ident.span.until(callee_expr.span);
let rest_span = callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
let rest_snippet = if let Some(first) = rest.first() {
self.tcx
.sess
.source_map()
.span_to_snippet(first.span.to(call_expr.span.shrink_to_hi()))
} else {
Ok(")".to_string())
};

if let Ok(rest_snippet) = rest_snippet {
let sugg = if callee_expr.precedence().order() >= PREC_POSTFIX {
vec![
(up_to_rcvr_span, "".to_string()),
(rest_span, format!(".{}({rest_snippet}", segment.ident)),
]
} else {
vec![
(up_to_rcvr_span, "(".to_string()),
(rest_span, format!(").{}({rest_snippet}", segment.ident)),
]
};
let self_ty = self.resolve_vars_if_possible(pick.callee.sig.inputs()[0]);
diag.multipart_suggestion(
format!(
"use the `.` operator to call the method `{}{}` on `{self_ty}`",
self.tcx
.associated_item(pick.callee.def_id)
.trait_container(self.tcx)
.map_or_else(
|| String::new(),
|trait_def_id| self.tcx.def_path_str(trait_def_id) + "::"
),
segment.ident
),
sugg,
Applicability::MaybeIncorrect,
);

// Let's check the method fully now
let return_ty = self.check_method_argument_types(
segment.ident.span,
call_expr,
Ok(pick.callee),
rest,
TupleArgumentsFlag::DontTupleArguments,
expected,
);

return Some(return_ty);
}
}

None
}

fn report_invalid_callee(
&self,
call_expr: &'tcx hir::Expr<'tcx>,
@@ -459,10 +590,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
def::CtorOf::Struct => "struct",
def::CtorOf::Variant => "enum variant",
};
let removal_span =
callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
unit_variant =
Some((removal_span, descr, rustc_hir_pretty::qpath_to_string(qpath)));
let removal_span = callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
unit_variant = Some((removal_span, descr, rustc_hir_pretty::qpath_to_string(qpath)));
}

let callee_ty = self.resolve_vars_if_possible(callee_ty);
@@ -525,7 +654,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};

if !self.maybe_suggest_bad_array_definition(&mut err, call_expr, callee_expr) {
if let Some((maybe_def, output_ty, _)) = self.extract_callable_info(callee_expr, callee_ty)
if let Some((maybe_def, output_ty, _)) =
self.extract_callable_info(callee_expr, callee_ty)
&& !self.type_is_sized_modulo_regions(self.param_env, output_ty, callee_expr.span)
{
let descr = match maybe_def {
10 changes: 8 additions & 2 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -120,14 +120,15 @@ impl<'a> Resolver<'a> {
}

fn report_with_use_injections(&mut self, krate: &Crate) {
for UseError { mut err, candidates, def_id, instead, suggestion, path } in
for UseError { mut err, candidates, def_id, instead, suggestion, path, is_call } in
self.use_injections.drain(..)
{
let (span, found_use) = if let Some(def_id) = def_id.as_local() {
UsePlacementFinder::check(krate, self.def_id_to_node_id[def_id])
} else {
(None, FoundUse::No)
};

if !candidates.is_empty() {
show_candidates(
&self.session,
@@ -140,10 +141,15 @@ impl<'a> Resolver<'a> {
IsPattern::No,
path,
);
err.emit();
} else if let Some((span, msg, sugg, appl)) = suggestion {
err.span_suggestion(span, msg, sugg, appl);
err.emit();
} else if let [segment] = path.as_slice() && is_call {
err.stash(segment.ident.span, rustc_errors::StashKey::CallIntoMethod);
} else {
err.emit();
}
err.emit();
}
}

2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
@@ -3263,6 +3263,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
instead,
suggestion,
path: path.into(),
is_call: source.is_call(),
});
}

@@ -3327,6 +3328,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
instead: false,
suggestion: None,
path: path.into(),
is_call: source.is_call(),
});
} else {
err.cancel();
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
@@ -674,6 +674,8 @@ struct UseError<'a> {
/// Path `Segment`s at the place of use that failed. Used for accurate suggestion after telling
/// the user to import the item directly.
path: Vec<Segment>,
/// Whether the expected source is a call
is_call: bool,
}

#[derive(Clone, Copy, PartialEq, Debug)]
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
error[E0423]: expected function, tuple struct or tuple variant, found enum `Option`
--> $DIR/issue-43871-enum-instead-of-variant.rs:19:13
|
LL | let x = Option(1);
| ^^^^^^ help: try to construct one of the enum's variants: `std::option::Option::Some`
|
= help: you might have meant to construct the enum's non-tuple variant

error[E0532]: expected tuple struct or tuple variant, found enum `Option`
--> $DIR/issue-43871-enum-instead-of-variant.rs:21:12
|
@@ -27,6 +19,14 @@ note: the enum is defined here
LL | enum Example { Ex(String), NotEx }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0423]: expected function, tuple struct or tuple variant, found enum `Option`
--> $DIR/issue-43871-enum-instead-of-variant.rs:19:13
|
LL | let x = Option(1);
| ^^^^^^ help: try to construct one of the enum's variants: `std::option::Option::Some`
|
= help: you might have meant to construct the enum's non-tuple variant

error[E0423]: expected function, tuple struct or tuple variant, found enum `Void`
--> $DIR/issue-43871-enum-instead-of-variant.rs:31:13
|
46 changes: 23 additions & 23 deletions src/test/ui/empty/empty-struct-braces-expr.stderr
Original file line number Diff line number Diff line change
@@ -21,29 +21,6 @@ help: a unit struct with a similar name exists
LL | let e1 = XEmpty2;
| ~~~~~~~

error[E0423]: expected function, tuple struct or tuple variant, found struct `Empty1`
--> $DIR/empty-struct-braces-expr.rs:16:14
|
LL | struct Empty1 {}
| ---------------- `Empty1` defined here
...
LL | let e1 = Empty1();
| ^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:2:1
|
LL | pub struct XEmpty2;
| ------------------ similarly named unit struct `XEmpty2` defined here
|
help: use struct literal syntax instead
|
LL | let e1 = Empty1 {};
| ~~~~~~~~~
help: a unit struct with a similar name exists
|
LL | let e1 = XEmpty2();
| ~~~~~~~

error[E0423]: expected value, found struct variant `E::Empty3`
--> $DIR/empty-struct-braces-expr.rs:18:14
|
@@ -84,6 +61,29 @@ help: a unit struct with a similar name exists
LL | let xe1 = XEmpty2;
| ~~~~~~~

error[E0423]: expected function, tuple struct or tuple variant, found struct `Empty1`
--> $DIR/empty-struct-braces-expr.rs:16:14
|
LL | struct Empty1 {}
| ---------------- `Empty1` defined here
...
LL | let e1 = Empty1();
| ^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:2:1
|
LL | pub struct XEmpty2;
| ------------------ similarly named unit struct `XEmpty2` defined here
|
help: use struct literal syntax instead
|
LL | let e1 = Empty1 {};
| ~~~~~~~~~
help: a unit struct with a similar name exists
|
LL | let e1 = XEmpty2();
| ~~~~~~~

error[E0423]: expected function, tuple struct or tuple variant, found struct `XEmpty1`
--> $DIR/empty-struct-braces-expr.rs:23:15
|
22 changes: 11 additions & 11 deletions src/test/ui/error-codes/E0423.stderr
Original file line number Diff line number Diff line change
@@ -26,6 +26,17 @@ help: surround the struct literal with parentheses
LL | for _ in (std::ops::Range { start: 0, end: 10 }) {}
| + +

error[E0423]: expected value, found struct `T`
--> $DIR/E0423.rs:14:8
|
LL | if T {} == T {} { println!("Ok"); }
| ^ not a value
|
help: surround the struct literal with parentheses
|
LL | if (T {}) == T {} { println!("Ok"); }
| + +

error[E0423]: expected function, tuple struct or tuple variant, found struct `Foo`
--> $DIR/E0423.rs:4:13
|
@@ -47,17 +58,6 @@ help: a function with a similar name exists
LL | let f = foo();
| ~~~

error[E0423]: expected value, found struct `T`
--> $DIR/E0423.rs:14:8
|
LL | if T {} == T {} { println!("Ok"); }
| ^ not a value
|
help: surround the struct literal with parentheses
|
LL | if (T {}) == T {} { println!("Ok"); }
| + +

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0423`.
12 changes: 6 additions & 6 deletions src/test/ui/issues/issue-58022.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo`
--> $DIR/issue-58022.rs:14:9
|
LL | Foo(Box::new(*slice))
| ^^^ not a function, tuple struct or tuple variant

error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type
--> $DIR/issue-58022.rs:4:25
|
@@ -13,6 +7,12 @@ LL |
LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
| ^^^^^^^^^ cannot refer to the associated constant of trait

error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo`
--> $DIR/issue-58022.rs:14:9
|
LL | Foo(Box::new(*slice))
| ^^^ not a function, tuple struct or tuple variant

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0423, E0790.
12 changes: 6 additions & 6 deletions src/test/ui/lang-items/issue-83471.stderr
Original file line number Diff line number Diff line change
@@ -4,12 +4,6 @@ error[E0573]: expected type, found built-in attribute `export_name`
LL | fn call(export_name);
| ^^^^^^^^^^^ not a type

error[E0425]: cannot find function `a` in this scope
--> $DIR/issue-83471.rs:21:5
|
LL | a()
| ^ not found in this scope

error[E0658]: language items are subject to change
--> $DIR/issue-83471.rs:7:1
|
@@ -45,6 +39,12 @@ LL | #[lang = "fn"]
LL | trait Fn {
| - this trait has 0 generic arguments

error[E0425]: cannot find function `a` in this scope
--> $DIR/issue-83471.rs:21:5
|
LL | a()
| ^ not found in this scope

error: aborting due to 5 previous errors; 1 warning emitted

Some errors have detailed explanations: E0425, E0573, E0658, E0718.
44 changes: 22 additions & 22 deletions src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr
Original file line number Diff line number Diff line change
@@ -319,22 +319,39 @@ LL | unknown_metavar!(a);
|
= note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `count` in this scope
--> $DIR/syntax-errors.rs:29:30
error[E0425]: cannot find value `i` in this scope
--> $DIR/syntax-errors.rs:29:36
|
LL | ( $( $i:ident ),* ) => { count(i) };
| ^^^^^ not found in this scope
| ^ not found in this scope
...
LL | no_curly__no_rhs_dollar__round!(a, b, c);
| ---------------------------------------- in this macro invocation
|
= note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `i` in this scope
--> $DIR/syntax-errors.rs:29:36
--> $DIR/syntax-errors.rs:35:29
|
LL | ( $i:ident ) => { count(i) };
| ^ not found in this scope
...
LL | no_curly__no_rhs_dollar__no_round!(a);
| ------------------------------------- in this macro invocation
|
= note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `a` in this scope
--> $DIR/syntax-errors.rs:153:37
|
LL | no_curly__rhs_dollar__no_round!(a);
| ^ not found in this scope

error[E0425]: cannot find function `count` in this scope
--> $DIR/syntax-errors.rs:29:30
|
LL | ( $( $i:ident ),* ) => { count(i) };
| ^ not found in this scope
| ^^^^^ not found in this scope
...
LL | no_curly__no_rhs_dollar__round!(a, b, c);
| ---------------------------------------- in this macro invocation
@@ -352,17 +369,6 @@ LL | no_curly__no_rhs_dollar__no_round!(a);
|
= note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `i` in this scope
--> $DIR/syntax-errors.rs:35:29
|
LL | ( $i:ident ) => { count(i) };
| ^ not found in this scope
...
LL | no_curly__no_rhs_dollar__no_round!(a);
| ------------------------------------- in this macro invocation
|
= note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `count` in this scope
--> $DIR/syntax-errors.rs:46:23
|
@@ -374,12 +380,6 @@ LL | no_curly__rhs_dollar__no_round!(a);
|
= note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `a` in this scope
--> $DIR/syntax-errors.rs:153:37
|
LL | no_curly__rhs_dollar__no_round!(a);
| ^ not found in this scope

error: aborting due to 40 previous errors

For more information about this error, try `rustc --explain E0425`.
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
error[E0425]: cannot find function `foo` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:11:5
|
LL | foo();
| ^^^ not found in this scope

error[E0425]: cannot find function `foo` in module `m`
--> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:12:8
|
LL | m::foo();
| ^^^ not found in `m`

error[E0425]: cannot find function `bar` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:13:5
|
LL | bar();
| ^^^ not found in this scope

error[E0425]: cannot find function `bar` in module `m`
--> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:14:8
|
LL | m::bar();
| ^^^ not found in `m`

error[E0425]: cannot find function `foo` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:11:5
|
LL | foo();
| ^^^ not found in this scope

error[E0425]: cannot find function `bar` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:13:5
|
LL | bar();
| ^^^ not found in this scope

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0425`.
24 changes: 12 additions & 12 deletions src/test/ui/namespace/namespaced-enum-glob-import-no-impls.stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
error[E0425]: cannot find function `foo` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls.rs:21:5
|
LL | foo();
| ^^^ not found in this scope

error[E0425]: cannot find function `foo` in module `m`
--> $DIR/namespaced-enum-glob-import-no-impls.rs:22:8
|
LL | m::foo();
| ^^^ not found in `m`

error[E0425]: cannot find function `bar` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls.rs:23:5
|
LL | bar();
| ^^^ not found in this scope

error[E0425]: cannot find function `bar` in module `m`
--> $DIR/namespaced-enum-glob-import-no-impls.rs:24:8
|
LL | m::bar();
| ^^^ not found in `m`

error[E0425]: cannot find function `foo` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls.rs:21:5
|
LL | foo();
| ^^^ not found in this scope

error[E0425]: cannot find function `bar` in this scope
--> $DIR/namespaced-enum-glob-import-no-impls.rs:23:5
|
LL | bar();
| ^^^ not found in this scope

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0425`.
18 changes: 9 additions & 9 deletions src/test/ui/parser/emoji-identifiers.stderr
Original file line number Diff line number Diff line change
@@ -9,15 +9,6 @@ help: Unicode character '➖' (Heavy Minus Sign) looks like '-' (Minus/Hyphen),
LL | let _ = i_like_to_😄_a_lot() - 4;
| ~

error[E0425]: cannot find function `i_like_to_😄_a_lot` in this scope
--> $DIR/emoji-identifiers.rs:13:13
|
LL | fn i_like_to_😅_a_lot() -> 👀 {
| ----------------------------- similarly named function `i_like_to_😅_a_lot` defined here
...
LL | let _ = i_like_to_😄_a_lot() ➖ 4;
| ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `i_like_to_😅_a_lot`

error: Ferris cannot be used as an identifier
--> $DIR/emoji-identifiers.rs:17:9
|
@@ -85,6 +76,15 @@ LL | 👀::full_of✨()
| function or associated item not found in `👀`
| help: there is an associated function with a similar name: `full_of_✨`

error[E0425]: cannot find function `i_like_to_😄_a_lot` in this scope
--> $DIR/emoji-identifiers.rs:13:13
|
LL | fn i_like_to_😅_a_lot() -> 👀 {
| ----------------------------- similarly named function `i_like_to_😅_a_lot` defined here
...
LL | let _ = i_like_to_😄_a_lot() ➖ 4;
| ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `i_like_to_😅_a_lot`

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0425, E0599.
12 changes: 6 additions & 6 deletions src/test/ui/parser/parser-recovery-1.stderr
Original file line number Diff line number Diff line change
@@ -18,18 +18,18 @@ error: unexpected token: `;`
LL | let x = y.;
| ^

error[E0425]: cannot find function `foo` in this scope
--> $DIR/parser-recovery-1.rs:5:17
|
LL | let x = foo();
| ^^^ not found in this scope

error[E0425]: cannot find value `y` in this scope
--> $DIR/parser-recovery-1.rs:10:13
|
LL | let x = y.;
| ^ not found in this scope

error[E0425]: cannot find function `foo` in this scope
--> $DIR/parser-recovery-1.rs:5:17
|
LL | let x = foo();
| ^^^ not found in this scope

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0425`.
12 changes: 6 additions & 6 deletions src/test/ui/parser/parser-recovery-2.stderr
Original file line number Diff line number Diff line change
@@ -13,18 +13,18 @@ LL | let x = foo();
LL | )
| ^ mismatched closing delimiter

error[E0425]: cannot find function `foo` in this scope
--> $DIR/parser-recovery-2.rs:5:17
|
LL | let x = foo();
| ^^^ not found in this scope

error[E0425]: cannot find value `y` in this scope
--> $DIR/parser-recovery-2.rs:10:13
|
LL | let x = y.;
| ^ not found in this scope

error[E0425]: cannot find function `foo` in this scope
--> $DIR/parser-recovery-2.rs:5:17
|
LL | let x = foo();
| ^^^ not found in this scope

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0425`.
12 changes: 6 additions & 6 deletions src/test/ui/parser/unmatched-langle-1.stderr
Original file line number Diff line number Diff line change
@@ -4,18 +4,18 @@ error: unmatched angle brackets
LL | foo::<<<<Ty<i32>>();
| ^^^ help: remove extra angle brackets

error[E0425]: cannot find function `foo` in this scope
--> $DIR/unmatched-langle-1.rs:5:5
|
LL | foo::<<<<Ty<i32>>();
| ^^^ not found in this scope

error[E0412]: cannot find type `Ty` in this scope
--> $DIR/unmatched-langle-1.rs:5:14
|
LL | foo::<<<<Ty<i32>>();
| ^^ not found in this scope

error[E0425]: cannot find function `foo` in this scope
--> $DIR/unmatched-langle-1.rs:5:5
|
LL | foo::<<<<Ty<i32>>();
| ^^^ not found in this scope

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0412, E0425.
12 changes: 6 additions & 6 deletions src/test/ui/proc-macro/keep-expr-tokens.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
error[E0425]: cannot find function `missing_fn` in this scope
--> $DIR/keep-expr-tokens.rs:17:17
|
LL | for item in missing_fn() {}
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `bad` in this scope
--> $DIR/keep-expr-tokens.rs:19:62
|
LL | (#[recollect_attr] #[recollect_attr] ((#[recollect_attr] bad)));
| ^^^ not found in this scope

error[E0425]: cannot find function `missing_fn` in this scope
--> $DIR/keep-expr-tokens.rs:17:17
|
LL | for item in missing_fn() {}
| ^^^^^^^^^^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.
12 changes: 6 additions & 6 deletions src/test/ui/resolve/bad-env-capture.stderr
Original file line number Diff line number Diff line change
@@ -6,18 +6,18 @@ LL | fn bar() { log(debug, x); }
|
= help: use the `|| { ... }` closure form instead

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-env-capture.rs:4:16
|
LL | fn bar() { log(debug, x); }
| ^^^ not found in this scope

error[E0425]: cannot find value `debug` in this scope
--> $DIR/bad-env-capture.rs:4:20
|
LL | fn bar() { log(debug, x); }
| ^^^^^ not found in this scope

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-env-capture.rs:4:16
|
LL | fn bar() { log(debug, x); }
| ^^^ not found in this scope

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0425, E0434.
12 changes: 6 additions & 6 deletions src/test/ui/resolve/bad-env-capture2.stderr
Original file line number Diff line number Diff line change
@@ -6,18 +6,18 @@ LL | fn bar() { log(debug, x); }
|
= help: use the `|| { ... }` closure form instead

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-env-capture2.rs:3:16
|
LL | fn bar() { log(debug, x); }
| ^^^ not found in this scope

error[E0425]: cannot find value `debug` in this scope
--> $DIR/bad-env-capture2.rs:3:20
|
LL | fn bar() { log(debug, x); }
| ^^^^^ not found in this scope

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-env-capture2.rs:3:16
|
LL | fn bar() { log(debug, x); }
| ^^^ not found in this scope

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0425, E0434.
12 changes: 6 additions & 6 deletions src/test/ui/resolve/bad-env-capture3.stderr
Original file line number Diff line number Diff line change
@@ -6,18 +6,18 @@ LL | fn bar() { log(debug, x); }
|
= help: use the `|| { ... }` closure form instead

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-env-capture3.rs:4:20
|
LL | fn bar() { log(debug, x); }
| ^^^ not found in this scope

error[E0425]: cannot find value `debug` in this scope
--> $DIR/bad-env-capture3.rs:4:24
|
LL | fn bar() { log(debug, x); }
| ^^^^^ not found in this scope

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-env-capture3.rs:4:20
|
LL | fn bar() { log(debug, x); }
| ^^^ not found in this scope

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0425, E0434.
12 changes: 6 additions & 6 deletions src/test/ui/resolve/bad-expr-path.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-expr-path.rs:4:5
|
LL | log(debug, m1::arguments);
| ^^^ not found in this scope

error[E0425]: cannot find value `debug` in this scope
--> $DIR/bad-expr-path.rs:4:9
|
@@ -16,6 +10,12 @@ error[E0425]: cannot find value `arguments` in module `m1`
LL | log(debug, m1::arguments);
| ^^^^^^^^^ not found in `m1`

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-expr-path.rs:4:5
|
LL | log(debug, m1::arguments);
| ^^^ not found in this scope

error[E0580]: `main` function has wrong type
--> $DIR/bad-expr-path.rs:3:1
|
12 changes: 6 additions & 6 deletions src/test/ui/resolve/bad-expr-path2.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-expr-path2.rs:6:5
|
LL | log(debug, m1::arguments);
| ^^^ not found in this scope

error[E0425]: cannot find value `debug` in this scope
--> $DIR/bad-expr-path2.rs:6:9
|
@@ -16,6 +10,12 @@ error[E0423]: expected value, found module `m1::arguments`
LL | log(debug, m1::arguments);
| ^^^^^^^^^^^^^ not a value

error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-expr-path2.rs:6:5
|
LL | log(debug, m1::arguments);
| ^^^ not found in this scope

error[E0580]: `main` function has wrong type
--> $DIR/bad-expr-path2.rs:5:1
|
86 changes: 43 additions & 43 deletions src/test/ui/resolve/issue-14254.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:19:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find value `a` in this scope
--> $DIR/issue-14254.rs:21:9
|
LL | a;
| ^ not found in this scope

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:28:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-14254.rs:30:9
|
@@ -46,12 +34,6 @@ error[E0425]: cannot find value `b` in this scope
LL | b;
| ^ not found in this scope

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:45:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-14254.rs:47:9
|
@@ -82,65 +64,83 @@ error[E0425]: cannot find value `b` in this scope
LL | b;
| ^ not found in this scope

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:62:9
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:64:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`

error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:64:9
--> $DIR/issue-14254.rs:73:9
|
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:71:9
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:82:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`

error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:73:9
--> $DIR/issue-14254.rs:91:9
|
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`

error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:100:9
|
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:80:9
--> $DIR/issue-14254.rs:19:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:82:9
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:28:9
|
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:89:9
--> $DIR/issue-14254.rs:45:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:91:9
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:62:9
|
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:98:9
--> $DIR/issue-14254.rs:71:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:100:9
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:80:9
|
LL | bah;
| ^^^ help: you might have meant to call the associated function: `Self::bah`
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:89:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:98:9
|
LL | baz();
| ^^^ help: you might have meant to call the method: `self.baz`

error: aborting due to 24 previous errors

90 changes: 45 additions & 45 deletions src/test/ui/resolve/issue-2356.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
error[E0425]: cannot find function `shave` in this scope
--> $DIR/issue-2356.rs:17:5
|
LL | shave();
| ^^^^^ not found in this scope

error[E0425]: cannot find function `clone` in this scope
--> $DIR/issue-2356.rs:24:5
|
LL | clone();
| ^^^^^ help: you might have meant to call the method: `self.clone`

error[E0425]: cannot find function `default` in this scope
--> $DIR/issue-2356.rs:31:5
|
@@ -31,6 +19,51 @@ error[E0425]: cannot find value `whiskers` in this scope
LL | whiskers -= other;
| ^^^^^^^^ a field by this name exists in `Self`

error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:65:8
|
LL | fn meow() {
| ---- this function doesn't have a `self` parameter
LL | if self.whiskers > 3 {
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
LL | fn meow(&self) {
| +++++

error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:79:5
|
LL | whiskers = 0;
| ^^^^^^^^ help: you might have meant to use the available field: `self.whiskers`

error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:84:5
|
LL | whiskers = 4;
| ^^^^^^^^ a field by this name exists in `Self`

error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:92:5
|
LL | fn main() {
| ---- this function can't have a `self` parameter
LL | self += 1;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter

error[E0425]: cannot find function `shave` in this scope
--> $DIR/issue-2356.rs:17:5
|
LL | shave();
| ^^^^^ not found in this scope

error[E0425]: cannot find function `clone` in this scope
--> $DIR/issue-2356.rs:24:5
|
LL | clone();
| ^^^^^ help: you might have meant to call the method: `self.clone`

error[E0425]: cannot find function `shave` in this scope
--> $DIR/issue-2356.rs:41:5
|
@@ -72,19 +105,6 @@ error[E0425]: cannot find function `purr` in this scope
LL | purr();
| ^^^^ not found in this scope

error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:65:8
|
LL | fn meow() {
| ---- this function doesn't have a `self` parameter
LL | if self.whiskers > 3 {
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
LL | fn meow(&self) {
| +++++

error[E0425]: cannot find function `grow_older` in this scope
--> $DIR/issue-2356.rs:72:5
|
@@ -102,32 +122,12 @@ error[E0425]: cannot find function `shave` in this scope
LL | shave();
| ^^^^^ not found in this scope

error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:79:5
|
LL | whiskers = 0;
| ^^^^^^^^ help: you might have meant to use the available field: `self.whiskers`

error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:84:5
|
LL | whiskers = 4;
| ^^^^^^^^ a field by this name exists in `Self`

error[E0425]: cannot find function `purr_louder` in this scope
--> $DIR/issue-2356.rs:86:5
|
LL | purr_louder();
| ^^^^^^^^^^^ not found in this scope

error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:92:5
|
LL | fn main() {
| ---- this function can't have a `self` parameter
LL | self += 1;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter

error: aborting due to 17 previous errors

Some errors have detailed explanations: E0424, E0425.
24 changes: 12 additions & 12 deletions src/test/ui/resolve/issue-42944.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
error[E0423]: cannot initialize a tuple struct which contains private fields
--> $DIR/issue-42944.rs:9:9
|
LL | Bx(());
| ^^
|
note: constructor is not visible here due to private fields
--> $DIR/issue-42944.rs:2:19
|
LL | pub struct Bx(());
| ^^ private field

error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this scope
--> $DIR/issue-42944.rs:16:9
|
@@ -22,6 +10,18 @@ note: tuple struct `foo::Bx` exists but is inaccessible
LL | pub struct Bx(());
| ^^^^^^^^^^^^^^^^^^ not accessible

error[E0423]: cannot initialize a tuple struct which contains private fields
--> $DIR/issue-42944.rs:9:9
|
LL | Bx(());
| ^^
|
note: constructor is not visible here due to private fields
--> $DIR/issue-42944.rs:2:19
|
LL | pub struct Bx(());
| ^^ private field

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0423, E0425.
40 changes: 20 additions & 20 deletions src/test/ui/resolve/issue-73427.stderr
Original file line number Diff line number Diff line change
@@ -124,13 +124,13 @@ LL | use std::f32::consts::E;
LL | use std::f64::consts::E;
|

error[E0423]: expected function, tuple struct or tuple variant, found enum `A`
--> $DIR/issue-73427.rs:46:13
error[E0532]: expected tuple struct or tuple variant, found enum `A`
--> $DIR/issue-73427.rs:48:12
|
LL | let x = A(3);
| ^
LL | if let A(3) = x { }
| ^
|
= help: you might have meant to construct one of the enum's non-tuple variants
= help: you might have meant to match against one of the enum's non-tuple variants
note: the enum is defined here
--> $DIR/issue-73427.rs:1:1
|
@@ -142,20 +142,20 @@ LL | | Tuple(),
LL | | Unit,
LL | | }
| |_^
help: try to construct one of the enum's variants
help: try to match against one of the enum's variants
|
LL | let x = A::Tuple(3);
| ~~~~~~~~
LL | let x = A::TupleWithFields(3);
| ~~~~~~~~~~~~~~~~~~
LL | if let A::Tuple(3) = x { }
| ~~~~~~~~
LL | if let A::TupleWithFields(3) = x { }
| ~~~~~~~~~~~~~~~~~~

error[E0532]: expected tuple struct or tuple variant, found enum `A`
--> $DIR/issue-73427.rs:48:12
error[E0423]: expected function, tuple struct or tuple variant, found enum `A`
--> $DIR/issue-73427.rs:46:13
|
LL | if let A(3) = x { }
| ^
LL | let x = A(3);
| ^
|
= help: you might have meant to match against one of the enum's non-tuple variants
= help: you might have meant to construct one of the enum's non-tuple variants
note: the enum is defined here
--> $DIR/issue-73427.rs:1:1
|
@@ -167,12 +167,12 @@ LL | | Tuple(),
LL | | Unit,
LL | | }
| |_^
help: try to match against one of the enum's variants
help: try to construct one of the enum's variants
|
LL | if let A::Tuple(3) = x { }
| ~~~~~~~~
LL | if let A::TupleWithFields(3) = x { }
| ~~~~~~~~~~~~~~~~~~
LL | let x = A::Tuple(3);
| ~~~~~~~~
LL | let x = A::TupleWithFields(3);
| ~~~~~~~~~~~~~~~~~~

error: aborting due to 7 previous errors

18 changes: 9 additions & 9 deletions src/test/ui/resolve/levenshtein.stderr
Original file line number Diff line number Diff line change
@@ -39,15 +39,6 @@ LL | const MAX_ITEM: usize = 10;
LL | let v = [0u32; MAXITEM]; // Misspelled constant name.
| ^^^^^^^ help: a constant with a similar name exists: `MAX_ITEM`

error[E0425]: cannot find function `foobar` in this scope
--> $DIR/levenshtein.rs:26:5
|
LL | fn foo_bar() {}
| ------------ similarly named function `foo_bar` defined here
...
LL | foobar(); // Misspelled function name.
| ^^^^^^ help: a function with a similar name exists: `foo_bar`

error[E0412]: cannot find type `first` in module `m`
--> $DIR/levenshtein.rs:28:15
|
@@ -66,6 +57,15 @@ LL | pub struct Second;
LL | let b: m::first = m::second; // Misspelled item in module.
| ^^^^^^ help: a unit struct with a similar name exists (notice the capitalization): `Second`

error[E0425]: cannot find function `foobar` in this scope
--> $DIR/levenshtein.rs:26:5
|
LL | fn foo_bar() {}
| ------------ similarly named function `foo_bar` defined here
...
LL | foobar(); // Misspelled function name.
| ^^^^^^ help: a function with a similar name exists: `foo_bar`

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0412, E0425.
22 changes: 11 additions & 11 deletions src/test/ui/resolve/resolve-hint-macro.stderr
Original file line number Diff line number Diff line change
@@ -14,17 +14,6 @@ LL | assert_eq { 1, 1 };
| |
| while parsing this struct

error[E0423]: expected function, found macro `assert_eq`
--> $DIR/resolve-hint-macro.rs:3:5
|
LL | assert_eq(1, 1);
| ^^^^^^^^^ not a function
|
help: use `!` to invoke the macro
|
LL | assert_eq!(1, 1);
| +

error[E0574]: expected struct, variant or union type, found macro `assert_eq`
--> $DIR/resolve-hint-macro.rs:5:5
|
@@ -47,6 +36,17 @@ help: use `!` to invoke the macro
LL | assert![true];
| +

error[E0423]: expected function, found macro `assert_eq`
--> $DIR/resolve-hint-macro.rs:3:5
|
LL | assert_eq(1, 1);
| ^^^^^^^^^ not a function
|
help: use `!` to invoke the macro
|
LL | assert_eq!(1, 1);
| +

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0423, E0574.
12 changes: 6 additions & 6 deletions src/test/ui/resolve/resolve-speculative-adjustment.stderr
Original file line number Diff line number Diff line change
@@ -4,12 +4,6 @@ error[E0425]: cannot find value `field` in this scope
LL | field;
| ^^^^^ not found in this scope

error[E0425]: cannot find function `method` in this scope
--> $DIR/resolve-speculative-adjustment.rs:19:13
|
LL | method();
| ^^^^^^ not found in this scope

error[E0425]: cannot find value `field` in this scope
--> $DIR/resolve-speculative-adjustment.rs:23:9
|
@@ -22,6 +16,12 @@ error[E0425]: cannot find function `method` in this scope
LL | method();
| ^^^^^^ help: you might have meant to call the method: `self.method`

error[E0425]: cannot find function `method` in this scope
--> $DIR/resolve-speculative-adjustment.rs:19:13
|
LL | method();
| ^^^^^^ not found in this scope

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0425`.
16 changes: 8 additions & 8 deletions src/test/ui/resolve/tuple-struct-alias.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
error[E0423]: expected function, tuple struct or tuple variant, found type alias `A`
--> $DIR/tuple-struct-alias.rs:5:13
error[E0532]: expected tuple struct or tuple variant, found type alias `A`
--> $DIR/tuple-struct-alias.rs:7:9
|
LL | struct S(u8, u16);
| ------------------ similarly named tuple struct `S` defined here
...
LL | let s = A(0, 1);
| ^ help: a tuple struct with a similar name exists: `S`
LL | A(..) => {}
| ^ help: a tuple struct with a similar name exists: `S`
|
= note: can't use a type alias as a constructor

error[E0532]: expected tuple struct or tuple variant, found type alias `A`
--> $DIR/tuple-struct-alias.rs:7:9
error[E0423]: expected function, tuple struct or tuple variant, found type alias `A`
--> $DIR/tuple-struct-alias.rs:5:13
|
LL | struct S(u8, u16);
| ------------------ similarly named tuple struct `S` defined here
...
LL | A(..) => {}
| ^ help: a tuple struct with a similar name exists: `S`
LL | let s = A(0, 1);
| ^ help: a tuple struct with a similar name exists: `S`
|
= note: can't use a type alias as a constructor

Original file line number Diff line number Diff line change
@@ -31,24 +31,6 @@ help: a local variable with a similar name exists
LL | println!("{cofig}");
| ~~~~~

error[E0425]: cannot find function `baz` in this scope
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:31:9
|
LL | baz();
| ^^^
...
LL | fn ba() {}
| ------- similarly named function `ba` defined here
|
help: you might have meant to call the method
|
LL | self.baz();
| ~~~~~~~~
help: a function with a similar name exists
|
LL | ba();
| ~~

error[E0425]: cannot find value `bah` in this scope
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9
|
@@ -103,6 +85,24 @@ help: a type alias with a similar name exists
LL | let foo: Bar = "".to_string();
| ~~~

error[E0425]: cannot find function `baz` in this scope
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:31:9
|
LL | baz();
| ^^^
...
LL | fn ba() {}
| ------- similarly named function `ba` defined here
|
help: you might have meant to call the method
|
LL | self.baz();
| ~~~~~~~~
help: a function with a similar name exists
|
LL | ba();
| ~~

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0412, E0425.
12 changes: 6 additions & 6 deletions src/test/ui/rfc-2008-non-exhaustive/struct.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
error[E0423]: cannot initialize a tuple struct which contains private fields
--> $DIR/struct.rs:20:14
|
LL | let ts = TupleStruct(640, 480);
| ^^^^^^^^^^^

error[E0423]: expected value, found struct `UnitStruct`
--> $DIR/struct.rs:29:14
|
@@ -68,6 +62,12 @@ help: add `..` at the end of the field list to ignore all other fields
LL | let NormalStruct { first_field, second_field , .. } = ns;
| ~~~~~~

error[E0423]: cannot initialize a tuple struct which contains private fields
--> $DIR/struct.rs:20:14
|
LL | let ts = TupleStruct(640, 480);
| ^^^^^^^^^^^

error[E0638]: `..` required with struct marked as non-exhaustive
--> $DIR/struct.rs:26:9
|
Original file line number Diff line number Diff line change
@@ -25,12 +25,6 @@ LL | trait C{async fn new(val: T) {}
= help: pass `--edition 2021` to `rustc`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0423]: expected function, found module `crate`
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:9:5
|
LL | crate(move || {} ).await
| ^^^^^ not a function

error[E0412]: cannot find type `T` in this scope
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:27
|
@@ -53,6 +47,12 @@ LL | trait C{async fn new(val: T) {}
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable

error[E0423]: expected function, found module `crate`
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:9:5
|
LL | crate(move || {} ).await
| ^^^^^ not a function

warning: changes to closure capture in Rust 2021 will affect drop order
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:6:57
|
12 changes: 6 additions & 6 deletions src/test/ui/suggestions/assoc_fn_without_self.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
error[E0425]: cannot find function `foo` in this scope
--> $DIR/assoc_fn_without_self.rs:14:13
|
LL | foo();
| ^^^ not found in this scope

error[E0425]: cannot find function `foo` in this scope
--> $DIR/assoc_fn_without_self.rs:16:9
|
@@ -32,6 +26,12 @@ help: consider using the associated function
LL | Self::baz(2, 3);
| ~~~~~~~~~

error[E0425]: cannot find function `foo` in this scope
--> $DIR/assoc_fn_without_self.rs:14:13
|
LL | foo();
| ^^^ not found in this scope

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0425`.
19 changes: 19 additions & 0 deletions src/test/ui/suggestions/fn-to-method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
struct Foo;

impl Foo {
fn bar(self) {}
}

fn main() {
let x = cmp(&1, &2);
//~^ ERROR cannot find function `cmp` in this scope
//~| HELP use the `.` operator to call the method `Ord::cmp` on `&{integer}`

let y = len([1, 2, 3]);
//~^ ERROR cannot find function `len` in this scope
//~| HELP use the `.` operator to call the method `len` on `&[{integer}]`

let z = bar(Foo);
//~^ ERROR cannot find function `bar` in this scope
//~| HELP use the `.` operator to call the method `bar` on `Foo`
}
38 changes: 38 additions & 0 deletions src/test/ui/suggestions/fn-to-method.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
error[E0425]: cannot find function `cmp` in this scope
--> $DIR/fn-to-method.rs:8:13
|
LL | let x = cmp(&1, &2);
| ^^^ not found in this scope
|
help: use the `.` operator to call the method `Ord::cmp` on `&{integer}`
|
LL | let x = (&1).cmp(&2);
| ~ ~~~~~~~~~

error[E0425]: cannot find function `len` in this scope
--> $DIR/fn-to-method.rs:12:13
|
LL | let y = len([1, 2, 3]);
| ^^^ not found in this scope
|
help: use the `.` operator to call the method `len` on `&[{integer}]`
|
LL - let y = len([1, 2, 3]);
LL + let y = [1, 2, 3].len();
|

error[E0425]: cannot find function `bar` in this scope
--> $DIR/fn-to-method.rs:16:13
|
LL | let z = bar(Foo);
| ^^^ not found in this scope
|
help: use the `.` operator to call the method `bar` on `Foo`
|
LL - let z = bar(Foo);
LL + let z = Foo.bar();
|

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0425`.