Skip to content

Commit 53fb433

Browse files
committedFeb 25, 2023
Special note for str in auto traits
1 parent 3560e65 commit 53fb433

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed
 

‎compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3107,6 +3107,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31073107
self.tcx.def_span(def_id),
31083108
"required because it's used within this closure",
31093109
),
3110+
ty::Str => err.note("`str` is considered to contain a `[u8]` slice for auto trait purposes"),
31103111
_ => err.note(&msg),
31113112
};
31123113
}

‎tests/ui/auto-traits/str-contains-slice-conceptually.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `[u8]: AutoTrait` is not satisfied in `str`
44
LL | needs_auto_trait::<str>();
55
| ^^^ within `str`, the trait `AutoTrait` is not implemented for `[u8]`
66
|
7-
= note: required because it appears within the type `str`
7+
= note: `str` is considered to contain a `[u8]` slice for auto trait purposes
88
note: required by a bound in `needs_auto_trait`
99
--> $DIR/str-contains-slice-conceptually.rs:8:24
1010
|

0 commit comments

Comments
 (0)