- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Description
I get an error message like this:
src/x86/bmi2/mod.rs:51:35: 51:36 error: mismatched types [E0308]
src/x86/bmi2/mod.rs:51         unsafe { intrinsics::bzhi(x, bit_position) }
                                                         ^
src/x86/bmi2/mod.rs:51:35: 51:36 help: run `rustc --explain E0308` to see a detailed explanation
src/x86/bmi2/mod.rs:51:35: 51:36 note: expected type `()`
src/x86/bmi2/mod.rs:51:35: 51:36 note:    found type `T`This tells me "what the error is", but gives me too little context (or no context at all) to actually solve it: I have to go to the intrinsics module, find the bzhi function, read its signature, and in my case, I end up baffled because it actually takes a T (so the expected type () makes no sense).
I still haven't figured out what is going on, but it would be good if when rustc detects a type error when calling a function, it would not only tell me where the error is, which type i am passing, and what type is expected, but where exactly the function is and what's its complete signature so that if needed I know where to go to read up the comments. Probably the real error here is that I am calling a function with the same name but from a different module, so it might be even better if rustc would check all functions in all modules in scope for functions with the same name and the type signature I am passing it and make a suggestion like "did you meant to call the bzhi function from the bar module instead?".
In particular the next error is a type error on the second function argument, so it would be even better if rustc could collapse these two errors into one.
EDIT: An example of the error is given here:
https://play.rust-lang.org/?gist=841b50e5845c61f2a1ebfd141673c151&version=nightly&backtrace=0
where the following error message is not very helpful:
error[E0308]: mismatched types
  --> src/main.rs:21:14
   |
21 |     bar::bar(x.zero())
   |              ^^^^^^^^ expected (), found type parameter
   |
   = note: expected type `()`
              found type `T`
   = help: here are some functions which might fulfill your needs:
           - .zero()
In particular the  expected (), found type parameter T is very misleading.