Apparent duplicated diagnostic note for type mismatch involving type with defaulted type parameter. #101992
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: (playground)
The current output is:
Current output
(
*_no_param
show the ideal diagnostics,*_default_param
show cases where the diagnostic appears to the user to be completely duplicated,*_with_param
show cases where the diagnostic appears to the user to be somewhat duplicated)Ideally the output should look like:
Ideal output (diff)
Essentailly, have the diagnostics for
calls_default_param_with_ref
andcalls_with_param_with_ref
be the same ascalls_no_param_with_ref
, and the diagnostics forreturns_default_param
andreturns_with_param
be the same asreturns_no_param
(with the corresponding types).(The diagnostics for
*_with_param
are technically not duplicated, since the note does give more information (the type parameter) that is not given by the error message. I have included them here since they are still mostly duplicated when all types involved are known, but it's debatable.)Explanation: When there is a type mismatch where the error message already completely describes the two types, no note is printed (see the
NoParam
functions above)1. When a type mismatch occurs where the error message does not already completely describe the two types, a note is printed with the two complete types (see theWithParam
functions above).In the case where the only type parameter of a type has a default, and that default is used, this causes the note that is printed to contain the "same" types as the error message2.
(The diagnostics for
*_with_param
are technically not duplicated, since the note does give more information (the type parameter) that is not given by the error message. I have included them here since they are still mostly duplicated when all types involved are known, but it's debatable.)I found this difference when adding a defaulted allocator type parameter to
String
in #101551, which added these notes to the outputs of a lot of UI tests.The results are the same in all editions, and on stable and nightly (and 1.41.0, but not 1.40.0, which prints the duplicate note even for
NoParam
1).Rust version
Stable:
Nightly:
Footnotes
Note that this was introduced 1.41.0: (godbolt.org link). Previously, the note with duplicate information appears to have always been printed. ↩ ↩2
I say "same" because what is printed is the same, but I think the error messages for
*_default_param
are really sayingexpected DefaultParam<_>, found ...
, and the notes are sayingexpected DefaultParam<()>, found ...
. ↩The text was updated successfully, but these errors were encountered: