Skip to content

Unhelpful "Sized not implemented for str" (or slices) after method lookup error. #33575

Closed
@eddyb

Description

@eddyb
fn main() {
    let x = ().foo();
    <i32 as std::str::FromStr>::from_str(&x);
}
<anon>:2:16: 2:19 error: no method named `foo` found for type `()` in the current scope
<anon>:2:9: 2:10 error: the trait `core::marker::Sized` is not implemented for the type `str` [E0277]

Because of the method error, x doesn't get a type (not even TyError, AFAICT), and then it gets inferred to str from another call in the function, which results in the unsized variable error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions