Skip to content

Hide type hints for constructor return values #3022

Closed
@jplatte

Description

@jplatte

It would be nice if rust-analyzer could omit the type hint for infallible constructors, for example

let mut builder = MyUsefulThingyBuilder::new();

and maybe for fallible constructors in conjunction with the ? operator too:

let thing = AnotherPrettyLongType::new(arg_a, arg_b)?;

as the type hints can cause the actual expression to go off screen and don't add anything in these cases. I'm not entirely certain what would be good criteria for considering something a constructor, but as a conservative approach only functions returning Self, Option<Self> or Result<Self, E> could be considered. Although IMHO it would be nice for conversions to also not receive type hints if invoked like a constructor:

let x = Type::from(something);
let y = Type::try_from(something)?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions