-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
E0277 focuses on the wrong part of the line. #100560
Comments
Can you minimize this or provide a few more signatures for all the methods being called here? |
oh, lol, it's chumsky. good to have known that -- didn't see the file path in your error output. so the root cause here is that both arguments in |
Oh, right, my bad. It's the Parser::delimited_by method in this case: fn delimited_by<U, V, L, R>(
self,
start: L,
end: R
) -> DelimitedBy<Self, L, R, U, V>
where
Self: Sized,
L: Parser<I, U, Error = Self::Error>,
R: Parser<I, V, Error = Self::Error>, So the I'm not entirely sure how to make the example more minimal though... |
oh you even already know the name of the lib >_> i hope they're not the source of a lot of error message reports |
haha no i just saw in the file path of the error you pasted, and i recognized the name
no worries, i think i understand the root cause. let me "minimize it". @rustbot claim |
Minimized: trait Bar {}
fn foo<T: Bar>(t: T, s: String) {}
fn bar<T: Bar>(t: T, u: u32) {}
fn main() {
foo(String::new(), String::new());
// ^^^ for foo, the error is placed here
// compare to bar
bar(String::new(), 1u32);
// ^^^^^^^^^^^ where the error is pointing out the correct arg
}
|
I've now gotten it to point at the arg even if there's a duplicate argument in the signature:
Now to deal with all the other fall-out of these changes... |
So i've got some code like this:
What is wrong: The
delimited_by
takes a parser for what occurs immediately before and immediately after the parser you call the method on. So it has a: Parser<I, O>
trait bound. Except thatPunctuation('[')
is a token, not a parser for a token. What I should have written isjust(Punctuation('['))
.What Rustc Tells You:
The Problem: The part that's "wrong" in the line is the argument, not the method call. The way the error describes things, it makes it sound like the method doesn't exist because the thing i'm calling it on doesn't satisfy some trait bound or something like that. Which, if this were nearly any other language, would sound like a silly thing to worry about, but with rust that's a genuine concern.
How I Think Rustc Should Show The Error:
Instead of focusing on
delimited_by
as having the error, it should focus on the argument todelimited_by
as having the error.The text was updated successfully, but these errors were encountered: