Skip to content

Commit 627f513

Browse files
authored
Rollup merge of #153896 - estebank:deref-backticks, r=Kivooeo
[tiny] Tweak "use of `Deref`" suggestion message Surround trait name with backticks.
2 parents f5844e5 + 8e22bcd commit 627f513

9 files changed

Lines changed: 63 additions & 63 deletions

File tree

compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
392392
{
393393
err.span_suggestion_verbose(
394394
span,
395-
"consider dereferencing to access the inner value using the Deref trait",
395+
"consider dereferencing to access the inner value using the `Deref` trait",
396396
format!("{prefix}{peeled_snippet}"),
397397
Applicability::MaybeIncorrect,
398398
);

tests/ui/closures/2229_closure_analysis/issue-118144.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | V(x) = func_arg;
66
| |
77
| expected `&mut V`, found `V`
88
|
9-
help: consider dereferencing to access the inner value using the Deref trait
9+
help: consider dereferencing to access the inner value using the `Deref` trait
1010
|
1111
LL | V(x) = &*func_arg;
1212
| ++

tests/ui/let-else/let-else-deref-coercion.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | let Bar::Present(z) = self else {
66
| |
77
| expected `Foo`, found `Bar`
88
|
9-
help: consider dereferencing to access the inner value using the Deref trait
9+
help: consider dereferencing to access the inner value using the `Deref` trait
1010
|
1111
LL | let Bar::Present(z) = &**self else {
1212
| +++
@@ -19,7 +19,7 @@ LL | let Bar(z) = x;
1919
| |
2020
| expected `Foo`, found `Bar`
2121
|
22-
help: consider dereferencing to access the inner value using the Deref trait
22+
help: consider dereferencing to access the inner value using the `Deref` trait
2323
|
2424
LL | let Bar(z) = &**x;
2525
| +++

tests/ui/pattern/deref-patterns/const-pats-do-not-mislead-inference.stable.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LL | if let "..." = &Box::new(x) {}
1919
|
2020
= note: expected reference `&Box<_>`
2121
found reference `&'static str`
22-
help: consider dereferencing to access the inner value using the Deref trait
22+
help: consider dereferencing to access the inner value using the `Deref` trait
2323
|
2424
LL | if let "..." = &*Box::new(x) {}
2525
| +
@@ -34,7 +34,7 @@ LL | if let b"..." = Box::new(&x) {}
3434
|
3535
= note: expected struct `Box<&_>`
3636
found reference `&'static [u8; 3]`
37-
help: consider dereferencing to access the inner value using the Deref trait
37+
help: consider dereferencing to access the inner value using the `Deref` trait
3838
|
3939
LL | if let b"..." = *Box::new(&x) {}
4040
| +

tests/ui/pattern/deref-patterns/needs-gate.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LL | 0 => {}
1818
|
1919
= note: expected struct `Box<{integer}>`
2020
found type `{integer}`
21-
help: consider dereferencing to access the inner value using the Deref trait
21+
help: consider dereferencing to access the inner value using the `Deref` trait
2222
|
2323
LL | match *Box::new(0) {
2424
| +

tests/ui/pin-ergonomics/pattern-matching-mix-deref-pattern.normal.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | let Foo { x, y } = foo.as_mut();
88
|
99
= note: expected struct `Pin<&mut Foo<T, U>>`
1010
found struct `Foo<_, _>`
11-
help: consider dereferencing to access the inner value using the Deref trait
11+
help: consider dereferencing to access the inner value using the `Deref` trait
1212
|
1313
LL | let Foo { x, y } = *foo.as_mut();
1414
| +
@@ -23,7 +23,7 @@ LL | Foo { x, y } => {}
2323
|
2424
= note: expected struct `Pin<&mut Foo<T, U>>`
2525
found struct `Foo<_, _>`
26-
help: consider dereferencing to access the inner value using the Deref trait
26+
help: consider dereferencing to access the inner value using the `Deref` trait
2727
|
2828
LL | match *foo.as_mut() {
2929
| +
@@ -38,7 +38,7 @@ LL | Foo { x, y } => {}
3838
|
3939
= note: expected struct `Pin<&mut Foo<T, U>>`
4040
found struct `Foo<_, _>`
41-
help: consider dereferencing to access the inner value using the Deref trait
41+
help: consider dereferencing to access the inner value using the `Deref` trait
4242
|
4343
LL | let _ = || match *foo.as_mut() {
4444
| +
@@ -53,7 +53,7 @@ LL | let Foo { x, y } = foo;
5353
|
5454
= note: expected struct `Pin<&Foo<T, U>>`
5555
found struct `Foo<_, _>`
56-
help: consider dereferencing to access the inner value using the Deref trait
56+
help: consider dereferencing to access the inner value using the `Deref` trait
5757
|
5858
LL | let Foo { x, y } = *foo;
5959
| +
@@ -68,7 +68,7 @@ LL | Foo { x, y } => {}
6868
|
6969
= note: expected struct `Pin<&Foo<T, U>>`
7070
found struct `Foo<_, _>`
71-
help: consider dereferencing to access the inner value using the Deref trait
71+
help: consider dereferencing to access the inner value using the `Deref` trait
7272
|
7373
LL | match *foo {
7474
| +
@@ -83,7 +83,7 @@ LL | Foo { x, y } => {}
8383
|
8484
= note: expected struct `Pin<&Foo<T, U>>`
8585
found struct `Foo<_, _>`
86-
help: consider dereferencing to access the inner value using the Deref trait
86+
help: consider dereferencing to access the inner value using the `Deref` trait
8787
|
8888
LL | let _ = || match *foo {
8989
| +
@@ -98,7 +98,7 @@ LL | let Bar(x, y) = bar.as_mut();
9898
|
9999
= note: expected struct `Pin<&mut Bar<T, U>>`
100100
found struct `Bar<_, _>`
101-
help: consider dereferencing to access the inner value using the Deref trait
101+
help: consider dereferencing to access the inner value using the `Deref` trait
102102
|
103103
LL | let Bar(x, y) = *bar.as_mut();
104104
| +
@@ -113,7 +113,7 @@ LL | Bar(x, y) => {}
113113
|
114114
= note: expected struct `Pin<&mut Bar<T, U>>`
115115
found struct `Bar<_, _>`
116-
help: consider dereferencing to access the inner value using the Deref trait
116+
help: consider dereferencing to access the inner value using the `Deref` trait
117117
|
118118
LL | match *bar.as_mut() {
119119
| +
@@ -128,7 +128,7 @@ LL | Bar(x, y) => {}
128128
|
129129
= note: expected struct `Pin<&mut Bar<T, U>>`
130130
found struct `Bar<_, _>`
131-
help: consider dereferencing to access the inner value using the Deref trait
131+
help: consider dereferencing to access the inner value using the `Deref` trait
132132
|
133133
LL | let _ = || match *bar.as_mut() {
134134
| +
@@ -143,7 +143,7 @@ LL | let Bar(x, y) = bar;
143143
|
144144
= note: expected struct `Pin<&Bar<T, U>>`
145145
found struct `Bar<_, _>`
146-
help: consider dereferencing to access the inner value using the Deref trait
146+
help: consider dereferencing to access the inner value using the `Deref` trait
147147
|
148148
LL | let Bar(x, y) = *bar;
149149
| +
@@ -158,7 +158,7 @@ LL | Bar(x, y) => {}
158158
|
159159
= note: expected struct `Pin<&Bar<T, U>>`
160160
found struct `Bar<_, _>`
161-
help: consider dereferencing to access the inner value using the Deref trait
161+
help: consider dereferencing to access the inner value using the `Deref` trait
162162
|
163163
LL | match *bar {
164164
| +
@@ -173,7 +173,7 @@ LL | Bar(x, y) => {}
173173
|
174174
= note: expected struct `Pin<&Bar<T, U>>`
175175
found struct `Bar<_, _>`
176-
help: consider dereferencing to access the inner value using the Deref trait
176+
help: consider dereferencing to access the inner value using the `Deref` trait
177177
|
178178
LL | let _ = || match *bar {
179179
| +
@@ -188,7 +188,7 @@ LL | let NonPinProject { x } = foo;
188188
|
189189
= note: expected struct `Pin<&mut NonPinProject<T>>`
190190
found struct `NonPinProject<_>`
191-
help: consider dereferencing to access the inner value using the Deref trait
191+
help: consider dereferencing to access the inner value using the `Deref` trait
192192
|
193193
LL | let NonPinProject { x } = *foo;
194194
| +
@@ -203,7 +203,7 @@ LL | let NonPinProject { x } = bar;
203203
|
204204
= note: expected struct `Pin<&NonPinProject<U>>`
205205
found struct `NonPinProject<_>`
206-
help: consider dereferencing to access the inner value using the Deref trait
206+
help: consider dereferencing to access the inner value using the `Deref` trait
207207
|
208208
LL | let NonPinProject { x } = *bar;
209209
| +
@@ -218,7 +218,7 @@ LL | NonPinProject { x } => {}
218218
|
219219
= note: expected struct `Pin<&mut NonPinProject<T>>`
220220
found struct `NonPinProject<_>`
221-
help: consider dereferencing to access the inner value using the Deref trait
221+
help: consider dereferencing to access the inner value using the `Deref` trait
222222
|
223223
LL | match *foo {
224224
| +
@@ -233,7 +233,7 @@ LL | NonPinProject { x } => {}
233233
|
234234
= note: expected struct `Pin<&NonPinProject<U>>`
235235
found struct `NonPinProject<_>`
236-
help: consider dereferencing to access the inner value using the Deref trait
236+
help: consider dereferencing to access the inner value using the `Deref` trait
237237
|
238238
LL | match *bar {
239239
| +

tests/ui/pin-ergonomics/pattern-matching.normal.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LL | let Foo { x, y } = foo_mut;
2828
|
2929
= note: expected struct `Pin<&mut Foo<T, U>>`
3030
found struct `Foo<_, _>`
31-
help: consider dereferencing to access the inner value using the Deref trait
31+
help: consider dereferencing to access the inner value using the `Deref` trait
3232
|
3333
LL | let Foo { x, y } = *foo_mut;
3434
| +
@@ -43,7 +43,7 @@ LL | let Foo { x, y } = foo_const;
4343
|
4444
= note: expected struct `Pin<&Foo<T, U>>`
4545
found struct `Foo<_, _>`
46-
help: consider dereferencing to access the inner value using the Deref trait
46+
help: consider dereferencing to access the inner value using the `Deref` trait
4747
|
4848
LL | let Foo { x, y } = *foo_const;
4949
| +
@@ -58,7 +58,7 @@ LL | Bar::Foo(x, y) => {
5858
|
5959
= note: expected struct `Pin<&mut Bar<T, U>>`
6060
found enum `Bar<_, _>`
61-
help: consider dereferencing to access the inner value using the Deref trait
61+
help: consider dereferencing to access the inner value using the `Deref` trait
6262
|
6363
LL | match *bar_mut {
6464
| +
@@ -73,7 +73,7 @@ LL | _ if let Bar::Bar { x, y } = bar_mut => {
7373
|
7474
= note: expected struct `Pin<&mut Bar<T, U>>`
7575
found enum `Bar<_, _>`
76-
help: consider dereferencing to access the inner value using the Deref trait
76+
help: consider dereferencing to access the inner value using the `Deref` trait
7777
|
7878
LL | _ if let Bar::Bar { x, y } = *bar_mut => {
7979
| +
@@ -88,7 +88,7 @@ LL | Bar::Bar { x, y } => {
8888
|
8989
= note: expected struct `Pin<&Bar<T, U>>`
9090
found enum `Bar<_, _>`
91-
help: consider dereferencing to access the inner value using the Deref trait
91+
help: consider dereferencing to access the inner value using the `Deref` trait
9292
|
9393
LL | match *bar_const {
9494
| +
@@ -103,7 +103,7 @@ LL | _ if let Bar::Foo(x, y) = bar_const => {
103103
|
104104
= note: expected struct `Pin<&Bar<T, U>>`
105105
found enum `Bar<_, _>`
106-
help: consider dereferencing to access the inner value using the Deref trait
106+
help: consider dereferencing to access the inner value using the `Deref` trait
107107
|
108108
LL | _ if let Bar::Foo(x, y) = *bar_const => {
109109
| +
@@ -118,7 +118,7 @@ LL | let (Foo { x, y },) = foo_mut;
118118
|
119119
= note: expected struct `Pin<&mut (Foo<T, U>,)>`
120120
found tuple `(_,)`
121-
help: consider dereferencing to access the inner value using the Deref trait
121+
help: consider dereferencing to access the inner value using the `Deref` trait
122122
|
123123
LL | let (Foo { x, y },) = *foo_mut;
124124
| +
@@ -133,7 +133,7 @@ LL | let (Foo { x, y },) = foo_const;
133133
|
134134
= note: expected struct `Pin<&(Foo<T, U>,)>`
135135
found tuple `(_,)`
136-
help: consider dereferencing to access the inner value using the Deref trait
136+
help: consider dereferencing to access the inner value using the `Deref` trait
137137
|
138138
LL | let (Foo { x, y },) = *foo_const;
139139
| +

tests/ui/suggestions/suggest-deref-in-match-issue-132784.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ use std::sync::Arc;
22
fn main() {
33
let mut x = Arc::new(Some(1));
44
match x {
5-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
6-
//~| HELP consider dereferencing to access the inner value using the Deref trait
5+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
6+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
77
Some(_) => {}
88
//~^ ERROR mismatched types
99
None => {}
1010
//~^ ERROR mismatched types
1111
}
1212

1313
match &x {
14-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
15-
//~| HELP consider dereferencing to access the inner value using the Deref trait
14+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
15+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
1616
Some(_) => {}
1717
//~^ ERROR mismatched types
1818
None => {}
@@ -21,8 +21,8 @@ fn main() {
2121

2222
let mut y = Box::new(Some(1));
2323
match y {
24-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
25-
//~| HELP consider dereferencing to access the inner value using the Deref trait
24+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
25+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
2626
Some(_) => {}
2727
//~^ ERROR mismatched types
2828
None => {}
@@ -31,8 +31,8 @@ fn main() {
3131

3232
let mut z = Arc::new(Some(1));
3333
match z as Arc<Option<i32>> {
34-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
35-
//~| HELP consider dereferencing to access the inner value using the Deref trait
34+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
35+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
3636
Some(_) => {}
3737
//~^ ERROR mismatched types
3838
None => {}
@@ -41,8 +41,8 @@ fn main() {
4141

4242
let z_const: &Arc<Option<i32>> = &z;
4343
match z_const {
44-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
45-
//~| HELP consider dereferencing to access the inner value using the Deref trait
44+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
45+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
4646
Some(_) => {}
4747
//~^ ERROR mismatched types
4848
None => {}
@@ -52,8 +52,8 @@ fn main() {
5252
// Normal reference because Arc doesn't implement DerefMut.
5353
let z_mut: &mut Arc<Option<i32>> = &mut z;
5454
match z_mut {
55-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
56-
//~| HELP consider dereferencing to access the inner value using the Deref trait
55+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
56+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
5757
Some(_) => {}
5858
//~^ ERROR mismatched types
5959
None => {}
@@ -63,8 +63,8 @@ fn main() {
6363
// Mutable reference because Box does implement DerefMut.
6464
let y_mut: &mut Box<Option<i32>> = &mut y;
6565
match y_mut {
66-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
67-
//~| HELP consider dereferencing to access the inner value using the Deref trait
66+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
67+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
6868
Some(_) => {}
6969
//~^ ERROR mismatched types
7070
None => {}
@@ -74,8 +74,8 @@ fn main() {
7474
// Difficult expression.
7575
let difficult = Arc::new(Some(1));
7676
match (& (&difficult) ) {
77-
//~^ HELP consider dereferencing to access the inner value using the Deref trait
78-
//~| HELP consider dereferencing to access the inner value using the Deref trait
77+
//~^ HELP consider dereferencing to access the inner value using the `Deref` trait
78+
//~| HELP consider dereferencing to access the inner value using the `Deref` trait
7979
Some(_) => {}
8080
//~^ ERROR mismatched types
8181
None => {}

0 commit comments

Comments
 (0)