rust/compiler
bors 99f7d368c0 Auto merge of #112319 - oli-obk:assoc_ty_sized_bound_for_object_safety2, r=compiler-errors
Don't require associated types with Self: Sized bounds in `dyn Trait` objects

Trait objects require *all* associated types to be specified, even if the associated type has an explicit `where Self: Sized` bound. The following snippet does not compile on master, but does with this PR.

```rust
fn _assert_is_object_safe(_: &dyn Foo) {}

pub trait Foo {
    type Bar where Self: Sized;
}
```

In contrast, if a `Self: Sized` bound is added to a method, the methodjust isn't callable on trait objects, but the trait can be made object safe just fine.

```rust
fn _assert_is_object_safe(_: &dyn Foo) {}

pub trait Foo {
    fn foo() where Self: Sized;
}
```

This PR closes this inconsistency (though it still exists for associated constants).

Additionally this PR adds a new lint that informs users they can remove associated type bounds from their trait objects if those associated type bounds have a `where Self: Sized` bound, and are thus useless.

r? `@compiler-errors`
2023-07-05 08:48:04 +00:00
..
2023-06-28 10:52:48 +08:00
2023-07-02 21:02:31 +02:00
2023-07-02 21:02:31 +02:00
2023-07-02 21:02:31 +02:00
2023-07-03 13:51:54 -07:00
2023-07-03 13:51:54 -07:00
nit
2023-07-04 15:11:12 +01:00
2023-07-03 21:40:04 +00:00