Skip to content

could type inference fill in the _ in expr as Box<_> when expecting Box<Trait> ? #22221

@pnkfelix

Description

@pnkfelix
Member

Could type inference fill in expr as Box<_> when expecting Box<Trait> ?

From what I have seen, it seems to make no attempt to use the surrounding context to fill in gaps like the _ in Box<_> above.

spawned from #22086

Activity

changed the title [-]could type inference fill in `expr as Box<_>` when expecting `Box<Trait>`[/-] [+]could type inference fill in `expr as Box<_>` when expecting `Box<Trait>` ?[/+] on Feb 12, 2015
pnkfelix

pnkfelix commented on Feb 12, 2015

@pnkfelix
MemberAuthor
changed the title [-]could type inference fill in `expr as Box<_>` when expecting `Box<Trait>` ?[/-] [+]could type inference fill in the `_` in `expr as Box<_>` when expecting `Box<Trait>` ?[/+] on Feb 16, 2015
steveklabnik

steveklabnik commented on May 24, 2016

@steveklabnik
Member

Triage: box stuff is still up for debate.

Mark-Simulacrum

Mark-Simulacrum commented on May 4, 2017

@Mark-Simulacrum
Member

I'm not quite sure how to triage this, since this doesn't compile at all today. Perhaps this should be closed until as Box<_> becomes possible?

error: non-scalar cast: `i32` as `std::boxed::Box<std::fmt::Display>`
 --> test.rs:4:27
  |
4 |     let t: Box<Display> = 10 as Box<_>;
  |                           ^^^^^^^^^^^^

error: aborting due to previous error
Mark-Simulacrum

Mark-Simulacrum commented on Jun 22, 2017

@Mark-Simulacrum
Member

Per discussion on IRC with @aturon I'm going to close. It doesn't seem helpful to track this, since in almost all or all cases, inferring the trait would likely lead to surprising behavior, and so we probably don't want to do this anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@pnkfelix@Mark-Simulacrum

        Issue actions

          could type inference fill in the `_` in `expr as Box<_>` when expecting `Box<Trait>` ? · Issue #22221 · rust-lang/rust