You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of rust-lang#11860 - GuillaumeGomez:improve-error-messages, r=flip1995
Improve error messages format
Following review in rust-lang/rust-clippy#11845, since there is already suggestions, no need to add the second part of the sentence every time.
r? `@flip1995`
changelog: Improve some error messages
Copy file name to clipboardExpand all lines: tests/ui/option_as_ref_deref.stderr
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
error: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead
1
+
error: called `.as_ref().map(Deref::deref)` on an `Option` value
2
2
--> $DIR/option_as_ref_deref.rs:11:13
3
3
|
4
4
LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len);
@@ -7,7 +7,7 @@ LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len);
7
7
= note: `-D clippy::option-as-ref-deref` implied by `-D warnings`
8
8
= help: to override `-D warnings` add `#[allow(clippy::option_as_ref_deref)]`
9
9
10
-
error: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead
10
+
error: called `.as_ref().map(Deref::deref)` on an `Option` value
11
11
--> $DIR/option_as_ref_deref.rs:14:13
12
12
|
13
13
LL | let _ = opt.clone()
@@ -17,97 +17,97 @@ LL | | Deref::deref
17
17
LL | | )
18
18
| |_________^ help: try using as_deref instead: `opt.clone().as_deref()`
19
19
20
-
error: called `.as_mut().map(DerefMut::deref_mut)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
20
+
error: called `.as_mut().map(DerefMut::deref_mut)` on an `Option` value
21
21
--> $DIR/option_as_ref_deref.rs:20:13
22
22
|
23
23
LL | let _ = opt.as_mut().map(DerefMut::deref_mut);
24
24
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
25
25
26
-
error: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
26
+
error: called `.as_ref().map(String::as_str)` on an `Option` value
27
27
--> $DIR/option_as_ref_deref.rs:22:13
28
28
|
29
29
LL | let _ = opt.as_ref().map(String::as_str);
30
30
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
31
31
32
-
error: called `.as_ref().map(|x| x.as_str())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
32
+
error: called `.as_ref().map(|x| x.as_str())` on an `Option` value
33
33
--> $DIR/option_as_ref_deref.rs:23:13
34
34
|
35
35
LL | let _ = opt.as_ref().map(|x| x.as_str());
36
36
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
37
37
38
-
error: called `.as_mut().map(String::as_mut_str)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
38
+
error: called `.as_mut().map(String::as_mut_str)` on an `Option` value
39
39
--> $DIR/option_as_ref_deref.rs:24:13
40
40
|
41
41
LL | let _ = opt.as_mut().map(String::as_mut_str);
42
42
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
43
43
44
-
error: called `.as_mut().map(|x| x.as_mut_str())` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
44
+
error: called `.as_mut().map(|x| x.as_mut_str())` on an `Option` value
45
45
--> $DIR/option_as_ref_deref.rs:25:13
46
46
|
47
47
LL | let _ = opt.as_mut().map(|x| x.as_mut_str());
48
48
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
49
49
50
-
error: called `.as_ref().map(CString::as_c_str)` on an Option value. This can be done more directly by calling `Some(CString::new(vec![]).unwrap()).as_deref()` instead
50
+
error: called `.as_ref().map(CString::as_c_str)` on an `Option` value
51
51
--> $DIR/option_as_ref_deref.rs:26:13
52
52
|
53
53
LL | let _ = Some(CString::new(vec![]).unwrap()).as_ref().map(CString::as_c_str);
54
54
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(CString::new(vec![]).unwrap()).as_deref()`
55
55
56
-
error: called `.as_ref().map(OsString::as_os_str)` on an Option value. This can be done more directly by calling `Some(OsString::new()).as_deref()` instead
56
+
error: called `.as_ref().map(OsString::as_os_str)` on an `Option` value
57
57
--> $DIR/option_as_ref_deref.rs:27:13
58
58
|
59
59
LL | let _ = Some(OsString::new()).as_ref().map(OsString::as_os_str);
60
60
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(OsString::new()).as_deref()`
61
61
62
-
error: called `.as_ref().map(PathBuf::as_path)` on an Option value. This can be done more directly by calling `Some(PathBuf::new()).as_deref()` instead
62
+
error: called `.as_ref().map(PathBuf::as_path)` on an `Option` value
63
63
--> $DIR/option_as_ref_deref.rs:28:13
64
64
|
65
65
LL | let _ = Some(PathBuf::new()).as_ref().map(PathBuf::as_path);
66
66
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(PathBuf::new()).as_deref()`
67
67
68
-
error: called `.as_ref().map(Vec::as_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref()` instead
68
+
error: called `.as_ref().map(Vec::as_slice)` on an `Option` value
69
69
--> $DIR/option_as_ref_deref.rs:29:13
70
70
|
71
71
LL | let _ = Some(Vec::<()>::new()).as_ref().map(Vec::as_slice);
72
72
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(Vec::<()>::new()).as_deref()`
73
73
74
-
error: called `.as_mut().map(Vec::as_mut_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref_mut()` instead
74
+
error: called `.as_mut().map(Vec::as_mut_slice)` on an `Option` value
75
75
--> $DIR/option_as_ref_deref.rs:30:13
76
76
|
77
77
LL | let _ = Some(Vec::<()>::new()).as_mut().map(Vec::as_mut_slice);
78
78
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `Some(Vec::<()>::new()).as_deref_mut()`
79
79
80
-
error: called `.as_ref().map(|x| x.deref())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
80
+
error: called `.as_ref().map(|x| x.deref())` on an `Option` value
81
81
--> $DIR/option_as_ref_deref.rs:32:13
82
82
|
83
83
LL | let _ = opt.as_ref().map(|x| x.deref());
84
84
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
85
85
86
-
error: called `.as_mut().map(|x| x.deref_mut())` on an Option value. This can be done more directly by calling `opt.clone().as_deref_mut()` instead
86
+
error: called `.as_mut().map(|x| x.deref_mut())` on an `Option` value
87
87
--> $DIR/option_as_ref_deref.rs:33:13
88
88
|
89
89
LL | let _ = opt.clone().as_mut().map(|x| x.deref_mut()).map(|x| x.len());
90
90
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.clone().as_deref_mut()`
91
91
92
-
error: called `.as_ref().map(|x| &**x)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
92
+
error: called `.as_ref().map(|x| &**x)` on an `Option` value
93
93
--> $DIR/option_as_ref_deref.rs:40:13
94
94
|
95
95
LL | let _ = opt.as_ref().map(|x| &**x);
96
96
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
97
97
98
-
error: called `.as_mut().map(|x| &mut **x)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
98
+
error: called `.as_mut().map(|x| &mut **x)` on an `Option` value
99
99
--> $DIR/option_as_ref_deref.rs:41:13
100
100
|
101
101
LL | let _ = opt.as_mut().map(|x| &mut **x);
102
102
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
103
103
104
-
error: called `.as_ref().map(std::ops::Deref::deref)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
104
+
error: called `.as_ref().map(std::ops::Deref::deref)` on an `Option` value
105
105
--> $DIR/option_as_ref_deref.rs:44:13
106
106
|
107
107
LL | let _ = opt.as_ref().map(std::ops::Deref::deref);
108
108
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
109
109
110
-
error: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
110
+
error: called `.as_ref().map(String::as_str)` on an `Option` value
0 commit comments