Skip to content
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

No line number printed with the compile error #55374

Closed
grantslatton opened this issue Oct 26, 2018 · 1 comment
Closed

No line number printed with the compile error #55374

grantslatton opened this issue Oct 26, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@grantslatton
Copy link

I found a case in which no line number is printed where it is known:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=b993c1bf0ecd17c5c8a3e3bc826bea26

Code:

trait Foo {
    type T;
    fn foo(&self, t: Self::T);
}

impl Foo for u32 {
    type T = ();
    
    fn foo(&self, t: impl Clone) {}
}

fn main() {}

Output:

   Compiling playground v0.0.1 (file:///playground)
error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 type parameters

error: aborting due to previous error

For more information about this error, try `rustc --explain E0049`.
error: Could not compile `playground`.

To learn more, run the command again with --verbose.
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. labels Oct 26, 2018
@estebank
Copy link
Contributor

estebank commented Nov 6, 2018

This is caused by improper handling of impl Trait in argument position in diagnostics, with code assuming that if the type parameters don't match is purely due to generics. I have a small patch that will fix this issue, but we'll have to rework how we get spans for generic arguments so that all diagnostics can handle impl Trait in arg position.

kennytm added a commit to kennytm/rust that referenced this issue Nov 7, 2018
…=varkor

Use trait impl method span when type param mismatch is due to impl Trait

Fix rust-lang#55374.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants