Skip to content

Commit 200c3f1

Browse files
committed
---
yaml --- r: 271967 b: refs/heads/master c: 944723b h: refs/heads/master i: 271965: 474e4a9 271963: 3038a7c 271959: 692990f 271951: 5642394 271935: f613b1f
1 parent bfb7ea5 commit 200c3f1

File tree

12 files changed

+206
-190
lines changed

12 files changed

+206
-190
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6a3b5585061e34bc87374adec993a6b1f0ec2a55
2+
refs/heads/master: 944723b7731ec1eacdbc1946009bcd51d17a6301
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc/traits/fulfill.rs

Lines changed: 162 additions & 124 deletions
Large diffs are not rendered by default.

trunk/src/librustc_const_eval/eval.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,10 @@ pub fn eval_const_expr(tcx: &TyCtxt, e: &Expr) -> ConstVal {
343343
match eval_const_expr_partial(tcx, e, ExprTypeChecked, None) {
344344
Ok(r) => r,
345345
// non-const path still needs to be a fatal error, because enums are funky
346+
Err(ref s) if s.kind == NonConstPath => tcx.sess.span_fatal(s.span, &s.description()),
346347
Err(s) => {
347-
match s.kind {
348-
NonConstPath |
349-
UnimplementedConstVal(_) => tcx.sess.span_fatal(s.span, &s.description()),
350-
_ => {
351-
tcx.sess.span_err(s.span, &s.description());
352-
Dummy
353-
}
354-
}
348+
tcx.sess.span_err(s.span, &s.description());
349+
Dummy
355350
},
356351
}
357352
}
@@ -612,7 +607,6 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
612607
const_val => signal!(e, NotOn(const_val)),
613608
}
614609
}
615-
hir::ExprUnary(hir::UnDeref, _) => signal!(e, UnimplementedConstVal("deref operation")),
616610
hir::ExprBinary(op, ref a, ref b) => {
617611
let b_ty = match op.node {
618612
hir::BiShl | hir::BiShr => ty_hint.erase_hint(),
@@ -751,7 +745,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
751745
if let Some(const_expr) = lookup_variant_by_id(tcx, enum_def, variant_def) {
752746
eval_const_expr_partial(tcx, const_expr, ty_hint, None)?
753747
} else {
754-
signal!(e, UnimplementedConstVal("enum variants"));
748+
signal!(e, NonConstPath);
755749
}
756750
}
757751
Def::Struct(..) => {
@@ -774,7 +768,6 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
774768
let callee_val = eval_const_expr_partial(tcx, callee, sub_ty_hint, fn_args)?;
775769
let did = match callee_val {
776770
Function(did) => did,
777-
Struct(_) => signal!(e, UnimplementedConstVal("tuple struct constructors")),
778771
callee => signal!(e, CallOn(callee)),
779772
};
780773
let (decl, result) = if let Some(fn_like) = lookup_const_fn_by_id(tcx, did) {
@@ -805,7 +798,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
805798
hir::ExprBlock(ref block) => {
806799
match block.expr {
807800
Some(ref expr) => eval_const_expr_partial(tcx, &expr, ty_hint, fn_args)?,
808-
None => signal!(e, UnimplementedConstVal("empty block")),
801+
None => bug!(),
809802
}
810803
}
811804
hir::ExprType(ref e, _) => eval_const_expr_partial(tcx, &e, ty_hint, fn_args)?,
@@ -847,8 +840,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
847840
},
848841

849842
Str(ref s) if idx as usize >= s.len() => signal!(e, IndexOutOfBounds),
850-
// FIXME: return a const char
851-
Str(_) => signal!(e, UnimplementedConstVal("indexing into str")),
843+
Str(_) => bug!("unimplemented"), // FIXME: return a const char
852844
_ => signal!(e, IndexedNonVec),
853845
}
854846
}
@@ -902,7 +894,6 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
902894
signal!(base, ExpectedConstStruct);
903895
}
904896
}
905-
hir::ExprAddrOf(..) => signal!(e, UnimplementedConstVal("address operator")),
906897
_ => signal!(e, MiscCatchAll)
907898
};
908899

@@ -1082,7 +1073,6 @@ fn cast_const_int<'tcx>(tcx: &TyCtxt<'tcx>, val: ConstInt, ty: ty::Ty) -> CastRe
10821073
Ok(Float(val as f64))
10831074
},
10841075
ty::TyFloat(ast::FloatTy::F32) => Ok(Float(val.to_u64().unwrap() as f32 as f64)),
1085-
ty::TyRawPtr(_) => Err(ErrKind::UnimplementedConstVal("casting an address to a raw ptr")),
10861076
_ => Err(CannotCast),
10871077
}
10881078
}
@@ -1104,7 +1094,6 @@ fn cast_const<'tcx>(tcx: &TyCtxt<'tcx>, val: ConstVal, ty: ty::Ty) -> CastResult
11041094
Bool(b) => cast_const_int(tcx, Infer(b as u64), ty),
11051095
Float(f) => cast_const_float(tcx, f, ty),
11061096
Char(c) => cast_const_int(tcx, Infer(c as u64), ty),
1107-
Function(_) => Err(UnimplementedConstVal("casting fn pointers")),
11081097
_ => Err(CannotCast),
11091098
}
11101099
}

trunk/src/librustc_passes/consts.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc::dep_graph::DepNode;
2828
use rustc::ty::cast::{CastKind};
2929
use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, compare_lit_exprs};
3030
use rustc_const_eval::{eval_const_expr_partial, lookup_const_by_id};
31-
use rustc_const_eval::ErrKind::{IndexOpFeatureGated, UnimplementedConstVal};
31+
use rustc_const_eval::ErrKind::IndexOpFeatureGated;
3232
use rustc_const_eval::EvalHint::ExprTypeChecked;
3333
use rustc::middle::def::Def;
3434
use rustc::middle::def_id::DefId;
@@ -110,16 +110,6 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
110110
entry.insert(ConstQualif::empty());
111111
}
112112
}
113-
if let Err(err) = eval_const_expr_partial(self.tcx, expr, ExprTypeChecked, None) {
114-
match err.kind {
115-
UnimplementedConstVal(_) => {},
116-
IndexOpFeatureGated => {},
117-
_ => self.tcx.sess.add_lint(CONST_ERR, expr.id, expr.span,
118-
format!("constant evaluation error: {}. This will \
119-
become a HARD ERROR in the future",
120-
err.description())),
121-
}
122-
}
123113
self.with_mode(mode, |this| {
124114
this.with_euv(None, |euv| euv.consume_expr(expr));
125115
this.visit_expr(expr);
@@ -445,7 +435,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
445435
match eval_const_expr_partial(
446436
self.tcx, ex, ExprTypeChecked, None) {
447437
Ok(_) => {}
448-
Err(ConstEvalErr { kind: UnimplementedConstVal(_), ..}) |
449438
Err(ConstEvalErr { kind: IndexOpFeatureGated, ..}) => {},
450439
Err(msg) => {
451440
self.tcx.sess.add_lint(CONST_ERR, ex.id,

trunk/src/test/compile-fail/const-err-early.rs

Lines changed: 0 additions & 22 deletions
This file was deleted.

trunk/src/test/compile-fail/const-err.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010

1111
#![feature(rustc_attrs)]
1212
#![allow(exceeding_bitshifts)]
13+
#![deny(const_err)]
1314

1415
fn black_box<T>(_: T) {
1516
unimplemented!()
1617
}
1718

19+
const BLA: u8 = 200u8 + 200u8;
20+
//~^ ERROR attempted to add with overflow
21+
1822
#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
1923
fn main() {
2024
let a = -std::i8::MIN;
@@ -26,8 +30,7 @@ fn main() {
2630
//~^ WARN attempted to multiply with overflow
2731
let d = 42u8 - (42u8 + 1);
2832
//~^ WARN attempted to subtract with overflow
29-
let _e = [5u8][1];
30-
//~^ ERROR const index-expr is out of bounds
33+
let _e = BLA;
3134
black_box(a);
3235
black_box(b);
3336
black_box(c);

trunk/src/test/compile-fail/const-eval-span.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
struct S(i32);
1515

1616
const CONSTANT: S = S(0);
17-
//~^ ERROR: unimplemented constant expression: tuple struct constructors [E0080]
17+
//~^ ERROR: constant evaluation error: call on struct [E0080]
1818

1919
enum E {
2020
V = CONSTANT,

trunk/src/test/compile-fail/const-pattern-not-const-evaluable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ enum Cake {
1717
use Cake::*;
1818

1919
const BOO: (Cake, Cake) = (Marmor, BlackForest);
20-
//~^ ERROR: constant evaluation error: unimplemented constant expression: enum variants [E0471]
20+
//~^ ERROR: constant evaluation error: non-constant path in constant expression [E0471]
2121
const FOO: Cake = BOO.1;
2222

2323
const fn foo() -> Cake {
24-
Marmor //~ ERROR: constant evaluation error: unimplemented constant expression: enum variants
25-
//~^ ERROR: unimplemented constant expression: enum variants
24+
Marmor //~ ERROR: constant evaluation error: non-constant path in constant expression [E0471]
25+
//~^ ERROR: non-constant path in constant expression
2626
}
2727

2828
const WORKS: Cake = Marmor;

trunk/src/test/compile-fail/feature-gate-negate-unsigned.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ impl std::ops::Neg for S {
1717
}
1818

1919
const _MAX: usize = -1;
20-
//~^ WARN unary negation of unsigned integer
21-
//~| ERROR unary negation of unsigned integer
20+
//~^ ERROR unary negation of unsigned integer
2221
//~| HELP use a cast or the `!` operator
2322

2423
fn main() {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test for #32326. We ran out of memory because we
12+
// attempted to expand this case up to the recursion limit, and 2^N is
13+
// too big.
14+
15+
enum Expr { //~ ERROR E0072
16+
Plus(Expr, Expr),
17+
Literal(i64),
18+
}
19+
20+
fn main() { }

trunk/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ enum State { ST_NULL, ST_WHITESPACE }
1515

1616
fn main() {
1717
[State::ST_NULL; (State::ST_WHITESPACE as usize)];
18-
//~^ ERROR expected constant integer for repeat count, but unimplemented constant expression
18+
//~^ ERROR expected constant integer for repeat count, but non-constant path
1919
}

trunk/src/test/compile-fail/sized-cycle-note.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ struct Baz { q: Option<Foo> }
2020

2121
struct Foo { q: Option<Baz> }
2222
//~^ ERROR recursive type `Foo` has infinite size
23-
//~| type `Foo` is embedded within `std::option::Option<Foo>`...
24-
//~| ...which in turn is embedded within `std::option::Option<Foo>`...
25-
//~| ...which in turn is embedded within `Baz`...
26-
//~| ...which in turn is embedded within `std::option::Option<Baz>`...
27-
//~| ...which in turn is embedded within `Foo`, completing the cycle.
23+
//~| NOTE type `Foo` is embedded within `std::option::Option<Foo>`...
24+
//~| NOTE ...which in turn is embedded within `std::option::Option<Foo>`...
25+
//~| NOTE ...which in turn is embedded within `Baz`...
26+
//~| NOTE ...which in turn is embedded within `std::option::Option<Baz>`...
27+
//~| NOTE ...which in turn is embedded within `Foo`, completing the cycle.
2828

2929
impl Foo { fn bar(&self) {} }
3030

0 commit comments

Comments
 (0)