Skip to content

Commit e9a8ff7

Browse files
Special note for str in auto traits
1 parent bf1afe1 commit e9a8ff7

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
@@ -3102,6 +3102,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31023102
self.tcx.def_span(def_id),
31033103
"required because it's used within this closure",
31043104
),
3105+
ty::Str => err.note("`str` is considered to contain a `[u8]` slice for auto trait purposes"),
31053106
_ => err.note(&msg),
31063107
};
31073108
}

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)