]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #105491 - sulami:master, r=compiler-errors
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 14 Dec 2022 09:31:05 +0000 (10:31 +0100)
committerGitHub <noreply@github.com>
Wed, 14 Dec 2022 09:31:05 +0000 (10:31 +0100)
Illegal sized bounds: only suggest mutability change if needed

In a scenario like

```rust
struct Type;

pub trait Trait {
    fn function(&mut self)
    where
        Self: Sized;
}

impl Trait for Type {
    fn function(&mut self) {}
}

fn main() {
    (&mut Type as &mut dyn Trait).function();
}
```

the problem is Sized, not the mutability of self. Thus don't emit the "you need &T instead of &mut T" note, or the other way around, as all it does is just invert the mutability of whatever was supplied.

Fixes #103622.

1  2 
compiler/rustc_hir_typeck/src/method/mod.rs