suggest method name with maybe ty mismatch

This commit is contained in:
yukang 2025-08-31 10:53:33 +08:00
parent 523d3999dc
commit 263766bcc2
5 changed files with 39 additions and 1 deletions

View file

@ -117,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Err(Ambiguity(..)) => true,
Err(PrivateMatch(..)) => false,
Err(IllegalSizedBound { .. }) => true,
Err(BadReturnType) => false,
Err(BadReturnType) => true,
Err(ErrorReported(_)) => false,
}
}

View file

@ -3,6 +3,11 @@ error[E0599]: no method named `test` found for opaque type `impl Future<Output =
|
LL | let x: u32 = foo().test();
| ^^^^ method not found in `impl Future<Output = A>`
|
help: consider `await`ing on the `Future` and calling the method on its `Output`
|
LL | let x: u32 = foo().await.test();
| ++++++
error: aborting due to 1 previous error

View file

@ -3,6 +3,11 @@ error[E0616]: field `len` of struct `Foo` is private
|
LL | if x.len {
| ^^^ private field
|
help: a method `len` also exists, call it with parentheses
|
LL | if x.len() {
| ++
error: aborting due to 1 previous error

View file

@ -0,0 +1,14 @@
struct LlamaModel;
impl LlamaModel {
fn chat_template(&self) -> Result<&str, ()> {
todo!()
}
}
fn template_from_str(_x: &str) {}
fn main() {
let model = LlamaModel;
template_from_str(&model.chat_template); //~ ERROR attempted to take value of method `chat_template` on type `LlamaModel`
}

View file

@ -0,0 +1,14 @@
error[E0615]: attempted to take value of method `chat_template` on type `LlamaModel`
--> $DIR/suggest-method-name-with-maybe-ty-mismatch-146008.rs:13:30
|
LL | template_from_str(&model.chat_template);
| ^^^^^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
LL | template_from_str(&model.chat_template());
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.