Rollup merge of #81309 - lcnr:lazy-norm-err-msgh, r=nikomatsakis
always eagerly eval consts in Relate r? ```@nikomatsakis``` cc ```@varkor```
This commit is contained in:
commit
49bf48a33d
4 changed files with 11 additions and 7 deletions
|
@ -421,12 +421,14 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
|
||||||
let t = relation.relate(a_t, b_t)?;
|
let t = relation.relate(a_t, b_t)?;
|
||||||
match relation.relate(sz_a, sz_b) {
|
match relation.relate(sz_a, sz_b) {
|
||||||
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
|
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
|
||||||
// FIXME(#72219) Implement improved diagnostics for mismatched array
|
|
||||||
// length?
|
|
||||||
Err(err) if relation.tcx().lazy_normalization() => Err(err),
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Check whether the lengths are both concrete/known values,
|
// Check whether the lengths are both concrete/known values,
|
||||||
// but are unequal, for better diagnostics.
|
// but are unequal, for better diagnostics.
|
||||||
|
//
|
||||||
|
// It might seem dubious to eagerly evaluate these constants here,
|
||||||
|
// we however cannot end up with errors in `Relate` during both
|
||||||
|
// `type_of` and `predicates_of`. This means that evaluating the
|
||||||
|
// constants should not cause cycle errors here.
|
||||||
let sz_a = sz_a.try_eval_usize(tcx, relation.param_env());
|
let sz_a = sz_a.try_eval_usize(tcx, relation.param_env());
|
||||||
let sz_b = sz_b.try_eval_usize(tcx, relation.param_env());
|
let sz_b = sz_b.try_eval_usize(tcx, relation.param_env());
|
||||||
match (sz_a, sz_b) {
|
match (sz_a, sz_b) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-argument-cross-crate-mismatch.rs:7:67
|
--> $DIR/const-argument-cross-crate-mismatch.rs:9:67
|
||||||
|
|
|
|
||||||
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
||||||
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
|
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-argument-cross-crate-mismatch.rs:9:65
|
--> $DIR/const-argument-cross-crate-mismatch.rs:11:65
|
||||||
|
|
|
|
||||||
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
||||||
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
|
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-argument-cross-crate-mismatch.rs:7:67
|
--> $DIR/const-argument-cross-crate-mismatch.rs:9:67
|
||||||
|
|
|
|
||||||
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
||||||
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
|
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-argument-cross-crate-mismatch.rs:9:65
|
--> $DIR/const-argument-cross-crate-mismatch.rs:11:65
|
||||||
|
|
|
|
||||||
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
||||||
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
|
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// aux-build:const_generic_lib.rs
|
// aux-build:const_generic_lib.rs
|
||||||
// revisions: full min
|
// revisions: full min
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
|
||||||
extern crate const_generic_lib;
|
extern crate const_generic_lib;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue