Auto merge of #116089 - estebank:issue-115992-2, r=compiler-errors
When suggesting `self.x` for `S { x }`, use `S { x: self.x }` Fix #115992. r? `@compiler-errors` Follow up to #116086.
This commit is contained in:
commit
c1f86f0bc8
14 changed files with 306 additions and 75 deletions
|
@ -4140,6 +4140,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn resolve_expr_field(&mut self, f: &'ast ExprField, e: &'ast Expr) {
|
||||||
|
self.resolve_expr(&f.expr, Some(e));
|
||||||
|
self.visit_ident(f.ident);
|
||||||
|
walk_list!(self, visit_attribute, f.attrs.iter());
|
||||||
|
}
|
||||||
|
|
||||||
fn resolve_expr(&mut self, expr: &'ast Expr, parent: Option<&'ast Expr>) {
|
fn resolve_expr(&mut self, expr: &'ast Expr, parent: Option<&'ast Expr>) {
|
||||||
// First, record candidate traits for this expression if it could
|
// First, record candidate traits for this expression if it could
|
||||||
// result in the invocation of a method call.
|
// result in the invocation of a method call.
|
||||||
|
@ -4155,7 +4161,19 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||||
|
|
||||||
ExprKind::Struct(ref se) => {
|
ExprKind::Struct(ref se) => {
|
||||||
self.smart_resolve_path(expr.id, &se.qself, &se.path, PathSource::Struct);
|
self.smart_resolve_path(expr.id, &se.qself, &se.path, PathSource::Struct);
|
||||||
visit::walk_expr(self, expr);
|
// This is the same as `visit::walk_expr(self, expr);`, but we want to pass the
|
||||||
|
// parent in for accurate suggestions when encountering `Foo { bar }` that should
|
||||||
|
// have been `Foo { bar: self.bar }`.
|
||||||
|
if let Some(qself) = &se.qself {
|
||||||
|
self.visit_ty(&qself.ty);
|
||||||
|
}
|
||||||
|
self.visit_path(&se.path, expr.id);
|
||||||
|
walk_list!(self, resolve_expr_field, &se.fields, expr);
|
||||||
|
match &se.rest {
|
||||||
|
StructRest::Base(expr) => self.visit_expr(expr),
|
||||||
|
StructRest::Rest(_span) => {}
|
||||||
|
StructRest::None => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprKind::Break(Some(label), _) | ExprKind::Continue(Some(label)) => {
|
ExprKind::Break(Some(label), _) | ExprKind::Continue(Some(label)) => {
|
||||||
|
|
|
@ -41,7 +41,7 @@ type Res = def::Res<ast::NodeId>;
|
||||||
|
|
||||||
/// A field or associated item from self type suggested in case of resolution failure.
|
/// A field or associated item from self type suggested in case of resolution failure.
|
||||||
enum AssocSuggestion {
|
enum AssocSuggestion {
|
||||||
Field,
|
Field(Span),
|
||||||
MethodWithSelf { called: bool },
|
MethodWithSelf { called: bool },
|
||||||
AssocFn { called: bool },
|
AssocFn { called: bool },
|
||||||
AssocType,
|
AssocType,
|
||||||
|
@ -51,7 +51,7 @@ enum AssocSuggestion {
|
||||||
impl AssocSuggestion {
|
impl AssocSuggestion {
|
||||||
fn action(&self) -> &'static str {
|
fn action(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
AssocSuggestion::Field => "use the available field",
|
AssocSuggestion::Field(_) => "use the available field",
|
||||||
AssocSuggestion::MethodWithSelf { called: true } => {
|
AssocSuggestion::MethodWithSelf { called: true } => {
|
||||||
"call the method with the fully-qualified path"
|
"call the method with the fully-qualified path"
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut span_label = None;
|
let mut span_label = None;
|
||||||
let item_span = path.last().unwrap().ident.span;
|
let item_ident = path.last().unwrap().ident;
|
||||||
|
let item_span = item_ident.span;
|
||||||
let (mod_prefix, mod_str, module, suggestion) = if path.len() == 1 {
|
let (mod_prefix, mod_str, module, suggestion) = if path.len() == 1 {
|
||||||
debug!(?self.diagnostic_metadata.current_impl_items);
|
debug!(?self.diagnostic_metadata.current_impl_items);
|
||||||
debug!(?self.diagnostic_metadata.current_function);
|
debug!(?self.diagnostic_metadata.current_function);
|
||||||
|
@ -231,9 +232,35 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
let sp = item_span.shrink_to_lo();
|
let sp = item_span.shrink_to_lo();
|
||||||
|
|
||||||
|
// Account for `Foo { field }` when suggesting `self.field` so we result on
|
||||||
|
// `Foo { field: self.field }`.
|
||||||
|
let field = match source {
|
||||||
|
PathSource::Expr(Some(Expr { kind: ExprKind::Struct(expr), .. })) => {
|
||||||
|
expr.fields.iter().find(|f| f.ident == item_ident)
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
let pre = if let Some(field) = field && field.is_shorthand {
|
||||||
|
format!("{item_ident}: ")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
// Ensure we provide a structured suggestion for an assoc fn only for
|
||||||
|
// expressions that are actually a fn call.
|
||||||
|
let is_call = match field {
|
||||||
|
Some(ast::ExprField { expr, .. }) => {
|
||||||
|
matches!(expr.kind, ExprKind::Call(..))
|
||||||
|
}
|
||||||
|
_ => matches!(
|
||||||
|
source,
|
||||||
|
PathSource::Expr(Some(Expr { kind: ExprKind::Call(..), ..})),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
match &item.kind {
|
match &item.kind {
|
||||||
AssocItemKind::Fn(fn_)
|
AssocItemKind::Fn(fn_)
|
||||||
if !sig.decl.has_self() && fn_.sig.decl.has_self() => {
|
if (!sig.decl.has_self() || !is_call) && fn_.sig.decl.has_self() => {
|
||||||
// Ensure that we only suggest `self.` if `self` is available,
|
// Ensure that we only suggest `self.` if `self` is available,
|
||||||
// you can't call `fn foo(&self)` from `fn bar()` (#115992).
|
// you can't call `fn foo(&self)` from `fn bar()` (#115992).
|
||||||
// We also want to mention that the method exists.
|
// We also want to mention that the method exists.
|
||||||
|
@ -243,20 +270,28 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
));
|
));
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
AssocItemKind::Fn(fn_)
|
||||||
|
if !fn_.sig.decl.has_self() && !is_call => {
|
||||||
|
span_label = Some((
|
||||||
|
item.ident.span,
|
||||||
|
"an associated function by that name is available on `Self` here",
|
||||||
|
));
|
||||||
|
None
|
||||||
|
}
|
||||||
AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => Some((
|
AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => Some((
|
||||||
sp,
|
sp,
|
||||||
"consider using the method on `Self`",
|
"consider using the method on `Self`",
|
||||||
"self.".to_string(),
|
format!("{pre}self."),
|
||||||
)),
|
)),
|
||||||
AssocItemKind::Fn(_) => Some((
|
AssocItemKind::Fn(_) => Some((
|
||||||
sp,
|
sp,
|
||||||
"consider using the associated function on `Self`",
|
"consider using the associated function on `Self`",
|
||||||
"Self::".to_string(),
|
format!("{pre}Self::"),
|
||||||
)),
|
)),
|
||||||
AssocItemKind::Const(..) => Some((
|
AssocItemKind::Const(..) => Some((
|
||||||
sp,
|
sp,
|
||||||
"consider using the associated constant on `Self`",
|
"consider using the associated constant on `Self`",
|
||||||
"Self::".to_string(),
|
format!("{pre}Self::"),
|
||||||
)),
|
)),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
|
@ -621,17 +656,30 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
self.lookup_assoc_candidate(ident, ns, is_expected, source.is_call())
|
self.lookup_assoc_candidate(ident, ns, is_expected, source.is_call())
|
||||||
{
|
{
|
||||||
let self_is_available = self.self_value_is_available(path[0].ident.span);
|
let self_is_available = self.self_value_is_available(path[0].ident.span);
|
||||||
|
// Account for `Foo { field }` when suggesting `self.field` so we result on
|
||||||
|
// `Foo { field: self.field }`.
|
||||||
|
let pre = match source {
|
||||||
|
PathSource::Expr(Some(Expr { kind: ExprKind::Struct(expr), .. }))
|
||||||
|
if expr
|
||||||
|
.fields
|
||||||
|
.iter()
|
||||||
|
.any(|f| f.ident == path[0].ident && f.is_shorthand) =>
|
||||||
|
{
|
||||||
|
format!("{path_str}: ")
|
||||||
|
}
|
||||||
|
_ => String::new(),
|
||||||
|
};
|
||||||
match candidate {
|
match candidate {
|
||||||
AssocSuggestion::Field => {
|
AssocSuggestion::Field(field_span) => {
|
||||||
if self_is_available {
|
if self_is_available {
|
||||||
err.span_suggestion(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span.shrink_to_lo(),
|
||||||
"you might have meant to use the available field",
|
"you might have meant to use the available field",
|
||||||
format!("self.{path_str}"),
|
format!("{pre}self."),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_label(span, "a field by this name exists in `Self`");
|
err.span_label(field_span, "a field by that name exists in `Self`");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AssocSuggestion::MethodWithSelf { called } if self_is_available => {
|
AssocSuggestion::MethodWithSelf { called } if self_is_available => {
|
||||||
|
@ -640,10 +688,10 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
"you might have meant to refer to the method"
|
"you might have meant to refer to the method"
|
||||||
};
|
};
|
||||||
err.span_suggestion(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span.shrink_to_lo(),
|
||||||
msg,
|
msg,
|
||||||
format!("self.{path_str}"),
|
"self.".to_string(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -651,10 +699,10 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
| AssocSuggestion::AssocFn { .. }
|
| AssocSuggestion::AssocFn { .. }
|
||||||
| AssocSuggestion::AssocConst
|
| AssocSuggestion::AssocConst
|
||||||
| AssocSuggestion::AssocType => {
|
| AssocSuggestion::AssocType => {
|
||||||
err.span_suggestion(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span.shrink_to_lo(),
|
||||||
format!("you might have meant to {}", candidate.action()),
|
format!("you might have meant to {}", candidate.action()),
|
||||||
format!("Self::{path_str}"),
|
"Self::".to_string(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1667,11 +1715,11 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
resolution.full_res()
|
resolution.full_res()
|
||||||
{
|
{
|
||||||
if let Some(field_ids) = self.r.field_def_ids(did) {
|
if let Some(field_ids) = self.r.field_def_ids(did) {
|
||||||
if field_ids
|
if let Some(field_id) = field_ids
|
||||||
.iter()
|
.iter()
|
||||||
.any(|&field_id| ident.name == self.r.tcx.item_name(field_id))
|
.find(|&&field_id| ident.name == self.r.tcx.item_name(field_id))
|
||||||
{
|
{
|
||||||
return Some(AssocSuggestion::Field);
|
return Some(AssocSuggestion::Field(self.r.def_span(*field_id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,23 @@ error[E0425]: cannot find function `collect_primary` in this scope
|
||||||
--> $DIR/associated-fn-called-as-fn.rs:6:30
|
--> $DIR/associated-fn-called-as-fn.rs:6:30
|
||||||
|
|
|
|
||||||
LL | '0'..='9' => collect_primary(&c),
|
LL | '0'..='9' => collect_primary(&c),
|
||||||
| ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary`
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the associated function
|
||||||
|
|
|
||||||
|
LL | '0'..='9' => Self::collect_primary(&c),
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `collect_primary` in this scope
|
error[E0425]: cannot find function `collect_primary` in this scope
|
||||||
--> $DIR/associated-fn-called-as-fn.rs:23:30
|
--> $DIR/associated-fn-called-as-fn.rs:23:30
|
||||||
|
|
|
|
||||||
LL | '0'..='9' => collect_primary(&c),
|
LL | '0'..='9' => collect_primary(&c),
|
||||||
| ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary`
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the associated function
|
||||||
|
|
|
||||||
|
LL | '0'..='9' => Self::collect_primary(&c),
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -11,5 +11,8 @@ impl Foo {
|
||||||
field; //~ ERROR cannot find value `field` in this scope
|
field; //~ ERROR cannot find value `field` in this scope
|
||||||
Foo { field } //~ ERROR cannot find value `field` in this scope
|
Foo { field } //~ ERROR cannot find value `field` in this scope
|
||||||
}
|
}
|
||||||
|
fn clone(&self) -> Foo {
|
||||||
|
Foo { field } //~ ERROR cannot find value `field` in this scope
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,21 +1,41 @@
|
||||||
error[E0425]: cannot find value `field` in this scope
|
error[E0425]: cannot find value `field` in this scope
|
||||||
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:11:9
|
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:11:9
|
||||||
|
|
|
|
||||||
|
LL | field: u32,
|
||||||
|
| ---------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
LL | fn field(&self) -> u32 {
|
LL | fn field(&self) -> u32 {
|
||||||
| ----- a method by that name is available on `Self` here
|
| ----- a method by that name is available on `Self` here
|
||||||
...
|
...
|
||||||
LL | field;
|
LL | field;
|
||||||
| ^^^^^ a field by this name exists in `Self`
|
| ^^^^^
|
||||||
|
|
||||||
error[E0425]: cannot find value `field` in this scope
|
error[E0425]: cannot find value `field` in this scope
|
||||||
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:12:15
|
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:12:15
|
||||||
|
|
|
|
||||||
|
LL | field: u32,
|
||||||
|
| ---------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
|
LL | fn field(&self) -> u32 {
|
||||||
|
| ----- a method by that name is available on `Self` here
|
||||||
|
...
|
||||||
|
LL | Foo { field }
|
||||||
|
| ^^^^^
|
||||||
|
|
||||||
|
error[E0425]: cannot find value `field` in this scope
|
||||||
|
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:15:15
|
||||||
|
|
|
||||||
LL | fn field(&self) -> u32 {
|
LL | fn field(&self) -> u32 {
|
||||||
| ----- a method by that name is available on `Self` here
|
| ----- a method by that name is available on `Self` here
|
||||||
...
|
...
|
||||||
LL | Foo { field }
|
LL | Foo { field }
|
||||||
| ^^^^^ a field by this name exists in `Self`
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | Foo { field: self.field }
|
||||||
|
| ++++++++++++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0425`.
|
For more information about this error, try `rustc --explain E0425`.
|
||||||
|
|
|
@ -8,13 +8,23 @@ error[E0425]: cannot find value `x` in this scope
|
||||||
--> $DIR/issue-14254.rs:30:9
|
--> $DIR/issue-14254.rs:30:9
|
||||||
|
|
|
|
||||||
LL | x;
|
LL | x;
|
||||||
| ^ help: you might have meant to use the available field: `self.x`
|
| ^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.x;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `y` in this scope
|
error[E0425]: cannot find value `y` in this scope
|
||||||
--> $DIR/issue-14254.rs:32:9
|
--> $DIR/issue-14254.rs:32:9
|
||||||
|
|
|
|
||||||
LL | y;
|
LL | y;
|
||||||
| ^ help: you might have meant to use the available field: `self.y`
|
| ^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.y;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `a` in this scope
|
error[E0425]: cannot find value `a` in this scope
|
||||||
--> $DIR/issue-14254.rs:34:9
|
--> $DIR/issue-14254.rs:34:9
|
||||||
|
@ -31,7 +41,7 @@ LL | bah;
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `b` in this scope
|
error[E0425]: cannot find value `b` in this scope
|
||||||
--> $DIR/issue-14254.rs:38:9
|
--> $DIR/issue-14254.rs:38:9
|
||||||
|
@ -43,13 +53,23 @@ error[E0425]: cannot find value `x` in this scope
|
||||||
--> $DIR/issue-14254.rs:47:9
|
--> $DIR/issue-14254.rs:47:9
|
||||||
|
|
|
|
||||||
LL | x;
|
LL | x;
|
||||||
| ^ help: you might have meant to use the available field: `self.x`
|
| ^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.x;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `y` in this scope
|
error[E0425]: cannot find value `y` in this scope
|
||||||
--> $DIR/issue-14254.rs:49:9
|
--> $DIR/issue-14254.rs:49:9
|
||||||
|
|
|
|
||||||
LL | y;
|
LL | y;
|
||||||
| ^ help: you might have meant to use the available field: `self.y`
|
| ^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.y;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `a` in this scope
|
error[E0425]: cannot find value `a` in this scope
|
||||||
--> $DIR/issue-14254.rs:51:9
|
--> $DIR/issue-14254.rs:51:9
|
||||||
|
@ -66,7 +86,7 @@ LL | bah;
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `b` in this scope
|
error[E0425]: cannot find value `b` in this scope
|
||||||
--> $DIR/issue-14254.rs:55:9
|
--> $DIR/issue-14254.rs:55:9
|
||||||
|
@ -83,7 +103,7 @@ LL | bah;
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `bah` in this scope
|
error[E0425]: cannot find value `bah` in this scope
|
||||||
--> $DIR/issue-14254.rs:73:9
|
--> $DIR/issue-14254.rs:73:9
|
||||||
|
@ -94,7 +114,7 @@ LL | bah;
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `bah` in this scope
|
error[E0425]: cannot find value `bah` in this scope
|
||||||
--> $DIR/issue-14254.rs:82:9
|
--> $DIR/issue-14254.rs:82:9
|
||||||
|
@ -105,7 +125,7 @@ LL | bah;
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `bah` in this scope
|
error[E0425]: cannot find value `bah` in this scope
|
||||||
--> $DIR/issue-14254.rs:91:9
|
--> $DIR/issue-14254.rs:91:9
|
||||||
|
@ -116,7 +136,7 @@ LL | bah;
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `bah` in this scope
|
error[E0425]: cannot find value `bah` in this scope
|
||||||
--> $DIR/issue-14254.rs:100:9
|
--> $DIR/issue-14254.rs:100:9
|
||||||
|
@ -127,55 +147,95 @@ LL | bah;
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:19:9
|
--> $DIR/issue-14254.rs:19:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:28:9
|
--> $DIR/issue-14254.rs:28:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:45:9
|
--> $DIR/issue-14254.rs:45:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:62:9
|
--> $DIR/issue-14254.rs:62:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:71:9
|
--> $DIR/issue-14254.rs:71:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:80:9
|
--> $DIR/issue-14254.rs:80:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:89:9
|
--> $DIR/issue-14254.rs:89:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/issue-14254.rs:98:9
|
--> $DIR/issue-14254.rs:98:9
|
||||||
|
|
|
|
||||||
LL | baz();
|
LL | baz();
|
||||||
| ^^^ help: you might have meant to call the method: `self.baz`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.baz();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error: aborting due to 24 previous errors
|
error: aborting due to 24 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
error[E0425]: cannot find value `whiskers` in this scope
|
error[E0425]: cannot find value `whiskers` in this scope
|
||||||
--> $DIR/issue-2356.rs:39:5
|
--> $DIR/issue-2356.rs:39:5
|
||||||
|
|
|
|
||||||
|
LL | whiskers: isize,
|
||||||
|
| --------------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
LL | whiskers -= other;
|
LL | whiskers -= other;
|
||||||
| ^^^^^^^^ a field by this name exists in `Self`
|
| ^^^^^^^^
|
||||||
|
|
||||||
error[E0424]: expected value, found module `self`
|
error[E0424]: expected value, found module `self`
|
||||||
--> $DIR/issue-2356.rs:65:8
|
--> $DIR/issue-2356.rs:65:8
|
||||||
|
@ -21,13 +24,21 @@ error[E0425]: cannot find value `whiskers` in this scope
|
||||||
--> $DIR/issue-2356.rs:79:5
|
--> $DIR/issue-2356.rs:79:5
|
||||||
|
|
|
|
||||||
LL | whiskers = 0;
|
LL | whiskers = 0;
|
||||||
| ^^^^^^^^ help: you might have meant to use the available field: `self.whiskers`
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.whiskers = 0;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find value `whiskers` in this scope
|
error[E0425]: cannot find value `whiskers` in this scope
|
||||||
--> $DIR/issue-2356.rs:84:5
|
--> $DIR/issue-2356.rs:84:5
|
||||||
|
|
|
|
||||||
|
LL | whiskers: isize,
|
||||||
|
| --------------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
LL | whiskers = 4;
|
LL | whiskers = 4;
|
||||||
| ^^^^^^^^ a field by this name exists in `Self`
|
| ^^^^^^^^
|
||||||
|
|
||||||
error[E0424]: expected value, found module `self`
|
error[E0424]: expected value, found module `self`
|
||||||
--> $DIR/issue-2356.rs:92:5
|
--> $DIR/issue-2356.rs:92:5
|
||||||
|
@ -47,19 +58,34 @@ error[E0425]: cannot find function `clone` in this scope
|
||||||
--> $DIR/issue-2356.rs:24:5
|
--> $DIR/issue-2356.rs:24:5
|
||||||
|
|
|
|
||||||
LL | clone();
|
LL | clone();
|
||||||
| ^^^^^ help: you might have meant to call the method: `self.clone`
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.clone();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `default` in this scope
|
error[E0425]: cannot find function `default` in this scope
|
||||||
--> $DIR/issue-2356.rs:31:5
|
--> $DIR/issue-2356.rs:31:5
|
||||||
|
|
|
|
||||||
LL | default();
|
LL | default();
|
||||||
| ^^^^^^^ help: you might have meant to call the associated function: `Self::default`
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the associated function
|
||||||
|
|
|
||||||
|
LL | Self::default();
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `shave` in this scope
|
error[E0425]: cannot find function `shave` in this scope
|
||||||
--> $DIR/issue-2356.rs:41:5
|
--> $DIR/issue-2356.rs:41:5
|
||||||
|
|
|
|
||||||
LL | shave(4);
|
LL | shave(4);
|
||||||
| ^^^^^ help: you might have meant to call the associated function: `Self::shave`
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the associated function
|
||||||
|
|
|
||||||
|
LL | Self::shave(4);
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `purr` in this scope
|
error[E0425]: cannot find function `purr` in this scope
|
||||||
--> $DIR/issue-2356.rs:43:5
|
--> $DIR/issue-2356.rs:43:5
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
error[E0425]: cannot find value `banana` in this scope
|
error[E0425]: cannot find value `banana` in this scope
|
||||||
--> $DIR/issue-60057.rs:8:21
|
--> $DIR/issue-60057.rs:8:21
|
||||||
|
|
|
|
||||||
|
LL | banana: u8,
|
||||||
|
| ---------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
LL | banana: banana
|
LL | banana: banana
|
||||||
| ^^^^^^ a field by this name exists in `Self`
|
| ^^^^^^
|
||||||
|
|
||||||
error[E0425]: cannot find value `banana` in this scope
|
error[E0425]: cannot find value `banana` in this scope
|
||||||
--> $DIR/issue-60057.rs:14:21
|
--> $DIR/issue-60057.rs:14:21
|
||||||
|
|
|
|
||||||
LL | banana: banana
|
LL | banana: banana
|
||||||
| ^^^^^^ help: you might have meant to use the available field: `self.banana`
|
| ^^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | banana: self.banana
|
||||||
|
| +++++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,23 @@ error[E0425]: cannot find value `field` in this scope
|
||||||
--> $DIR/resolve-assoc-suggestions.rs:20:9
|
--> $DIR/resolve-assoc-suggestions.rs:20:9
|
||||||
|
|
|
|
||||||
LL | field;
|
LL | field;
|
||||||
| ^^^^^ help: you might have meant to use the available field: `self.field`
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.field;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0412]: cannot find type `Type` in this scope
|
error[E0412]: cannot find type `Type` in this scope
|
||||||
--> $DIR/resolve-assoc-suggestions.rs:23:16
|
--> $DIR/resolve-assoc-suggestions.rs:23:16
|
||||||
|
|
|
|
||||||
LL | let _: Type;
|
LL | let _: Type;
|
||||||
| ^^^^ help: you might have meant to use the associated type: `Self::Type`
|
| ^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the associated type
|
||||||
|
|
|
||||||
|
LL | let _: Self::Type;
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope
|
error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope
|
||||||
--> $DIR/resolve-assoc-suggestions.rs:25:13
|
--> $DIR/resolve-assoc-suggestions.rs:25:13
|
||||||
|
@ -50,7 +60,12 @@ error[E0425]: cannot find value `method` in this scope
|
||||||
--> $DIR/resolve-assoc-suggestions.rs:34:9
|
--> $DIR/resolve-assoc-suggestions.rs:34:9
|
||||||
|
|
|
|
||||||
LL | method;
|
LL | method;
|
||||||
| ^^^^^^ help: you might have meant to refer to the method: `self.method`
|
| ^^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to refer to the method
|
||||||
|
|
|
||||||
|
LL | self.method;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,23 @@ error[E0425]: cannot find value `field` in this scope
|
||||||
--> $DIR/resolve-speculative-adjustment.rs:23:9
|
--> $DIR/resolve-speculative-adjustment.rs:23:9
|
||||||
|
|
|
|
||||||
LL | field;
|
LL | field;
|
||||||
| ^^^^^ help: you might have meant to use the available field: `self.field`
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.field;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `method` in this scope
|
error[E0425]: cannot find function `method` in this scope
|
||||||
--> $DIR/resolve-speculative-adjustment.rs:25:9
|
--> $DIR/resolve-speculative-adjustment.rs:25:9
|
||||||
|
|
|
|
||||||
LL | method();
|
LL | method();
|
||||||
| ^^^^^^ help: you might have meant to call the method: `self.method`
|
| ^^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to call the method
|
||||||
|
|
|
||||||
|
LL | self.method();
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `method` in this scope
|
error[E0425]: cannot find function `method` in this scope
|
||||||
--> $DIR/resolve-speculative-adjustment.rs:19:13
|
--> $DIR/resolve-speculative-adjustment.rs:19:13
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
error[E0425]: cannot find value `config` in this scope
|
error[E0425]: cannot find value `config` in this scope
|
||||||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:7:16
|
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:7:16
|
||||||
|
|
|
|
||||||
|
LL | config: String,
|
||||||
|
| -------------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
LL | Self { config }
|
LL | Self { config }
|
||||||
| ^^^^^^
|
| ^^^^^^ help: a local variable with a similar name exists: `cofig`
|
||||||
| |
|
|
||||||
| a field by this name exists in `Self`
|
|
||||||
| help: a local variable with a similar name exists: `cofig`
|
|
||||||
|
|
||||||
error[E0425]: cannot find value `config` in this scope
|
error[E0425]: cannot find value `config` in this scope
|
||||||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:11:20
|
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:11:20
|
||||||
|
|
|
|
||||||
|
LL | config: String,
|
||||||
|
| -------------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
LL | println!("{config}");
|
LL | println!("{config}");
|
||||||
| ^^^^^^
|
| ^^^^^^ help: a local variable with a similar name exists: `cofig`
|
||||||
| |
|
|
||||||
| a field by this name exists in `Self`
|
|
||||||
| help: a local variable with a similar name exists: `cofig`
|
|
||||||
|
|
||||||
error[E0425]: cannot find value `config` in this scope
|
error[E0425]: cannot find value `config` in this scope
|
||||||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20
|
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20
|
||||||
|
@ -25,7 +25,7 @@ LL | println!("{config}");
|
||||||
help: you might have meant to use the available field
|
help: you might have meant to use the available field
|
||||||
|
|
|
|
||||||
LL | println!("{self.config}");
|
LL | println!("{self.config}");
|
||||||
| ~~~~~~~~~~~
|
| +++++
|
||||||
help: a local variable with a similar name exists
|
help: a local variable with a similar name exists
|
||||||
|
|
|
|
||||||
LL | println!("{cofig}");
|
LL | println!("{cofig}");
|
||||||
|
@ -43,7 +43,7 @@ LL | fn ba() {}
|
||||||
help: you might have meant to refer to the associated function
|
help: you might have meant to refer to the associated function
|
||||||
|
|
|
|
||||||
LL | Self::bah;
|
LL | Self::bah;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
help: a function with a similar name exists
|
help: a function with a similar name exists
|
||||||
|
|
|
|
||||||
LL | ba;
|
LL | ba;
|
||||||
|
@ -61,7 +61,7 @@ LL | const BARR: u32 = 3;
|
||||||
help: you might have meant to use the associated `const`
|
help: you might have meant to use the associated `const`
|
||||||
|
|
|
|
||||||
LL | Self::BAR;
|
LL | Self::BAR;
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
help: a constant with a similar name exists
|
help: a constant with a similar name exists
|
||||||
|
|
|
|
||||||
LL | BARR;
|
LL | BARR;
|
||||||
|
@ -79,7 +79,7 @@ LL | type Bar = String;
|
||||||
help: you might have meant to use the associated type
|
help: you might have meant to use the associated type
|
||||||
|
|
|
|
||||||
LL | let foo: Self::Baz = "".to_string();
|
LL | let foo: Self::Baz = "".to_string();
|
||||||
| ~~~~~~~~~
|
| ++++++
|
||||||
help: a type alias with a similar name exists
|
help: a type alias with a similar name exists
|
||||||
|
|
|
|
||||||
LL | let foo: Bar = "".to_string();
|
LL | let foo: Bar = "".to_string();
|
||||||
|
@ -97,7 +97,7 @@ LL | fn ba() {}
|
||||||
help: you might have meant to call the method
|
help: you might have meant to call the method
|
||||||
|
|
|
|
||||||
LL | self.baz();
|
LL | self.baz();
|
||||||
| ~~~~~~~~
|
| +++++
|
||||||
help: a function with a similar name exists
|
help: a function with a similar name exists
|
||||||
|
|
|
|
||||||
LL | ba();
|
LL | ba();
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
error[E0425]: cannot find value `cx` in this scope
|
error[E0425]: cannot find value `cx` in this scope
|
||||||
--> $DIR/unresolved_static_type_field.rs:9:11
|
--> $DIR/unresolved_static_type_field.rs:9:11
|
||||||
|
|
|
|
||||||
|
LL | cx: bool,
|
||||||
|
| -------- a field by that name exists in `Self`
|
||||||
|
...
|
||||||
LL | f(cx);
|
LL | f(cx);
|
||||||
| ^^ a field by this name exists in `Self`
|
| ^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,12 @@ error[E0425]: cannot find value `meows` in this scope
|
||||||
--> $DIR/class-missing-self.rs:9:7
|
--> $DIR/class-missing-self.rs:9:7
|
||||||
|
|
|
|
||||||
LL | meows += 1;
|
LL | meows += 1;
|
||||||
| ^^^^^ help: you might have meant to use the available field: `self.meows`
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the available field
|
||||||
|
|
|
||||||
|
LL | self.meows += 1;
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0425]: cannot find function `sleep` in this scope
|
error[E0425]: cannot find function `sleep` in this scope
|
||||||
--> $DIR/class-missing-self.rs:10:7
|
--> $DIR/class-missing-self.rs:10:7
|
||||||
|
|
|
@ -2,7 +2,12 @@ error[E0412]: cannot find type `Bla` in this scope
|
||||||
--> $DIR/assoc-type-in-method-return.rs:3:25
|
--> $DIR/assoc-type-in-method-return.rs:3:25
|
||||||
|
|
|
|
||||||
LL | fn to_bla(&self) -> Bla;
|
LL | fn to_bla(&self) -> Bla;
|
||||||
| ^^^ help: you might have meant to use the associated type: `Self::Bla`
|
| ^^^
|
||||||
|
|
|
||||||
|
help: you might have meant to use the associated type
|
||||||
|
|
|
||||||
|
LL | fn to_bla(&self) -> Self::Bla;
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue