Skip to content

impl Trait feature is not make code easy #47348

Description

@3442853561
#![feature(conservative_impl_trait, universal_impl_trait)]

use std::ops::Sub;

trait Trait: Sub + Copy {}

impl Trait for i32{}

fn test0(foo: impl Trait) -> <impl Trait as std::ops::Sub>::Output {
    foo - foo
}

fn test1<T: Sub + Copy>(foo: T) -> T::Output {
    foo - foo
}

fn main() {
    let foo = test0(1);
    let bar = test1(1);
    println!("{:?}", bar);
}

Only the bar can be debug.

Activity

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

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.T-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