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
Copy file name to clipboardExpand all lines: tests/ui/option_as_ref_deref.stderr
+38-10
Original file line number
Diff line number
Diff line change
@@ -64,19 +64,47 @@ error: called `.as_ref().map(PathBuf::as_path)` on an Option value. This can be
64
64
LL | let _ = Some(PathBuf::new()).as_ref().map(PathBuf::as_path);
65
65
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(PathBuf::new()).as_deref()`
66
66
67
-
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', clippy_lints/src/path_from_format.rs:39:41
68
-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
67
+
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
+
--> $DIR/option_as_ref_deref.rs:31:13
69
+
|
70
+
LL | let _ = Some(Vec::<()>::new()).as_ref().map(Vec::as_slice);
71
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(Vec::<()>::new()).as_deref()`
69
72
70
-
error: internal compiler error: unexpected panic
73
+
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
+
--> $DIR/option_as_ref_deref.rs:32:13
75
+
|
76
+
LL | let _ = Some(Vec::<()>::new()).as_mut().map(Vec::as_mut_slice);
77
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `Some(Vec::<()>::new()).as_deref_mut()`
71
78
72
-
note: the compiler unexpectedly panicked. this is a bug.
79
+
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
+
--> $DIR/option_as_ref_deref.rs:34:13
81
+
|
82
+
LL | let _ = opt.as_ref().map(|x| x.deref());
83
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
73
84
74
-
note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new
85
+
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
+
--> $DIR/option_as_ref_deref.rs:35:13
87
+
|
88
+
LL | let _ = opt.clone().as_mut().map(|x| x.deref_mut()).map(|x| x.len());
89
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.clone().as_deref_mut()`
0 commit comments