# Make associated types Sized by default

**URL:** <https://internals.rust-lang.org/t/make-associated-types-sized-by-default/615>\
**Category:** ideas (deprecated)\
**Created:** [October 8, 2014, 8:19pm UTC](https://internals.rust-lang.org/t/make-associated-types-sized-by-default/615 "2014-10-08T20:19:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kennytm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kennytm/32/161_2.png) [@kennytm](https://internals.rust-lang.org/u/kennytm)\
**Post date:** [October 8, 2014, 8:19pm UTC](https://internals.rust-lang.org/t/make-associated-types-sized-by-default/615/1 "2014-10-08T20:19:51Z")

</div>

Currently this program:

```rust
#![feature(associated_types)]
trait A {
    type T;
    fn foo(&self) -> <Self as A>::T;
    fn bar(&self) -> <Self as A>::T { self.foo() }
}
fn main() {}

```

Fails to compile as:

```rust
1.rs:5:39: 5:49 error: cannot move a value of type T: the size of T cannot be statically determined [E0161]
1.rs:5 fn bar(&self) -> <Self as A>::T { self.foo() }
                                             ^ ~~~~~~~~~

```

According to RFC 59 we should be able to fix it by (currently unimplemented)

```rust
trait A {
    type T : Sized;
    ...
}

```

But,

1. Shouldn’t associated types be Sized by default? As associated types are to be used to replace “output” type parameters, it is more convenient to be Sized.

2. If associated types are Sized by default, what should be the syntax then if we want to allow _unsized_ associated types? The generic spelling currently suggests something like

---

<div class="post-metadata">

**Author:** ![aturon](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/aturon/32/3272_2.png) [@aturon](https://internals.rust-lang.org/u/aturon)\
**Post date:** [October 9, 2014, 3:13pm UTC](https://internals.rust-lang.org/t/make-associated-types-sized-by-default/615/2 "2014-10-09T15:13:55Z")

</div>

Good catch – can you please file this as an issue on the github rust repository?

---

<div class="post-metadata">

**Author:** ![kennytm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kennytm/32/161_2.png) [@kennytm](https://internals.rust-lang.org/u/kennytm)\
**Post date:** [October 10, 2014, 10:34am UTC](https://internals.rust-lang.org/t/make-associated-types-sized-by-default/615/3 "2014-10-10T10:34:18Z")

</div>

Thanks. Filed as [https://github.com/rust-lang/rust/issues/17921](https://github.com/rust-lang/rust/issues/17921).

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:22am UTC](https://internals.rust-lang.org/t/make-associated-types-sized-by-default/615/4 "2019-03-25T08:22:58Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
