-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.F-associated_type_defaults`#![feature(associated_type_defaults)]``#![feature(associated_type_defaults)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
Here is a sample code:
trait Inner<S> {}
trait MyTrait {
fn something<I: Inner<Self>>(i: I);
}
Which fails to compile with
error[E0277]: the size for values of type
Self
cannot be known at compilation time
--> src/lib.rs:4:5
|
4 | fn something<I: Inner>(i: I);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
OTOH if we add a special This
associated type then we are completely fine:
#![feature(associated_type_defaults)]
trait Inner<S> {}
trait MyTrait {
type This = Self;
fn something<I: Inner<Self::This>>(i: I);
}
It looks like an undesirable behavior.
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.F-associated_type_defaults`#![feature(associated_type_defaults)]``#![feature(associated_type_defaults)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.