From d5bd4e233d2bb4415138e384e66379eedbc7e76e Mon Sep 17 00:00:00 2001 From: Boxy Date: Wed, 29 May 2024 17:06:50 +0100 Subject: [PATCH] Partially implement `ConstArgHasType` --- .../rustc_infer/src/infer/relate/combine.rs | 9 +- .../rustc_trait_selection/src/solve/mod.rs | 26 +++- .../error_reporting/type_err_ctxt_ext.rs | 16 +++ .../src/traits/fulfill.rs | 41 ++++-- .../src/traits/select/mod.rs | 19 ++- .../121858.rs} | 7 +- tests/crashes/122638.rs | 12 -- tests/crashes/123141-2.rs | 23 ---- tests/crashes/123141.rs | 27 ++-- .../generic_const_type_mismatch.rs | 1 + .../generic_const_type_mismatch.stderr | 14 +- .../alias_const_param_ty-1.rs} | 4 +- .../alias_const_param_ty-1.stderr | 19 +++ .../alias_const_param_ty-2.rs} | 11 +- .../alias_const_param_ty-2.stderr | 11 ++ .../ui/const-generics/bad-subst-const-kind.rs | 6 +- .../bad-subst-const-kind.stderr | 17 ++- .../const-generics/defaults/doesnt_infer.rs | 4 +- .../defaults/doesnt_infer.stderr | 2 +- .../generic_arg_infer/issue-91614.rs | 2 +- ...-125520-layout-mismatch-mulwithoverflow.rs | 27 ---- ...520-layout-mismatch-mulwithoverflow.stderr | 125 ------------------ .../generic_const_exprs/type_mismatch.rs | 2 +- .../generic_const_exprs/type_mismatch.stderr | 14 +- .../ui/const-generics/issues/issue-105821.rs | 11 +- .../const-generics/issues/issue-105821.stderr | 8 -- tests/ui/consts/eval_type_mismatch.stderr | 34 ----- tests/ui/inference/issue-83606.rs | 2 +- .../bad-const-wf-doesnt-specialize.rs | 3 +- .../bad-const-wf-doesnt-specialize.stderr | 36 ++--- 30 files changed, 206 insertions(+), 327 deletions(-) rename tests/{ui/consts/eval_type_mismatch.rs => crashes/121858.rs} (53%) delete mode 100644 tests/crashes/122638.rs delete mode 100644 tests/crashes/123141-2.rs rename tests/{crashes/114456.rs => ui/const-generics/adt_const_params/alias_const_param_ty-1.rs} (69%) create mode 100644 tests/ui/const-generics/adt_const_params/alias_const_param_ty-1.stderr rename tests/{crashes/114456-2.rs => ui/const-generics/adt_const_params/alias_const_param_ty-2.rs} (64%) create mode 100644 tests/ui/const-generics/adt_const_params/alias_const_param_ty-2.stderr delete mode 100644 tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs delete mode 100644 tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr delete mode 100644 tests/ui/const-generics/issues/issue-105821.stderr delete mode 100644 tests/ui/consts/eval_type_mismatch.stderr diff --git a/compiler/rustc_infer/src/infer/relate/combine.rs b/compiler/rustc_infer/src/infer/relate/combine.rs index 7e7d4f43c7c..e721c36dec3 100644 --- a/compiler/rustc_infer/src/infer/relate/combine.rs +++ b/compiler/rustc_infer/src/infer/relate/combine.rs @@ -22,11 +22,10 @@ use super::lub::Lub; use super::type_relating::TypeRelating; use super::StructurallyRelateAliases; -use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, TypeTrace}; +use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace}; use crate::traits::{Obligation, PredicateObligations}; use rustc_middle::bug; use rustc_middle::infer::unify_key::EffectVarValue; -use rustc_middle::traits::ObligationCause; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::relate::{RelateResult, TypeRelation}; use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeVisitableExt, Upcast}; @@ -159,12 +158,6 @@ pub fn super_combine_consts( let a = self.shallow_resolve_const(a); let b = self.shallow_resolve_const(b); - // It is always an error if the types of two constants that are related are not equal. - let InferOk { value: (), obligations } = self - .at(&ObligationCause::dummy_with_span(relation.span()), relation.param_env()) - .eq(DefineOpaqueTypes::No, a.ty(), b.ty())?; - relation.register_obligations(obligations); - match (a.kind(), b.kind()) { ( ty::ConstKind::Infer(InferConst::Var(a_vid)), diff --git a/compiler/rustc_trait_selection/src/solve/mod.rs b/compiler/rustc_trait_selection/src/solve/mod.rs index a432090f78c..f9febd290fe 100644 --- a/compiler/rustc_trait_selection/src/solve/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/mod.rs @@ -197,8 +197,30 @@ fn compute_const_arg_has_type_goal( goal: Goal<'tcx, (ty::Const<'tcx>, Ty<'tcx>)>, ) -> QueryResult<'tcx> { let (ct, ty) = goal.predicate; - self.eq(goal.param_env, ct.ty(), ty)?; - self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) + + // FIXME(BoxyUwU): Really we should not be calling `ct.ty()` for any variant + // other than `ConstKind::Value`. Unfortunately this would require looking in the + // env for any `ConstArgHasType` assumptions for parameters and placeholders. I + // have not yet gotten around to implementing this though. + // + // We do still stall on infer vars though as otherwise a goal like: + // `ConstArgHasType(?x: usize, usize)` can succeed even though it might later + // get unified with some const that is not of type `usize`. + match ct.kind() { + // FIXME: Ignore effect vars because canonicalization doesn't handle them correctly + // and if we stall on the var then we wind up creating ambiguity errors in a probe + // for this goal which contains an effect var. Which then ends up ICEing. + ty::ConstKind::Infer(ty::InferConst::Var(_)) => { + self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS) + } + ty::ConstKind::Error(_) => { + self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) + } + _ => { + self.eq(goal.param_env, ct.ty(), ty)?; + self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) + } + } } } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 46953a61296..7f995b315f7 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -2685,6 +2685,22 @@ fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>) -> Erro .with_span_label(span, format!("cannot satisfy `{predicate}`")) } } + + // Given some `ConstArgHasType(?x, usize)`, we should not emit an error such as + // "type annotations needed: cannot satisfy the constant `_` has type `usize`" + // Instead we should emit a normal error suggesting the user to turbofish the + // const parameter that is currently being inferred. Unfortunately we cannot + // nicely emit such an error so we delay an ICE incase nobody else reports it + // for us. + ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => { + return self.tcx.sess.dcx().span_delayed_bug( + span, + format!( + "`ambiguous ConstArgHasType({:?}, {:?}) unaccompanied by inference error`", + ct, ty + ), + ); + } _ => { if let Some(e) = self.tainted_by_errors() { return e; diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 07fcf109fda..c64d1be751c 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -429,16 +429,37 @@ fn process_obligation( // This is because this is not ever a useful obligation to report // as the cause of an overflow. ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => { - match self.selcx.infcx.at(&obligation.cause, obligation.param_env).eq( - // Only really excercised by generic_const_exprs - DefineOpaqueTypes::Yes, - ct.ty(), - ty, - ) { - Ok(inf_ok) => ProcessResult::Changed(mk_pending(inf_ok.into_obligations())), - Err(_) => ProcessResult::Error(FulfillmentErrorCode::Select( - SelectionError::Unimplemented, - )), + // FIXME(BoxyUwU): Really we should not be calling `ct.ty()` for any variant + // other than `ConstKind::Value`. Unfortunately this would require looking in the + // env for any `ConstArgHasType` assumptions for parameters and placeholders. I + // don't really want to implement this in the old solver so I haven't. + // + // We do still stall on infer vars though as otherwise a goal like: + // `ConstArgHasType(?x: usize, usize)` can succeed even though it might later + // get unified with some const that is not of type `usize`. + let ct = self.selcx.infcx.shallow_resolve_const(ct); + match ct.kind() { + ty::ConstKind::Infer(ty::InferConst::Var(vid)) => { + pending_obligation.stalled_on.clear(); + pending_obligation.stalled_on.extend([TyOrConstInferVar::Const(vid)]); + ProcessResult::Unchanged + } + ty::ConstKind::Error(_) => return ProcessResult::Changed(vec![]), + _ => { + match self.selcx.infcx.at(&obligation.cause, obligation.param_env).eq( + // Only really excercised by generic_const_exprs + DefineOpaqueTypes::Yes, + ct.ty(), + ty, + ) { + Ok(inf_ok) => { + ProcessResult::Changed(mk_pending(inf_ok.into_obligations())) + } + Err(_) => ProcessResult::Error(FulfillmentErrorCode::Select( + SelectionError::Unimplemented, + )), + } + } } } diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 696b1c15115..1f53e8cc671 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -992,10 +992,27 @@ fn evaluate_predicate_recursively<'o>( } ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig), ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => { + // FIXME(BoxyUwU): Really we should not be calling `ct.ty()` for any variant + // other than `ConstKind::Value`. Unfortunately this would require looking in the + // env for any `ConstArgHasType` assumptions for parameters and placeholders. I + // don't really want to implement this in the old solver so I haven't. + // + // We do still stall on infer vars though as otherwise a goal like: + // `ConstArgHasType(?x: usize, usize)` can succeed even though it might later + // get unified with some const that is not of type `usize`. + let ct = self.infcx.shallow_resolve_const(ct); + let ct_ty = match ct.kind() { + ty::ConstKind::Infer(ty::InferConst::Var(_)) => { + return Ok(EvaluatedToAmbig); + } + ty::ConstKind::Error(_) => return Ok(EvaluatedToOk), + _ => ct.ty(), + }; + match self.infcx.at(&obligation.cause, obligation.param_env).eq( // Only really excercised by generic_const_exprs DefineOpaqueTypes::Yes, - ct.ty(), + ct_ty, ty, ) { Ok(inf_ok) => self.evaluate_predicates_recursively( diff --git a/tests/ui/consts/eval_type_mismatch.rs b/tests/crashes/121858.rs similarity index 53% rename from tests/ui/consts/eval_type_mismatch.rs rename to tests/crashes/121858.rs index 3d821ab538e..7d5bae37f84 100644 --- a/tests/ui/consts/eval_type_mismatch.rs +++ b/tests/crashes/121858.rs @@ -1,17 +1,14 @@ +//@ known-bug: #121858 #![feature(generic_const_exprs)] -#![allow(incomplete_features)] struct Outer(); impl Outer -//~^ ERROR: `A` is not of type `i64` -//~| ERROR: mismatched types where [(); A + (B * 2)]:, { - fn o() {} + fn o() -> Union {} } fn main() { Outer::<1, 1>::o(); - //~^ ERROR: no function or associated item named `o` found } diff --git a/tests/crashes/122638.rs b/tests/crashes/122638.rs deleted file mode 100644 index af0fc5bbd50..00000000000 --- a/tests/crashes/122638.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ known-bug: #122638 -#![feature(min_specialization)] - -impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> { - fn next(&mut self) -> Option {} -} - -struct ConstChunksExact<'a, T: '_, const assert: usize> {} - -impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { - type Item = &'a [T; N]; -} diff --git a/tests/crashes/123141-2.rs b/tests/crashes/123141-2.rs deleted file mode 100644 index 74f961c2a33..00000000000 --- a/tests/crashes/123141-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ known-bug: #123141 - -trait ConstChunksExactTrait { - fn const_chunks_exact(&self) -> ConstChunksExact<'_, T, {N}>; -} - -impl ConstChunksExactTrait for [T] {} - -struct ConstChunksExact<'a, T: 'a, const N: usize> {} - -impl <'a, T: , const N: usize> Iterator for ConstChunksExact<'a, T, {rem}> { - type Item = &'a [T; N]; -} - -fn main() { - let slice = &[1i32, 2, 3, 4, 5, 6, 7, 7, 9, 1i32]; - - let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8 ,9]].iter(); - - for a in slice.const_chunks_exact::<3>() { - assert_eq!(a, iter.next().unwrap()); - } -} diff --git a/tests/crashes/123141.rs b/tests/crashes/123141.rs index 99dfee7670e..07181387e04 100644 --- a/tests/crashes/123141.rs +++ b/tests/crashes/123141.rs @@ -1,22 +1,23 @@ //@ known-bug: #123141 -trait ConstChunksExactTrait { - fn const_chunks_exact(&self) -> ConstChunksExact<'_, T, { N }>; + +trait Trait { + fn next(self) -> Self::Item; + type Item; } -impl ConstChunksExactTrait for [T] {} +struct Foo(T); -struct ConstChunksExact<'a, T: 'a, const N: usize> {} +impl Trait for Foo { + type Item = Foo; + fn next(self) -> Self::Item { + loop {} + } +} -impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, { rem }> { - type Item = &'a [T; N]; +fn opaque() -> impl Trait { + Foo::<_>(10_u32) } fn main() { - let slice = &[1i32, 2, 3, 4, 5, 6, 7, 7, 9, 1i32]; - - let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].iter(); - - for a in slice.const_chunks_exact::<3>() { - assert_eq!(a, iter.next().unwrap()); - } + opaque().next(); } diff --git a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs index 89d0b74d403..fa0b0fdc136 100644 --- a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs +++ b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs @@ -8,5 +8,6 @@ trait Trait {} //~^ ERROR: mismatched types impl Trait for [(); N] {} //~^ ERROR: mismatched types +//~| ERROR: conflicting implementations of trait `Trait` fn main() {} diff --git a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr index d1950254660..d65450845bc 100644 --- a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr +++ b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr @@ -1,3 +1,12 @@ +error[E0119]: conflicting implementations of trait `Trait` for type `[(); _]` + --> $DIR/generic_const_type_mismatch.rs:9:1 + | +LL | impl Trait for [(); N] {} + | ----------------------------------- first implementation here +LL | +LL | impl Trait for [(); N] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); _]` + error[E0308]: mismatched types --> $DIR/generic_const_type_mismatch.rs:7:34 | @@ -10,6 +19,7 @@ error[E0308]: mismatched types LL | impl Trait for [(); N] {} | ^ expected `usize`, found `i8` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0119, E0308. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/crashes/114456.rs b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-1.rs similarity index 69% rename from tests/crashes/114456.rs rename to tests/ui/const-generics/adt_const_params/alias_const_param_ty-1.rs index e347327e738..8035fce0914 100644 --- a/tests/crashes/114456.rs +++ b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-1.rs @@ -1,5 +1,7 @@ -//@ known-bug: #114456 +//@ check-pass #![feature(adt_const_params, lazy_type_alias)] +//~^ WARN: the feature `adt_const_params` is incomplete +//~| WARN: the feature `lazy_type_alias` is incomplete pub type Matrix = [usize; 1]; const EMPTY_MATRIX: Matrix = [0; 1]; diff --git a/tests/ui/const-generics/adt_const_params/alias_const_param_ty-1.stderr b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-1.stderr new file mode 100644 index 00000000000..5c6981077b2 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-1.stderr @@ -0,0 +1,19 @@ +warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/alias_const_param_ty-1.rs:2:12 + | +LL | #![feature(adt_const_params, lazy_type_alias)] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #95174 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/alias_const_param_ty-1.rs:2:30 + | +LL | #![feature(adt_const_params, lazy_type_alias)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112792 for more information + +warning: 2 warnings emitted + diff --git a/tests/crashes/114456-2.rs b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-2.rs similarity index 64% rename from tests/crashes/114456-2.rs rename to tests/ui/const-generics/adt_const_params/alias_const_param_ty-2.rs index eca27febb96..a576b75341c 100644 --- a/tests/crashes/114456-2.rs +++ b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-2.rs @@ -1,5 +1,6 @@ -//@ known-bug: #114456 +//@ check-pass #![feature(adt_const_params)] +//~^ WARN: the feature `adt_const_params` is incomplete const EMPTY_MATRIX: ::Matrix = [0; 1]; @@ -12,8 +13,12 @@ pub const fn new() -> Self { } pub enum Type {} -pub trait Trait { type Matrix; } -impl Trait for Type { type Matrix = [usize; 1]; } +pub trait Trait { + type Matrix; +} +impl Trait for Type { + type Matrix = [usize; 1]; +} fn main() { let _ = Walk::new(); diff --git a/tests/ui/const-generics/adt_const_params/alias_const_param_ty-2.stderr b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-2.stderr new file mode 100644 index 00000000000..dbc8ab71636 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/alias_const_param_ty-2.stderr @@ -0,0 +1,11 @@ +warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/alias_const_param_ty-2.rs:2:12 + | +LL | #![feature(adt_const_params)] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #95174 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/const-generics/bad-subst-const-kind.rs b/tests/ui/const-generics/bad-subst-const-kind.rs index 88f98a54b6e..d5913879191 100644 --- a/tests/ui/const-generics/bad-subst-const-kind.rs +++ b/tests/ui/const-generics/bad-subst-const-kind.rs @@ -10,5 +10,7 @@ trait Q { const ASSOC: usize = 1; } -pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] { todo!() } -//~^ ERROR: `[u8; 13]: Q` is not satisfied +pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] { + //~^ ERROR: the constant `13` is not of type `u64` + todo!() +} diff --git a/tests/ui/const-generics/bad-subst-const-kind.stderr b/tests/ui/const-generics/bad-subst-const-kind.stderr index 6cf9fa743b3..6725f6762e4 100644 --- a/tests/ui/const-generics/bad-subst-const-kind.stderr +++ b/tests/ui/const-generics/bad-subst-const-kind.stderr @@ -1,10 +1,16 @@ -error[E0277]: the trait bound `[u8; 13]: Q` is not satisfied +error: the constant `13` is not of type `u64` --> $DIR/bad-subst-const-kind.rs:13:24 | -LL | pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] { todo!() } - | ^^^^^^^^ the trait `Q` is not implemented for `[u8; 13]` +LL | pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] { + | ^^^^^^^^ expected `u64`, found `usize` | - = help: the trait `Q` is implemented for `[u8; N]` +note: required for `[u8; 13]` to implement `Q` + --> $DIR/bad-subst-const-kind.rs:8:20 + | +LL | impl Q for [u8; N] { + | ------------ ^ ^^^^^^^ + | | + | unsatisfied trait bound introduced here error[E0308]: mismatched types --> $DIR/bad-subst-const-kind.rs:8:31 @@ -14,5 +20,4 @@ LL | impl Q for [u8; N] { error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/defaults/doesnt_infer.rs b/tests/ui/const-generics/defaults/doesnt_infer.rs index e14c08fc148..016685eee9d 100644 --- a/tests/ui/const-generics/defaults/doesnt_infer.rs +++ b/tests/ui/const-generics/defaults/doesnt_infer.rs @@ -3,7 +3,9 @@ struct Foo; impl Foo { - fn foo() -> Self { loop {} } + fn foo() -> Self { + loop {} + } } fn main() { diff --git a/tests/ui/const-generics/defaults/doesnt_infer.stderr b/tests/ui/const-generics/defaults/doesnt_infer.stderr index 93d58603397..1e779f75ce0 100644 --- a/tests/ui/const-generics/defaults/doesnt_infer.stderr +++ b/tests/ui/const-generics/defaults/doesnt_infer.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed for `Foo<_>` - --> $DIR/doesnt_infer.rs:11:9 + --> $DIR/doesnt_infer.rs:13:9 | LL | let foo = Foo::foo(); | ^^^ diff --git a/tests/ui/const-generics/generic_arg_infer/issue-91614.rs b/tests/ui/const-generics/generic_arg_infer/issue-91614.rs index b45e2cbc737..cfbc5faecd9 100644 --- a/tests/ui/const-generics/generic_arg_infer/issue-91614.rs +++ b/tests/ui/const-generics/generic_arg_infer/issue-91614.rs @@ -4,5 +4,5 @@ fn main() { let y = Mask::<_, _>::splat(false); - //~^ ERROR: type annotations needed for + //~^ ERROR: type annotations needed } diff --git a/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs b/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs deleted file mode 100644 index cd2dc3f4fe8..00000000000 --- a/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs +++ /dev/null @@ -1,27 +0,0 @@ -// issue: rust-lang/rust#125520 -#![feature(generic_const_exprs)] -//~^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes - -struct Outer(); -impl Outer -//~^ ERROR the constant `A` is not of type `i64` -//~| ERROR the constant `B` is not of type `i64` -//~| ERROR mismatched types -//~| ERROR mismatched types -where - [(); A + (B * 2)]:, -{ - fn i() -> Self { - //~^ ERROR the constant `A` is not of type `i64` - //~| ERROR the constant `B` is not of type `i64` - Self - //~^ ERROR mismatched types - //~| ERROR the constant `A` is not of type `i64` - //~| ERROR the constant `B` is not of type `i64` - } -} - -fn main() { - Outer::<1, 1>::o(); - //~^ ERROR no function or associated item named `o` found for struct `Outer` in the current scope -} diff --git a/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr b/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr deleted file mode 100644 index 2dbd69fd3bc..00000000000 --- a/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr +++ /dev/null @@ -1,125 +0,0 @@ -warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:2:12 - | -LL | #![feature(generic_const_exprs)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #76560 for more information - = note: `#[warn(incomplete_features)]` on by default - -error: the constant `A` is not of type `i64` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:38 - | -LL | impl Outer - | ^^^^^^^^^^^ expected `i64`, found `usize` - | -note: required by a bound in `Outer` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:14 - | -LL | struct Outer(); - | ^^^^^^^^^^^^ required by this bound in `Outer` - -error: the constant `B` is not of type `i64` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:38 - | -LL | impl Outer - | ^^^^^^^^^^^ expected `i64`, found `usize` - | -note: required by a bound in `Outer` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:28 - | -LL | struct Outer(); - | ^^^^^^^^^^^^ required by this bound in `Outer` - -error: the constant `A` is not of type `i64` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:14:15 - | -LL | fn i() -> Self { - | ^^^^ expected `i64`, found `usize` - | -note: required by a bound in `Outer` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:14 - | -LL | struct Outer(); - | ^^^^^^^^^^^^ required by this bound in `Outer` - -error: the constant `B` is not of type `i64` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:14:15 - | -LL | fn i() -> Self { - | ^^^^ expected `i64`, found `usize` - | -note: required by a bound in `Outer` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:28 - | -LL | struct Outer(); - | ^^^^^^^^^^^^ required by this bound in `Outer` - -error[E0308]: mismatched types - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:17:9 - | -LL | struct Outer(); - | ---------------------------------------- `Outer` defines a struct constructor here, which should be called -... -LL | fn i() -> Self { - | ---- expected `Outer` because of return type -... -LL | Self - | ^^^^ expected `Outer`, found struct constructor - | - = note: expected struct `Outer` - found struct constructor `fn() -> Outer {Outer::}` -help: use parentheses to construct this tuple struct - | -LL | Self() - | ++ - -error: the constant `A` is not of type `i64` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:17:9 - | -LL | Self - | ^^^^ expected `i64`, found `usize` - | -note: required by a bound in `Outer` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:14 - | -LL | struct Outer(); - | ^^^^^^^^^^^^ required by this bound in `Outer` - -error: the constant `B` is not of type `i64` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:17:9 - | -LL | Self - | ^^^^ expected `i64`, found `usize` - | -note: required by a bound in `Outer` - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:28 - | -LL | struct Outer(); - | ^^^^^^^^^^^^ required by this bound in `Outer` - -error[E0599]: no function or associated item named `o` found for struct `Outer` in the current scope - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:25:20 - | -LL | struct Outer(); - | ---------------------------------------- function or associated item `o` not found for this struct -... -LL | Outer::<1, 1>::o(); - | ^ function or associated item not found in `Outer<1, 1>` - -error[E0308]: mismatched types - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:44 - | -LL | impl Outer - | ^ expected `i64`, found `usize` - -error[E0308]: mismatched types - --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:47 - | -LL | impl Outer - | ^ expected `i64`, found `usize` - -error: aborting due to 10 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0308, E0599. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs b/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs index 285f9dee6c2..6b0d9e047db 100644 --- a/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs +++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs @@ -10,7 +10,7 @@ trait Q { //~| ERROR mismatched types pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} -//~^ ERROR `[u8; 13]: Q` is not satisfied +//~^ ERROR the constant `13` is not of type `u64` //~| ERROR mismatched types pub fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr index a63a56dd675..bb6d650b7ab 100644 --- a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr +++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr @@ -7,13 +7,19 @@ LL | const ASSOC: usize; LL | impl Q for [u8; N] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation -error[E0277]: the trait bound `[u8; 13]: Q` is not satisfied +error: the constant `13` is not of type `u64` --> $DIR/type_mismatch.rs:12:26 | LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} - | ^^^^^^^^ the trait `Q` is not implemented for `[u8; 13]` + | ^^^^^^^^ expected `u64`, found `usize` | - = help: the trait `Q` is implemented for `[u8; N]` +note: required for `[u8; 13]` to implement `Q` + --> $DIR/type_mismatch.rs:8:20 + | +LL | impl Q for [u8; N] {} + | ------------ ^ ^^^^^^^ + | | + | unsatisfied trait bound introduced here error[E0308]: mismatched types --> $DIR/type_mismatch.rs:12:20 @@ -31,5 +37,5 @@ LL | impl Q for [u8; N] {} error: aborting due to 4 previous errors -Some errors have detailed explanations: E0046, E0277, E0308. +Some errors have detailed explanations: E0046, E0308. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/issues/issue-105821.rs b/tests/ui/const-generics/issues/issue-105821.rs index e55da461605..ecbae4d9f35 100644 --- a/tests/ui/const-generics/issues/issue-105821.rs +++ b/tests/ui/const-generics/issues/issue-105821.rs @@ -1,10 +1,7 @@ -//@ failure-status: 101 -//@ known-bug: rust-lang/rust#125451 -//@ normalize-stderr-test "note: .*\n\n" -> "" -//@ normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> "" -//@ normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -//@ normalize-stderr-test "delayed at .*" -> "" -//@ rustc-env:RUST_BACKTRACE=0 +//@ check-pass +// If this test starts failing because it ICEs due to not being able to convert a `ReErased` to +// something then feel free to just convert this to a known-bug. I'm pretty sure this is still +// a failing test, we just started masking the bug. #![allow(incomplete_features)] #![feature(adt_const_params, generic_const_exprs)] diff --git a/tests/ui/const-generics/issues/issue-105821.stderr b/tests/ui/const-generics/issues/issue-105821.stderr deleted file mode 100644 index 1f0fc0f33ce..00000000000 --- a/tests/ui/const-generics/issues/issue-105821.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: internal compiler error: compiler/rustc_borrowck/src/universal_regions.rs:LL:CC: cannot convert `'{erased}` to a region vid - -query stack during panic: -#0 [mir_borrowck] borrow-checking `::R` -#1 [analysis] running analysis passes on this crate -end of query stack -error: aborting due to 1 previous error - diff --git a/tests/ui/consts/eval_type_mismatch.stderr b/tests/ui/consts/eval_type_mismatch.stderr deleted file mode 100644 index 38d6e33d406..00000000000 --- a/tests/ui/consts/eval_type_mismatch.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error: the constant `A` is not of type `i64` - --> $DIR/eval_type_mismatch.rs:5:38 - | -LL | impl Outer - | ^^^^^^^^^^^ expected `i64`, found `usize` - | -note: required by a bound in `Outer` - --> $DIR/eval_type_mismatch.rs:4:14 - | -LL | struct Outer(); - | ^^^^^^^^^^^^ required by this bound in `Outer` - -error[E0599]: no function or associated item named `o` found for struct `Outer<1, 1>` in the current scope - --> $DIR/eval_type_mismatch.rs:15:20 - | -LL | struct Outer(); - | ------------------------------------------ function or associated item `o` not found for this struct -... -LL | Outer::<1, 1>::o(); - | ^ function or associated item not found in `Outer<1, 1>` - | - = note: the function or associated item was found for - - `Outer` - -error[E0308]: mismatched types - --> $DIR/eval_type_mismatch.rs:5:44 - | -LL | impl Outer - | ^ expected `i64`, found `usize` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0308, E0599. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/inference/issue-83606.rs b/tests/ui/inference/issue-83606.rs index 4454b5e60f0..e6e291c3a92 100644 --- a/tests/ui/inference/issue-83606.rs +++ b/tests/ui/inference/issue-83606.rs @@ -6,5 +6,5 @@ fn main() { let _ = foo("foo"); - //~^ ERROR type annotations needed for `[usize; _]` + //~^ ERROR type annotations needed } diff --git a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs index 4d1cd4332fe..f89a463bc58 100644 --- a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs +++ b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs @@ -7,8 +7,7 @@ impl Copy for S {} //~^ ERROR: mismatched types -//~| ERROR: the trait bound `S: Clone` is not satisfied -//~| ERROR: the constant `N` is not of type `usize` impl Copy for S {} +//~^ ERROR: conflicting implementations of trait `Copy` for type `S<_>` fn main() {} diff --git a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr index 716a4787948..1dac58e1f69 100644 --- a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr +++ b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr @@ -1,29 +1,11 @@ -error[E0277]: the trait bound `S: Clone` is not satisfied - --> $DIR/bad-const-wf-doesnt-specialize.rs:8:29 +error[E0119]: conflicting implementations of trait `Copy` for type `S<_>` + --> $DIR/bad-const-wf-doesnt-specialize.rs:10:1 | LL | impl Copy for S {} - | ^^^^ the trait `Clone` is not implemented for `S` - | - = help: the trait `Clone` is implemented for `S` -note: required by a bound in `Copy` - --> $SRC_DIR/core/src/marker.rs:LL:COL -help: consider annotating `S` with `#[derive(Clone)]` - | -LL + #[derive(Clone)] -LL | struct S; - | - -error: the constant `N` is not of type `usize` - --> $DIR/bad-const-wf-doesnt-specialize.rs:8:29 - | -LL | impl Copy for S {} - | ^^^^ expected `usize`, found `i32` - | -note: required by a bound in `S` - --> $DIR/bad-const-wf-doesnt-specialize.rs:6:10 - | -LL | struct S; - | ^^^^^^^^^^^^^^ required by this bound in `S` + | -------------------------------- first implementation here +LL | +LL | impl Copy for S {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S<_>` error[E0308]: mismatched types --> $DIR/bad-const-wf-doesnt-specialize.rs:8:31 @@ -31,7 +13,7 @@ error[E0308]: mismatched types LL | impl Copy for S {} | ^ expected `usize`, found `i32` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0119, E0308. +For more information about an error, try `rustc --explain E0119`.