Skip to content

Rollup of 10 pull requests #130732

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 21 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3dcb5a3
Add str.as_str() for easy dereferencing of Box<str>
kornelski Aug 25, 2024
c2ccd89
handle unsized consts with type `str` in v0 symbol mangling
Jaic1 Sep 14, 2024
f48c5ec
Mark and implement 'char::encode_utf16' as const; Rewrite 'encode_utf…
bjoernager Sep 21, 2024
95469dc
No longer mark RTN as incomplete
compiler-errors Sep 21, 2024
3b8089a
Introduce structurally_normalize_const, use it in hir_typeck
compiler-errors Sep 22, 2024
2daf076
Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'u8' as con…
bjoernager Sep 22, 2024
8f57949
Don't call const normalize in error reporting
compiler-errors Sep 22, 2024
01d19d7
Don't call try_eval_target_usize in error reporting
compiler-errors Sep 22, 2024
2273aee
Replace calls to Const::eval in mir build
compiler-errors Sep 22, 2024
e9b0bc9
Add test for `available_parallelism()`
Sep 22, 2024
ff3a9f4
tests: Remove spuriously failing vec-tryinto-array codegen test
workingjubilee Sep 22, 2024
510fc34
Rollup merge of #129550 - kornelski:boxasstr, r=joshtriplett,dtolnay
matthiaskrgr Sep 23, 2024
23393de
Rollup merge of #130344 - Jaic1:fix-116306, r=BoxyUwU
matthiaskrgr Sep 23, 2024
c1ccdb7
Rollup merge of #130659 - bjoernager:const-char-encode-utf16, r=dtolnay
matthiaskrgr Sep 23, 2024
9f5cbfb
Rollup merge of #130705 - compiler-errors:rtn-complete, r=jackh726
matthiaskrgr Sep 23, 2024
8206036
Rollup merge of #130712 - compiler-errors:const-eval-error-reporting,…
matthiaskrgr Sep 23, 2024
8bb69b1
Rollup merge of #130713 - bjoernager:const-char-make-ascii, r=Noratrieb
matthiaskrgr Sep 23, 2024
2bca5c4
Rollup merge of #130714 - compiler-errors:try-structurally-resolve-co…
matthiaskrgr Sep 23, 2024
0e08d70
Rollup merge of #130715 - compiler-errors:mir-build-const-eval, r=Box…
matthiaskrgr Sep 23, 2024
004213b
Rollup merge of #130723 - D0liphin:master, r=workingjubilee
matthiaskrgr Sep 23, 2024
693269b
Rollup merge of #130726 - workingjubilee:put-the-spurs-to-this-test, …
matthiaskrgr Sep 23, 2024
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 @@ -17,7 +17,7 @@ use rustc_middle::traits::SignatureMismatchData;
use rustc_middle::traits::select::OverflowError;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::print::{
FmtPrinter, Print, PrintTraitPredicateExt as _, PrintTraitRefExt as _,
with_forced_trimmed_paths,
Expand Down Expand Up @@ -1788,22 +1788,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
return false;
}

let cand = self.resolve_vars_if_possible(impl_trait_ref).fold_with(
&mut BottomUpFolder {
tcx: self.tcx,
ty_op: |ty| ty,
lt_op: |lt| lt,
ct_op: |ct| ct.normalize(self.tcx, ty::ParamEnv::empty()),
},
);
if cand.references_error() {
let impl_trait_ref = self.resolve_vars_if_possible(impl_trait_ref);
if impl_trait_ref.references_error() {
return false;
}
err.highlighted_help(vec![
StringPart::normal(format!("the trait `{}` ", cand.print_trait_sugared())),
StringPart::normal(format!(
"the trait `{}` ",
impl_trait_ref.print_trait_sugared()
)),
StringPart::highlighted("is"),
StringPart::normal(" implemented for `"),
StringPart::highlighted(cand.self_ty().to_string()),
StringPart::highlighted(impl_trait_ref.self_ty().to_string()),
StringPart::normal("`"),
]);

Expand Down Expand Up @@ -1915,15 +1911,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let mut impl_candidates: Vec<_> = impl_candidates
.iter()
.cloned()
.filter(|cand| !cand.trait_ref.references_error())
.map(|mut cand| {
// Fold the consts so that they shows up as, e.g., `10`
// instead of `core::::array::{impl#30}::{constant#0}`.
cand.trait_ref = cand.trait_ref.fold_with(&mut BottomUpFolder {
tcx: self.tcx,
ty_op: |ty| ty,
lt_op: |lt| lt,
ct_op: |ct| ct.normalize(self.tcx, ty::ParamEnv::empty()),
});
// Normalize the trait ref in its *own* param-env so
// that consts are folded and any trivial projections
// are normalized.
cand.trait_ref = self
.tcx
.try_normalize_erasing_regions(
self.tcx.param_env(cand.impl_def_id),
cand.trait_ref,
)
.unwrap_or(cand.trait_ref);
cand
})
.collect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4620,7 +4620,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
format!("&{}{ty}", mutability.prefix_str())
}
}
ty::Array(ty, len) if let Some(len) = len.try_eval_target_usize(tcx, param_env) => {
ty::Array(ty, len) if let Some(len) = len.try_to_target_usize(tcx) => {
if len == 0 {
"[]".to_string()
} else if self.type_is_copy_modulo_regions(param_env, ty) || len == 1 {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/binop/binary-op-suggest-deref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ LL | let _ = FOO & (*"Sized".to_string().into_boxed_str());
|
= help: the trait `BitAnd<str>` is not implemented for `i32`
= help: the following other types implement trait `BitAnd<Rhs>`:
`&'a i32` implements `BitAnd<i32>`
`&i32` implements `BitAnd<&i32>`
`&i32` implements `BitAnd<i32>`
`&i32` implements `BitAnd`
`i32` implements `BitAnd<&i32>`
`i32` implements `BitAnd`

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/binop/binop-mul-i32-f32.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LL | x * y
|
= help: the trait `Mul<f32>` is not implemented for `i32`
= help: the following other types implement trait `Mul<Rhs>`:
`&'a i32` implements `Mul<i32>`
`&i32` implements `Mul<&i32>`
`&i32` implements `Mul<i32>`
`&i32` implements `Mul`
`i32` implements `Mul<&i32>`
`i32` implements `Mul`

Expand Down
48 changes: 24 additions & 24 deletions tests/ui/binop/shift-various-bad-types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ LL | 22 >> p.char;
|
= help: the trait `Shr<char>` is not implemented for `{integer}`
= help: the following other types implement trait `Shr<Rhs>`:
`&'a i128` implements `Shr<i128>`
`&'a i128` implements `Shr<i16>`
`&'a i128` implements `Shr<i32>`
`&'a i128` implements `Shr<i64>`
`&'a i128` implements `Shr<i8>`
`&'a i128` implements `Shr<isize>`
`&'a i128` implements `Shr<u128>`
`&'a i128` implements `Shr<u16>`
`&i128` implements `Shr<&i16>`
`&i128` implements `Shr<&i32>`
`&i128` implements `Shr<&i64>`
`&i128` implements `Shr<&i8>`
`&i128` implements `Shr<&isize>`
`&i128` implements `Shr<&u128>`
`&i128` implements `Shr<&u16>`
`&i128` implements `Shr<&u32>`
and 568 others

error[E0277]: no implementation for `{integer} >> &str`
Expand All @@ -24,14 +24,14 @@ LL | 22 >> p.str;
|
= help: the trait `Shr<&str>` is not implemented for `{integer}`
= help: the following other types implement trait `Shr<Rhs>`:
`&'a i128` implements `Shr<i128>`
`&'a i128` implements `Shr<i16>`
`&'a i128` implements `Shr<i32>`
`&'a i128` implements `Shr<i64>`
`&'a i128` implements `Shr<i8>`
`&'a i128` implements `Shr<isize>`
`&'a i128` implements `Shr<u128>`
`&'a i128` implements `Shr<u16>`
`&i128` implements `Shr<&i16>`
`&i128` implements `Shr<&i32>`
`&i128` implements `Shr<&i64>`
`&i128` implements `Shr<&i8>`
`&i128` implements `Shr<&isize>`
`&i128` implements `Shr<&u128>`
`&i128` implements `Shr<&u16>`
`&i128` implements `Shr<&u32>`
and 568 others

error[E0277]: no implementation for `{integer} >> &Panolpy`
Expand All @@ -42,14 +42,14 @@ LL | 22 >> p;
|
= help: the trait `Shr<&Panolpy>` is not implemented for `{integer}`
= help: the following other types implement trait `Shr<Rhs>`:
`&'a i128` implements `Shr<i128>`
`&'a i128` implements `Shr<i16>`
`&'a i128` implements `Shr<i32>`
`&'a i128` implements `Shr<i64>`
`&'a i128` implements `Shr<i8>`
`&'a i128` implements `Shr<isize>`
`&'a i128` implements `Shr<u128>`
`&'a i128` implements `Shr<u16>`
`&i128` implements `Shr<&i16>`
`&i128` implements `Shr<&i32>`
`&i128` implements `Shr<&i64>`
`&i128` implements `Shr<&i8>`
`&i128` implements `Shr<&isize>`
`&i128` implements `Shr<&u128>`
`&i128` implements `Shr<&u16>`
`&i128` implements `Shr<&u32>`
and 568 others

error[E0308]: mismatched types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the trait bound `A<_>: Bar<_>` is not satisfied
LL | let _ = A;
| ^ the trait `Bar<_>` is not implemented for `A<_>`
|
= help: the trait `Bar<_>` is implemented for `A<7>`
= help: the trait `Bar<_>` is implemented for `A<{ 6 + 1 }>`
note: required by a bound in `A`
--> $DIR/unused-substs-1.rs:9:11
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/consts/const-eval/const-eval-overflow-3b.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ LL | = [0; (i8::MAX + 1u8) as usize];
|
= help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
`&'a i8` implements `Add<i8>`
`&i8` implements `Add<&i8>`
`&i8` implements `Add<i8>`
`&i8` implements `Add`
`i8` implements `Add<&i8>`
`i8` implements `Add`

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/consts/const-eval/const-eval-overflow-4b.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
|
= help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
`&'a i8` implements `Add<i8>`
`&i8` implements `Add<&i8>`
`&i8` implements `Add<i8>`
`&i8` implements `Add`
`i8` implements `Add<&i8>`
`i8` implements `Add`

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/impl-trait/equality.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ LL | n + sum_to(n - 1)
|
= help: the trait `Add<impl Foo>` is not implemented for `u32`
= help: the following other types implement trait `Add<Rhs>`:
`&'a u32` implements `Add<u32>`
`&u32` implements `Add<&u32>`
`&u32` implements `Add<u32>`
`&u32` implements `Add`
`u32` implements `Add<&u32>`
`u32` implements `Add`

Expand Down
32 changes: 16 additions & 16 deletions tests/ui/issues/issue-11771.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ LL | 1 +
|
= help: the trait `Add<()>` is not implemented for `{integer}`
= help: the following other types implement trait `Add<Rhs>`:
`&'a f128` implements `Add<f128>`
`&'a f16` implements `Add<f16>`
`&'a f32` implements `Add<f32>`
`&'a f64` implements `Add<f64>`
`&'a i128` implements `Add<i128>`
`&'a i16` implements `Add<i16>`
`&'a i32` implements `Add<i32>`
`&'a i64` implements `Add<i64>`
`&f128` implements `Add<f128>`
`&f128` implements `Add`
`&f16` implements `Add<f16>`
`&f16` implements `Add`
`&f32` implements `Add<f32>`
`&f32` implements `Add`
`&f64` implements `Add<f64>`
`&f64` implements `Add`
and 56 others

error[E0277]: cannot add `()` to `{integer}`
Expand All @@ -24,14 +24,14 @@ LL | 1 +
|
= help: the trait `Add<()>` is not implemented for `{integer}`
= help: the following other types implement trait `Add<Rhs>`:
`&'a f128` implements `Add<f128>`
`&'a f16` implements `Add<f16>`
`&'a f32` implements `Add<f32>`
`&'a f64` implements `Add<f64>`
`&'a i128` implements `Add<i128>`
`&'a i16` implements `Add<i16>`
`&'a i32` implements `Add<i32>`
`&'a i64` implements `Add<i64>`
`&f128` implements `Add<f128>`
`&f128` implements `Add`
`&f16` implements `Add<f16>`
`&f16` implements `Add`
`&f32` implements `Add<f32>`
`&f32` implements `Add`
`&f64` implements `Add<f64>`
`&f64` implements `Add`
and 56 others

error: aborting due to 2 previous errors
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/issues/issue-24352.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LL | 1.0f64 - 1
|
= help: the trait `Sub<{integer}>` is not implemented for `f64`
= help: the following other types implement trait `Sub<Rhs>`:
`&'a f64` implements `Sub<f64>`
`&f64` implements `Sub<&f64>`
`&f64` implements `Sub<f64>`
`&f64` implements `Sub`
`f64` implements `Sub<&f64>`
`f64` implements `Sub`
help: consider using a floating-point literal by writing it with `.0`
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/issues/issue-50582.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
|
= help: the trait `Add<()>` is not implemented for `{integer}`
= help: the following other types implement trait `Add<Rhs>`:
`&'a f128` implements `Add<f128>`
`&'a f16` implements `Add<f16>`
`&'a f32` implements `Add<f32>`
`&'a f64` implements `Add<f64>`
`&'a i128` implements `Add<i128>`
`&'a i16` implements `Add<i16>`
`&'a i32` implements `Add<i32>`
`&'a i64` implements `Add<i64>`
`&f128` implements `Add<f128>`
`&f128` implements `Add`
`&f16` implements `Add<f16>`
`&f16` implements `Add`
`&f32` implements `Add<f32>`
`&f32` implements `Add`
`&f64` implements `Add<f64>`
`&f64` implements `Add`
and 56 others

error: aborting due to 2 previous errors
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/iterators/invalid-iterator-chain-fixable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LL | println!("{}", scores.sum::<i32>());
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain-fixable.rs:14:10
Expand Down Expand Up @@ -66,7 +66,7 @@ LL | .sum::<i32>(),
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain-fixable.rs:23:14
Expand Down Expand Up @@ -99,7 +99,7 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain-fixable.rs:27:38
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | let x = Some(()).iter().map(|()| 1).sum::<f32>();
|
= help: the trait `Sum<{integer}>` is not implemented for `f32`
= help: the following other types implement trait `Sum<A>`:
`f32` implements `Sum<&'a f32>`
`f32` implements `Sum<&f32>`
`f32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain-with-int-infer.rs:2:29
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/iterators/invalid-iterator-chain.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LL | println!("{}", scores.sum::<i32>());
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:12:10
Expand Down Expand Up @@ -65,7 +65,7 @@ LL | .sum::<i32>(),
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:25:14
Expand Down Expand Up @@ -104,7 +104,7 @@ LL | .sum::<i32>(),
|
= help: the trait `Sum<f64>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:33:14
Expand Down Expand Up @@ -134,7 +134,7 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:38:38
Expand Down Expand Up @@ -162,7 +162,7 @@ LL | println!("{}", vec![(), ()].iter().sum::<i32>());
|
= help: the trait `Sum<&()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&'a i32>`
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:39:33
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lazy-type-alias/trailing-where-clause.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | let _: Alias<()>;
`String` implements `From<&mut str>`
`String` implements `From<&str>`
`String` implements `From<Box<str>>`
`String` implements `From<Cow<'a, str>>`
`String` implements `From<Cow<'_, str>>`
`String` implements `From<char>`
note: required by a bound in `Alias`
--> $DIR/trailing-where-clause.rs:8:13
Expand Down
Loading