Skip to content

impl Trait feature is not make code easy #47348

Closed as not planned
Closed as not planned
@3442853561

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.

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