Skip to content

Rollup of 9 pull requests #108488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5c7ae25
Require `literal`s for some `(u)int_impl!` parameters
scottmcm Feb 21, 2023
2850116
Replace parse_[sth]_expr with parse_expr_[sth] function names
est31 Feb 24, 2023
3d34538
rustc_infer: Consolidate obligation elaboration de-duplication
megakorre Feb 24, 2023
a772a6f
Add ErrorGuaranteed to HIR TyKind::Err
compiler-errors Feb 22, 2023
c0e58c3
Add ErrorGuaranteed to HIR ExprKind::Err
compiler-errors Feb 22, 2023
0f4a7d1
Make clippy happy
compiler-errors Feb 23, 2023
3560e65
Treat `str` as containing `[u8]` for auto trait purposes
compiler-errors Feb 11, 2023
53fb433
Special note for str in auto traits
compiler-errors Feb 14, 2023
e5d1fcd
hir-analysis: make a helpful note
tshepang Feb 25, 2023
9e22516
Fix `VecDeque::shrink_to` and add tests.
Sp00ph Feb 26, 2023
4a4f43e
Disambiguate comments
Sp00ph Feb 26, 2023
90677ed
refactor: statically guarantee that current error codes are documented
Ezrashaw Feb 25, 2023
5304415
refactor: improve `error-index-generator` dependency
Ezrashaw Feb 25, 2023
312020e
Remove `from_fn` lang item
Noratrieb Feb 26, 2023
2bc553c
Rollup merge of #107941 - compiler-errors:str-has-u8-slice-for-auto, …
matthiaskrgr Feb 26, 2023
3d2319f
Rollup merge of #108299 - scottmcm:literal-bits, r=Nilstrieb
matthiaskrgr Feb 26, 2023
b27f37d
Rollup merge of #108337 - tshepang:translatable-hir-analysis, r=cjgillot
matthiaskrgr Feb 26, 2023
19b8685
Rollup merge of #108379 - compiler-errors:hir-error-guaranteed, r=cjg…
matthiaskrgr Feb 26, 2023
786a75a
Rollup merge of #108418 - est31:parser_function_names, r=Nilstrieb
matthiaskrgr Feb 26, 2023
c815e03
Rollup merge of #108424 - megakorre:elaborator_refactor, r=compiler-e…
matthiaskrgr Feb 26, 2023
be23b32
Rollup merge of #108475 - Sp00ph:fix_shrink_to, r=thomcc
matthiaskrgr Feb 26, 2023
edd27cf
Rollup merge of #108482 - Ezrashaw:force-error-docs, r=GuillaumeGomez
matthiaskrgr Feb 26, 2023
9c27fc7
Rollup merge of #108484 - Nilstrieb:˂DiagnosticItem˂FromFn˃ as From˂˂…
matthiaskrgr Feb 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(..)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3107,6 +3107,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
self.tcx.def_span(def_id),
"required because it's used within this closure",
),
ty::Str => err.note("`str` is considered to contain a `[u8]` slice for auto trait purposes"),
_ => err.note(&msg),
};
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2300,12 +2300,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
| ty::Float(_)
| ty::FnDef(..)
| ty::FnPtr(_)
| ty::Str
| ty::Error(_)
| ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
| ty::Never
| ty::Char => ty::Binder::dummy(Vec::new()),

// Treat this like `struct str([u8]);`
ty::Str => ty::Binder::dummy(vec![self.tcx().mk_slice(self.tcx().types.u8)]),

ty::Placeholder(..)
| ty::Dynamic(..)
| ty::Param(..)
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/auto-traits/str-contains-slice-conceptually.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![feature(negative_impls)]
#![feature(auto_traits)]

auto trait AutoTrait {}

impl<T> !AutoTrait for [T] {}

fn needs_auto_trait<T: AutoTrait + ?Sized>() {}

fn main() {
needs_auto_trait::<str>();
//~^ ERROR the trait bound `[u8]: AutoTrait` is not satisfied in `str`
}
16 changes: 16 additions & 0 deletions tests/ui/auto-traits/str-contains-slice-conceptually.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0277]: the trait bound `[u8]: AutoTrait` is not satisfied in `str`
--> $DIR/str-contains-slice-conceptually.rs:11:22
|
LL | needs_auto_trait::<str>();
| ^^^ within `str`, the trait `AutoTrait` is not implemented for `[u8]`
|
= note: `str` is considered to contain a `[u8]` slice for auto trait purposes
note: required by a bound in `needs_auto_trait`
--> $DIR/str-contains-slice-conceptually.rs:8:24
|
LL | fn needs_auto_trait<T: AutoTrait + ?Sized>() {}
| ^^^^^^^^^ required by this bound in `needs_auto_trait`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.