diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-12-31 17:13:11 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-01-11 01:34:23 +0000 |
| commit | c2ae386c851b9f85439375dc788a506e2482ca60 (patch) | |
| tree | 4ad1ade571b635d09670aa0053d8fbd6ac5ae4ba /compiler/rustc_codegen_llvm/src/errors.rs | |
| parent | 57f9f8f883b2621296549d82669299aecd00cc78 (diff) | |
| download | rust-c2ae386c851b9f85439375dc788a506e2482ca60.tar.gz rust-c2ae386c851b9f85439375dc788a506e2482ca60.zip | |
On E0308, detect `mut arg: &Ty` meant to be `arg: &mut Ty`
```
error[E0308]: mismatched types
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:6:14
|
LL | fn change_object(mut object: &Object) {
| ------- expected due to this parameter type
LL | let object2 = Object;
LL | object = object2;
| ^^^^^^^ expected `&Object`, found `Object`
|
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
LL ~ fn change_object(object: &mut Object) {
LL | let object2 = Object;
LL ~ *object = object2;
|
```
This might be the first thing someone tries to write to mutate the value *behind* an argument. We avoid suggesting `object = &object2;`, as that is less likely to be what was intended.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
