Skip to content

Commit 9998f4a

Browse files
committed
Auto merge of rust-lang#116372 - matthiaskrgr:rollup-ee9oxxa, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#113053 (add notes about non-compliant FP behavior on 32bit x86 targets) - rust-lang#115726 (For a single impl candidate, try to unify it with error trait ref) - rust-lang#116158 (Don't suggest nonsense suggestions for unconstrained type vars in `note_source_of_type_mismatch_constraint`) - rust-lang#116351 (Add `must_use` on pointer equality functions) - rust-lang#116355 (Clarify float rounding direction for signed zero) - rust-lang#116361 (Bump stdarch submodule) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4f75af9 + c3daf77 commit 9998f4a

30 files changed

+236
-62
lines changed

compiler/rustc_hir_typeck/src/demand.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::ty::adjustment::AllowTwoPhase;
1414
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1515
use rustc_middle::ty::fold::BottomUpFolder;
1616
use rustc_middle::ty::print::with_no_trimmed_paths;
17-
use rustc_middle::ty::{self, Article, AssocItem, Ty, TypeAndMut, TypeFoldable};
17+
use rustc_middle::ty::{self, Article, AssocItem, Ty, TypeAndMut, TypeFoldable, TypeVisitableExt};
1818
use rustc_span::symbol::sym;
1919
use rustc_span::{BytePos, Span, DUMMY_SP};
2020
use rustc_trait_selection::infer::InferCtxtExt as _;
@@ -504,12 +504,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
504504
// incompatible fix at the original mismatch site.
505505
if matches!(source, TypeMismatchSource::Ty(_))
506506
&& let Some(ideal_method) = ideal_method
507+
&& let ideal_arg_ty = self.resolve_vars_if_possible(ideal_method.sig.inputs()[idx + 1])
508+
// HACK(compiler-errors): We don't actually consider the implications
509+
// of our inference guesses in `emit_type_mismatch_suggestions`, so
510+
// only suggest things when we know our type error is precisely due to
511+
// a type mismatch, and not via some projection or something. See #116155.
512+
&& !ideal_arg_ty.has_non_region_infer()
507513
{
508514
self.emit_type_mismatch_suggestions(
509515
err,
510516
arg_expr,
511517
arg_ty,
512-
self.resolve_vars_if_possible(ideal_method.sig.inputs()[idx + 1]),
518+
ideal_arg_ty,
513519
None,
514520
None,
515521
);

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+88-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore-tidy-filelength :(
2+
13
mod ambiguity;
24
pub mod on_unimplemented;
35
pub mod suggestions;
@@ -67,6 +69,7 @@ pub enum CandidateSimilarity {
6769
pub struct ImplCandidate<'tcx> {
6870
pub trait_ref: ty::TraitRef<'tcx>,
6971
pub similarity: CandidateSimilarity,
72+
impl_def_id: DefId,
7073
}
7174

7275
enum GetSafeTransmuteErrorAndReason {
@@ -1331,6 +1334,7 @@ trait InferCtxtPrivExt<'tcx> {
13311334
body_def_id: LocalDefId,
13321335
err: &mut Diagnostic,
13331336
other: bool,
1337+
param_env: ty::ParamEnv<'tcx>,
13341338
) -> bool;
13351339

13361340
fn report_similar_impl_candidates_for_root_obligation(
@@ -1918,8 +1922,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
19181922

19191923
let imp = self.tcx.impl_trait_ref(def_id).unwrap().skip_binder();
19201924

1921-
self.fuzzy_match_tys(trait_pred.skip_binder().self_ty(), imp.self_ty(), false)
1922-
.map(|similarity| ImplCandidate { trait_ref: imp, similarity })
1925+
self.fuzzy_match_tys(trait_pred.skip_binder().self_ty(), imp.self_ty(), false).map(
1926+
|similarity| ImplCandidate { trait_ref: imp, similarity, impl_def_id: def_id },
1927+
)
19231928
})
19241929
.collect();
19251930
if candidates.iter().any(|c| matches!(c.similarity, CandidateSimilarity::Exact { .. })) {
@@ -1938,7 +1943,82 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
19381943
body_def_id: LocalDefId,
19391944
err: &mut Diagnostic,
19401945
other: bool,
1946+
param_env: ty::ParamEnv<'tcx>,
19411947
) -> bool {
1948+
// If we have a single implementation, try to unify it with the trait ref
1949+
// that failed. This should uncover a better hint for what *is* implemented.
1950+
if let [single] = &impl_candidates {
1951+
if self.probe(|_| {
1952+
let ocx = ObligationCtxt::new(self);
1953+
let obligation_trait_ref = self.instantiate_binder_with_placeholders(trait_ref);
1954+
let impl_args = self.fresh_args_for_item(DUMMY_SP, single.impl_def_id);
1955+
let impl_trait_ref = ocx.normalize(
1956+
&ObligationCause::dummy(),
1957+
param_env,
1958+
ty::EarlyBinder::bind(single.trait_ref).instantiate(self.tcx, impl_args),
1959+
);
1960+
1961+
ocx.register_obligations(
1962+
self.tcx
1963+
.predicates_of(single.impl_def_id)
1964+
.instantiate(self.tcx, impl_args)
1965+
.into_iter()
1966+
.map(|(clause, _)| {
1967+
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, clause)
1968+
}),
1969+
);
1970+
if !ocx.select_where_possible().is_empty() {
1971+
return false;
1972+
}
1973+
1974+
let mut terrs = vec![];
1975+
for (obligation_arg, impl_arg) in
1976+
std::iter::zip(obligation_trait_ref.args, impl_trait_ref.args)
1977+
{
1978+
if let Err(terr) =
1979+
ocx.eq(&ObligationCause::dummy(), param_env, impl_arg, obligation_arg)
1980+
{
1981+
terrs.push(terr);
1982+
}
1983+
if !ocx.select_where_possible().is_empty() {
1984+
return false;
1985+
}
1986+
}
1987+
1988+
// Literally nothing unified, just give up.
1989+
if terrs.len() == impl_trait_ref.args.len() {
1990+
return false;
1991+
}
1992+
1993+
let cand =
1994+
self.resolve_vars_if_possible(impl_trait_ref).fold_with(&mut BottomUpFolder {
1995+
tcx: self.tcx,
1996+
ty_op: |ty| ty,
1997+
lt_op: |lt| lt,
1998+
ct_op: |ct| ct.normalize(self.tcx, ty::ParamEnv::empty()),
1999+
});
2000+
err.highlighted_help(vec![
2001+
(format!("the trait `{}` ", cand.print_only_trait_path()), Style::NoStyle),
2002+
("is".to_string(), Style::Highlight),
2003+
(" implemented for `".to_string(), Style::NoStyle),
2004+
(cand.self_ty().to_string(), Style::Highlight),
2005+
("`".to_string(), Style::NoStyle),
2006+
]);
2007+
2008+
if let [TypeError::Sorts(exp_found)] = &terrs[..] {
2009+
let exp_found = self.resolve_vars_if_possible(*exp_found);
2010+
err.help(format!(
2011+
"for that trait implementation, expected `{}`, found `{}`",
2012+
exp_found.expected, exp_found.found
2013+
));
2014+
}
2015+
2016+
true
2017+
}) {
2018+
return true;
2019+
}
2020+
}
2021+
19422022
let other = if other { "other " } else { "" };
19432023
let report = |candidates: Vec<TraitRef<'tcx>>, err: &mut Diagnostic| {
19442024
if candidates.is_empty() {
@@ -2062,9 +2142,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
20622142
})
20632143
.collect();
20642144
impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref));
2145+
let mut impl_candidates: Vec<_> =
2146+
impl_candidates.into_iter().map(|cand| cand.trait_ref).collect();
20652147
impl_candidates.dedup();
20662148

2067-
report(impl_candidates.into_iter().map(|cand| cand.trait_ref).collect(), err)
2149+
report(impl_candidates, err)
20682150
}
20692151

20702152
fn report_similar_impl_candidates_for_root_obligation(
@@ -2108,6 +2190,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
21082190
body_def_id,
21092191
err,
21102192
true,
2193+
obligation.param_env,
21112194
);
21122195
}
21132196
}
@@ -2316,6 +2399,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
23162399
obligation.cause.body_id,
23172400
&mut err,
23182401
false,
2402+
obligation.param_env,
23192403
);
23202404
}
23212405
}
@@ -3051,6 +3135,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
30513135
body_def_id,
30523136
err,
30533137
true,
3138+
obligation.param_env,
30543139
) {
30553140
self.report_similar_impl_candidates_for_root_obligation(
30563141
&obligation,

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ pub mod primitive;
418418
// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
419419
// merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
420420
#[allow(clashing_extern_declarations)]
421+
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
421422
#[unstable(feature = "stdsimd", issue = "48556")]
422423
mod core_arch;
423424

library/core/src/primitive_docs.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1142,10 +1142,9 @@ impl<T: Copy> Copy for (T,) {
11421142
/// surprising results upon inspecting the bit patterns,
11431143
/// as the same calculations might produce NaNs with different bit patterns.
11441144
///
1145-
/// When the number resulting from a primitive operation (addition,
1146-
/// subtraction, multiplication, or division) on this type is not exactly
1147-
/// representable as `f32`, it is rounded according to the roundTiesToEven
1148-
/// direction defined in IEEE 754-2008. That means:
1145+
/// When a primitive operation (addition, subtraction, multiplication, or
1146+
/// division) is performed on this type, the result is rounded according to the
1147+
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
11491148
///
11501149
/// - The result is the representable value closest to the true value, if there
11511150
/// is a unique closest representable value.
@@ -1154,6 +1153,9 @@ impl<T: Copy> Copy for (T,) {
11541153
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
11551154
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
11561155
/// true value's sign).
1156+
/// - If the result of a sum exactly equals zero, the outcome is +0.0 unless
1157+
/// both arguments were negative, then it is -0.0. Subtraction `a - b` is
1158+
/// regarded as a sum `a + (-b)`.
11571159
///
11581160
/// For more information on floating point numbers, see [Wikipedia][wikipedia].
11591161
///

library/core/src/ptr/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
18641864
/// ```
18651865
#[stable(feature = "ptr_eq", since = "1.17.0")]
18661866
#[inline(always)]
1867+
#[must_use = "pointer comparison produces a value"]
18671868
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
18681869
a == b
18691870
}
@@ -1886,6 +1887,7 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
18861887
/// ```
18871888
#[unstable(feature = "ptr_addr_eq", issue = "116324")]
18881889
#[inline(always)]
1890+
#[must_use = "pointer comparison produces a value"]
18891891
pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
18901892
(p as *const ()) == (q as *const ())
18911893
}

src/doc/rustc/src/platform-support.md

+26-21
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ All tier 1 targets with host tools support the full standard library.
3333
target | notes
3434
-------|-------
3535
`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.1, glibc 2.17+) [^missing-stack-probes]
36-
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+) [^windows-support]
37-
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+) [^windows-support]
38-
`i686-unknown-linux-gnu` | 32-bit Linux (kernel 3.2+, glibc 2.17+)
36+
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+) [^windows-support] [^x86_32-floats-return-ABI]
37+
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+) [^windows-support] [^x86_32-floats-return-ABI]
38+
`i686-unknown-linux-gnu` | 32-bit Linux (kernel 3.2+, glibc 2.17+) [^x86_32-floats-return-ABI]
3939
`x86_64-apple-darwin` | 64-bit macOS (10.12+, Sierra+)
4040
`x86_64-pc-windows-gnu` | 64-bit MinGW (Windows 7+) [^windows-support]
4141
`x86_64-pc-windows-msvc` | 64-bit MSVC (Windows 7+) [^windows-support]
@@ -47,7 +47,10 @@ target | notes
4747

4848
[^windows-support]: Only Windows 10 currently undergoes automated testing. Earlier versions of Windows rely on testing and support from the community.
4949

50+
[^x86_32-floats-return-ABI]: Due to limitations of the C ABI, floating-point support on `i686` targets is non-compliant: floating-point return values are passed via an x87 register, so NaN payload bits can be lost. See [issue #114479][x86-32-float-issue].
51+
5052
[77071]: https://github.com/rust-lang/rust/issues/77071
53+
[x86-32-float-issue]: https://github.com/rust-lang/rust/issues/114479
5154

5255
## Tier 1
5356

@@ -150,12 +153,12 @@ target | std | notes
150153
`armv7r-none-eabi` | * | Bare ARMv7-R
151154
`armv7r-none-eabihf` | * | Bare ARMv7-R, hardfloat
152155
`asmjs-unknown-emscripten` | ✓ | asm.js via Emscripten
153-
`i586-pc-windows-msvc` | * | 32-bit Windows w/o SSE
154-
`i586-unknown-linux-gnu` | ✓ | 32-bit Linux w/o SSE (kernel 3.2, glibc 2.17)
155-
`i586-unknown-linux-musl` | ✓ | 32-bit Linux w/o SSE, MUSL
156-
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android
157-
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD
158-
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with MUSL
156+
`i586-pc-windows-msvc` | * | 32-bit Windows w/o SSE [^x86_32-floats-x87]
157+
`i586-unknown-linux-gnu` | ✓ | 32-bit Linux w/o SSE (kernel 3.2, glibc 2.17) [^x86_32-floats-x87]
158+
`i586-unknown-linux-musl` | ✓ | 32-bit Linux w/o SSE, MUSL [^x86_32-floats-x87]
159+
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android [^x86_32-floats-return-ABI]
160+
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI]
161+
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with MUSL [^x86_32-floats-return-ABI]
159162
[`i686-unknown-uefi`](platform-support/unknown-uefi.md) | * | 32-bit UEFI
160163
[`loongarch64-unknown-none`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64D ABI)
161164
[`loongarch64-unknown-none-softfloat`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64S ABI)
@@ -195,6 +198,8 @@ target | std | notes
195198
`x86_64-unknown-redox` | ✓ | Redox OS
196199
[`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | * | 64-bit UEFI
197200

201+
[^x86_32-floats-x87]: Floating-point support on `i586` targets is non-compliant: the `x87` registers and instructions used for these targets do not provide IEEE-754-compliant behavior, in particular when it comes to rounding and NaN payload bits. See [issue #114479][x86-32-float-issue].
202+
198203
[Fortanix ABI]: https://edp.fortanix.com/
199204

200205
## Tier 3
@@ -264,18 +269,18 @@ target | std | host | notes
264269
`bpfel-unknown-none` | * | | BPF (little endian)
265270
`csky-unknown-linux-gnuabiv2` | ✓ | | C-SKY abiv2 Linux(little endian)
266271
`hexagon-unknown-linux-musl` | ? | |
267-
`i386-apple-ios` | ✓ | | 32-bit x86 iOS
268-
[`i586-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS |
269-
`i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.12+, Sierra+)
270-
`i686-pc-windows-msvc` | * | | 32-bit Windows XP support
271-
[`i686-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ✓ |
272-
`i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku
273-
[`i686-unknown-hurd-gnu`](platform-support/hurd.md) | ✓ | ✓ | 32-bit GNU/Hurd
274-
[`i686-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 with SSE2
275-
[`i686-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 32-bit OpenBSD
276-
`i686-uwp-windows-gnu` | ? | |
277-
`i686-uwp-windows-msvc` | ? | |
278-
`i686-wrs-vxworks` | ? | |
272+
`i386-apple-ios` | ✓ | | 32-bit x86 iOS [^x86_32-floats-return-ABI]
273+
[`i586-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS [^x86_32-floats-return-ABI]
274+
`i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.12+, Sierra+) [^x86_32-floats-return-ABI]
275+
`i686-pc-windows-msvc` | * | | 32-bit Windows XP support [^x86_32-floats-return-ABI]
276+
[`i686-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ✓ | [^x86_32-floats-return-ABI]
277+
`i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku [^x86_32-floats-return-ABI]
278+
[`i686-unknown-hurd-gnu`](platform-support/hurd.md) | ✓ | ✓ | 32-bit GNU/Hurd [^x86_32-floats-return-ABI]
279+
[`i686-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 with SSE2 [^x86_32-floats-return-ABI]
280+
[`i686-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 32-bit OpenBSD [^x86_32-floats-return-ABI]
281+
`i686-uwp-windows-gnu` | ? | | [^x86_32-floats-return-ABI]
282+
`i686-uwp-windows-msvc` | ? | | [^x86_32-floats-return-ABI]
283+
`i686-wrs-vxworks` | ? | | [^x86_32-floats-return-ABI]
279284
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
280285
`mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc
281286
[`mips64-openwrt-linux-musl`](platform-support/mips64-openwrt-linux-musl.md) | ? | | MIPS64 for OpenWrt Linux MUSL

tests/ui/const-generics/occurs-check/unused-substs-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `A<_>: Bar<_>` is not satisfied
44
LL | let _ = A;
55
| ^ the trait `Bar<_>` is not implemented for `A<_>`
66
|
7-
= help: the trait `Bar<N>` is implemented for `A<7>`
7+
= help: the trait `Bar<_>` is implemented for `A<7>`
88
note: required by a bound in `A`
99
--> $DIR/unused-substs-1.rs:9:11
1010
|

tests/ui/generic-const-items/unsatisfied-bounds.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ LL | let () = K::<()>;
1717
| ^^ the trait `From<()>` is not implemented for `Infallible`
1818
|
1919
= help: the trait `From<!>` is implemented for `Infallible`
20+
= help: for that trait implementation, expected `!`, found `()`
2021
note: required by a bound in `K`
2122
--> $DIR/unsatisfied-bounds.rs:12:17
2223
|
@@ -48,6 +49,7 @@ LL | let _ = <() as Trait<&'static str>>::B::<()>;
4849
| ^^ the trait `From<()>` is not implemented for `Infallible`
4950
|
5051
= help: the trait `From<!>` is implemented for `Infallible`
52+
= help: for that trait implementation, expected `!`, found `()`
5153
note: required by a bound in `Trait::B`
5254
--> $DIR/unsatisfied-bounds.rs:21:21
5355
|

tests/ui/impl-trait/issues/issue-62742.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
44
LL | WrongImpl::foo(0i32);
55
| ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
66
|
7-
= help: the trait `Raw<[T]>` is implemented for `RawImpl<T>`
7+
= help: the trait `Raw<[_]>` is implemented for `RawImpl<_>`
88
note: required by a bound in `SafeImpl`
99
--> $DIR/issue-62742.rs:26:35
1010
|
@@ -42,7 +42,8 @@ error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
4242
LL | WrongImpl::<()>::foo(0i32);
4343
| ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
4444
|
45-
= help: the trait `Raw<[T]>` is implemented for `RawImpl<T>`
45+
= help: the trait `Raw<[()]>` is implemented for `RawImpl<()>`
46+
= help: for that trait implementation, expected `[()]`, found `()`
4647
note: required by a bound in `SafeImpl`
4748
--> $DIR/issue-62742.rs:26:35
4849
|

tests/ui/indexing/index-help.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ LL | x[0i32];
55
| ^^^^ slice indices are of type `usize` or ranges of `usize`
66
|
77
= help: the trait `SliceIndex<[{integer}]>` is not implemented for `i32`
8-
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
8+
= help: the trait `SliceIndex<[{integer}]>` is implemented for `usize`
9+
= help: for that trait implementation, expected `usize`, found `i32`
910
= note: required for `Vec<{integer}>` to implement `Index<i32>`
1011

1112
error: aborting due to previous error

tests/ui/indexing/indexing-requires-a-uint.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ LL | [0][0u8];
55
| ^^^ slice indices are of type `usize` or ranges of `usize`
66
|
77
= help: the trait `SliceIndex<[{integer}]>` is not implemented for `u8`
8-
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
8+
= help: the trait `SliceIndex<[{integer}]>` is implemented for `usize`
9+
= help: for that trait implementation, expected `usize`, found `u8`
910
= note: required for `[{integer}]` to implement `Index<u8>`
1011

1112
error[E0308]: mismatched types

0 commit comments

Comments
 (0)