Skip to content

Calling .into() on argument that expects Into<Type> gives confusing error #71252

Closed
@estebank

Description

@estebank

When calling (x: Type)::into() in a fn that expects Into<Type> we currently emit:

error[E0283]: type annotations needed
    --> src/librustc_resolve/late/diagnostics.rs:1143:21
     |
1143 |                 err.span_note(spans.into(), "these named lifetimes are available to use");
     |                     ^^^^^^^^^ ------------ this method call resolves to `T`
     |                     |
     |                     cannot infer type for type parameter `S` declared on the method `span_note`
     |
     = note: cannot resolve `_: std::convert::Into<rustc_span::MultiSpan>`

We should check whether T == MultiSpan and suggest the removal of the into() call.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions