Skip to content

Commit 93f5bc8

Browse files
committed
---
yaml --- r: 273122 b: refs/heads/beta c: bba1596 h: refs/heads/master
1 parent da4eb11 commit 93f5bc8

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 54b15c7160e165621f0a7ae6a71db30dded254df
26+
refs/heads/beta: bba1596c71989bdbad19ec06b27fa0d81d5bc58f
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc/middle/const_eval.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ pub enum ErrKind {
465465
Math(ConstMathErr),
466466

467467
IntermediateUnsignedNegative,
468-
InferredWrongType(ConstInt),
468+
/// Expected, Got
469+
TypeMismatch(String, ConstInt),
469470
BadType(ConstVal),
470471
}
471472

@@ -528,7 +529,10 @@ impl ConstEvalErr {
528529
number was encountered. This is most likely a bug in\
529530
the constant evaluator".into_cow(),
530531

531-
InferredWrongType(ref i) => format!("inferred wrong type for {}", i).into_cow(),
532+
TypeMismatch(ref expected, ref got) => {
533+
format!("mismatched types: expected `{}`, found `{}`",
534+
expected, got.description()).into_cow()
535+
},
532536
BadType(ref i) => format!("value of wrong type: {:?}", i).into_cow(),
533537
}
534538
}
@@ -745,7 +749,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
745749

746750
let val = match eval_const_expr_partial(tcx, &base, base_hint, fn_args) {
747751
Ok(val) => val,
748-
Err(ConstEvalErr { kind: InferredWrongType(val), .. }) => {
752+
Err(ConstEvalErr { kind: TypeMismatch(_, val), .. }) => {
749753
// Something like `5i8 as usize` doesn't need a type hint for the base
750754
// instead take the type hint from the inner value
751755
let hint = match val.int_type() {
@@ -1085,8 +1089,8 @@ fn infer<'tcx>(
10851089
(&ty::TyUint(_), Infer(_)) => Err(err(Math(ConstMathErr::NotInRange))),
10861090
(&ty::TyUint(_), InferSigned(_)) => Err(err(IntermediateUnsignedNegative)),
10871091

1088-
(&ty::TyInt(_), i) |
1089-
(&ty::TyUint(_), i) => Err(err(InferredWrongType(i))),
1092+
(&ty::TyInt(ity), i) => Err(err(TypeMismatch(ity.to_string(), i))),
1093+
(&ty::TyUint(ity), i) => Err(err(TypeMismatch(ity.to_string(), i))),
10901094

10911095
(&ty::TyEnum(ref adt, _), i) => {
10921096
let hints = tcx.lookup_repr_hints(adt.did);

branches/beta/src/test/compile-fail/const-eval-overflow-3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// self-hosted and a cross-compiled setup; therefore resorting to
1818
// error-pattern for now.
1919

20-
// error-pattern: expected constant integer for repeat count, but tried to add two integrals of
20+
// error-pattern: expected constant integer for repeat count, but attempted to add with overflow
2121

2222
#![allow(unused_imports)]
2323

branches/beta/src/test/compile-fail/const-eval-overflow-4b.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use std::{u8, u16, u32, u64, usize};
2121

2222
const A_I8_T
2323
: [u32; (i8::MAX as i8 + 1u8) as usize]
24-
//~^ ERROR tried to add two integrals of different types [E0250]
24+
//~^ ERROR mismatched types:
25+
//~| expected `i8`,
26+
//~| found `u8` [E0250]
2527
= [0; (i8::MAX as usize) + 1];
2628

2729
fn main() {

branches/beta/src/test/compile-fail/issue-8761.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010

1111
enum Foo {
1212
A = 1i64,
13-
//~^ ERROR mismatched types: expected `isize` got `i64`
13+
//~^ ERROR mismatched types:
14+
//~| expected `isize`,
15+
//~| found `i64` [E0080]
1416
B = 2u8
15-
//~^ ERROR mismatched types: expected `isize` got `u8`
17+
//~^ ERROR mismatched types:
18+
//~| expected `isize`,
19+
//~| found `u8` [E0080]
1620
}
1721

1822
fn main() {}

branches/beta/src/test/compile-fail/repeat_count.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ fn main() {
4343
let f = [0; -4_isize];
4444
//~^ ERROR mismatched types
4545
//~| expected `usize`
46-
//~| found `isize`
47-
//~| ERROR expected positive integer for repeat count, found isize [E0306]
46+
//~| found `isize` [E0308]
47+
//~| ERROR mismatched types:
48+
//~| expected `usize`,
49+
//~| found `isize` [E0307]
4850
let f = [0_usize; -1_isize];
4951
//~^ ERROR mismatched types
5052
//~| expected `usize`
51-
//~| found `isize`
52-
//~| ERROR expected positive integer for repeat count, found isize [E0306]
53+
//~| found `isize` [E0308]
54+
//~| ERROR mismatched types
55+
//~| expected `usize`
56+
//~| found `isize` [E0307]
5357
struct G {
5458
g: (),
5559
}

0 commit comments

Comments
 (0)