Skip to content

Incorrectly-/Un-spanned error with type Out = Box<dyn Bar<Assoc: Copy>>; #63594

Closed
@Centril

Description

@Centril

With the following, the error appears in the wrong place (1), while it should be at (2).

//~ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied
// (1) --^

#![feature(associated_type_bounds)]

fn main() {}

trait Bar { type Assoc; }

trait Thing {
    type Out;
    fn func() -> Self::Out;
}

struct AssocNoCopy;
impl Bar for AssocNoCopy { type Assoc = String; }

impl Thing for AssocNoCopy {
    type Out = Box<dyn Bar<Assoc: Copy>>;

    fn func() -> Self::Out {
        Box::new(AssocNoCopy)
        //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied
        // (2) --^
    }
}

cc @alexreg @estebank @varkor

Metadata

Metadata

Assignees

Labels

A-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.F-associated_type_bounds`#![feature(associated_type_bounds)]`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