Treat str as containing [u8] for auto trait purposes

This commit is contained in:
Michael Goulet
2023-02-11 23:01:22 +00:00
parent 31448badfd
commit 3560e65c44
4 changed files with 35 additions and 2 deletions

View File

@@ -20,12 +20,14 @@ pub(super) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
| ty::Float(_)
| ty::FnDef(..)
| ty::FnPtr(_)
| ty::Str
| ty::Error(_)
| ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
| ty::Never
| ty::Char => Ok(vec![]),
// Treat this like `struct str([u8]);`
ty::Str => Ok(vec![tcx.mk_slice(tcx.types.u8)]),
ty::Dynamic(..)
| ty::Param(..)
| ty::Foreign(..)