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

unhelpful "expected T, found T" message for identically named but distinct type parameters #9914

Closed
ben0x539 opened this issue Oct 17, 2013 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@ben0x539
Copy link
Contributor

struct Thing<T> {
    thing: T
}   

impl<T> Thing<T> {
  fn get<T>(self) -> T { 
    self.thing
  }   
}   
foo.rs:7:4: 7:14 error: mismatched types: expected `T` but found `T` (expected type parameter but found type parameter)
foo.rs:7     self.thing
             ^~~~~~~~~~

It's all right and proper but maybe we could come up with a way to denote that those two T come from different type parameter lists, or even ban type parameters shadowing each other.

@ghost
Copy link

ghost commented Oct 18, 2014

Closing as a dupe of #3404.

@ghost ghost closed this as completed Oct 18, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue May 20, 2023
don't remove `dbg!` in arbitrary expressions

Fixes rust-lang#9914

The `dbg_macro` lint replaces empty `dbg!` invocations with the empty string in its suggestion, which is not always valid code in certain contexts (e.g. `let _ = dbg!();` becomes `let _ = ;`). This PR changes it to `()`, which should always be valid where `dbg!()` is valid (`dbg!()` with no arguments evaluates to `()`).

It also special-cases "standalone" `dbg!();` expression statements, where it will suggest removing the whole statement entirely like it did before.

changelog: [`dbg_macro`]: don't remove `dbg!()` in arbitrary expressions as it sometimes results in syntax errors
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

2 participants
@ben0x539 and others