diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-26 12:04:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-26 12:04:57 +0100 |
| commit | 2bc553c6ea6243ecaee79ebe7a6fb5c6595e5eb9 (patch) | |
| tree | 02680f3a814060640fed46849a35917be79f9022 /compiler/rustc_trait_selection/src/solve | |
| parent | 70fd012439d75fd6ce561a6518b9b8fd399f455f (diff) | |
| parent | 53fb43365258bee55d796ba360835a9d6fcef9a5 (diff) | |
| download | rust-2bc553c6ea6243ecaee79ebe7a6fb5c6595e5eb9.tar.gz rust-2bc553c6ea6243ecaee79ebe7a6fb5c6595e5eb9.zip | |
Rollup merge of #107941 - compiler-errors:str-has-u8-slice-for-auto, r=lcnr
Treat `str` as containing `[u8]` for auto trait purposes Wanted to gauge ``@rust-lang/lang`` and ``@rust-lang/types`` teams' thoughts on treating `str` as "containing" a `[u8]` slice for auto-trait purposes. ``@dtolnay`` brought this up in https://github.com/rust-lang/rust/issues/13231#issuecomment-1399386472 as a blocker for future `str` type librarification, and I think it's both a valid concern and very easy to fix. I'm interested in actually doing that `str` type librarification (#107939), but this probably should be considered in the mean time regardless of that PR. r? types for the impl, though this definitely needs an FCP.
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs index f7d1b4be74b..d7d93377cf1 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs @@ -21,12 +21,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(..) |
