Skip to content

Commit

Permalink
Regenerate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 8, 2018
1 parent 6cfda07 commit aedd4c6
Show file tree
Hide file tree
Showing 34 changed files with 247 additions and 283 deletions.
21 changes: 3 additions & 18 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/librustc/ich/impls_ty.rs
Expand Up @@ -61,10 +61,10 @@ for ty::subst::Kind<'gcx> {
}
}

impl<'gcx> HashStable<StableHashingContext<'gcx>>
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ty::subst::UnpackedKind<'gcx> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
match self {
ty::subst::UnpackedKind::Lifetime(lt) => lt.hash_stable(hcx, hasher),
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/maps/on_disk_cache.rs
Expand Up @@ -362,6 +362,7 @@ impl<'sess> OnDiskCache<'sess> {
cnum_map: cnum_map.as_ref().unwrap(),
file_index_to_file: &self.file_index_to_file,
file_index_to_stable_id: &self.file_index_to_stable_id,
synthetic_expansion_infos: &self.synthetic_expansion_infos,
interpret_alloc_cache: FxHashMap::default(),
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Expand Up @@ -36,7 +36,7 @@ use rustc_typeck as typeck;
use rustc_privacy;
use rustc_plugin::registry::Registry;
use rustc_plugin as plugin;
use rustc_passes::{self, ast_validation, loops, consts, hir_stats};
use rustc_passes::{self, ast_validation, loops, rvalue_promotion, hir_stats};
use super::Compilation;

use serialize::json;
Expand Down
22 changes: 13 additions & 9 deletions src/librustc_mir/hair/pattern/mod.rs
Expand Up @@ -373,13 +373,17 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
PatternKind::Constant { value: hi }) => {
use std::cmp::Ordering;
match (end, compare_const_vals(&lo.val, &hi.val, ty).unwrap()) {
(RangeEnd::Excluded, Ordering::Less) => {},
(RangeEnd::Excluded, _) => span_err!(
self.tcx.sess,
lo_expr.span,
E0579,
"lower range bound must be less than upper",
),
(RangeEnd::Excluded, Ordering::Less) =>
PatternKind::Range { lo, hi, end },
(RangeEnd::Excluded, _) => {
span_err!(
self.tcx.sess,
lo_expr.span,
E0579,
"lower range bound must be less than upper",
);
PatternKind::Wild
},
(RangeEnd::Included, Ordering::Greater) => {
let mut err = struct_span_err!(
self.tcx.sess,
Expand All @@ -399,10 +403,10 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
to be less than or equal to the end of the range.");
}
err.emit();
PatternKind::Wild
},
(RangeEnd::Included, _) => {}
(RangeEnd::Included, _) => PatternKind::Range { lo, hi, end },
}
PatternKind::Range { lo, hi, end }
}
_ => PatternKind::Wild
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/monomorphize/collector.rs
Expand Up @@ -1090,8 +1090,7 @@ fn collect_miri<'a, 'tcx>(
let instance = Instance::mono(tcx, did);
if should_monomorphize_locally(tcx, &instance) {
trace!("collecting static {:?}", did);
let node_id = tcx.hir.as_local_node_id(did).unwrap();
output.push(MonoItem::Static(node_id));
output.push(MonoItem::Static(did));
}
} else if let Some(alloc) = tcx.interpret_interner.get_alloc(alloc_id) {
trace!("collecting {:?} with {:#?}", alloc_id, alloc);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/uniform_array_move_out.rs
Expand Up @@ -203,7 +203,7 @@ impl MirPass for RestoreSubsliceArrayMoveOut {
let opt_size = opt_src_place.and_then(|src_place| {
let src_ty = src_place.ty(mir, tcx).to_ty(tcx);
if let ty::TyArray(_, ref size_o) = src_ty.sty {
size_o.val.to_const_int().and_then(|v| v.to_u64())
size_o.val.to_raw_bits().map(|n| n as u64)
} else {
None
}
Expand Down
13 changes: 2 additions & 11 deletions src/librustc_passes/rvalue_promotion.rs
Expand Up @@ -32,7 +32,7 @@ use rustc::middle::expr_use_visitor as euv;
use rustc::middle::mem_categorization as mc;
use rustc::middle::mem_categorization::Categorization;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::maps::{queries, Providers};
use rustc::ty::maps::Providers;
use rustc::ty::subst::Substs;
use rustc::traits::Reveal;
use rustc::util::nodemap::{ItemLocalSet, NodeSet};
Expand Down Expand Up @@ -325,16 +325,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
// Don't peek inside trait associated constants.
false
} else {
queries::const_is_rvalue_promotable_to_static::try_get(v.tcx, e.span, did)
.unwrap_or_else(|mut err| {
// A cycle between constants ought to be reported elsewhere.
err.cancel();
v.tcx.sess.delay_span_bug(
e.span,
&format!("cycle encountered during const qualification: {:?}",
did));
false
})
v.tcx.at(e.span).const_is_rvalue_promotable_to_static(did)
};

// Just in case the type is more specific than the definition,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-eval-overflow-2.stderr
Expand Up @@ -5,7 +5,7 @@ LL | const NEG_NEG_128: i8 = -NEG_128;
| ^^^^^^^^ attempt to negate with overflow
|
note: for pattern here
--> $DIR/const-eval-overflow-2.rs:27:9
--> $DIR/const-eval-overflow-2.rs:26:9
|
LL | NEG_NEG_128 => println!("A"),
| ^^^^^^^^^^^
Expand Down
8 changes: 0 additions & 8 deletions src/test/ui/const-eval-overflow-4.stderr
@@ -1,11 +1,3 @@
warning: constant evaluation error: attempt to add with overflow
--> $DIR/const-eval-overflow-4.rs:23:13
|
LL | : [u32; (i8::MAX as i8 + 1i8) as usize]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(const_err)] on by default

error[E0080]: constant evaluation error
--> $DIR/const-eval-overflow-4.rs:23:13
|
Expand Down
25 changes: 7 additions & 18 deletions src/test/ui/const-eval/conditional_array_execution.stderr
@@ -1,26 +1,15 @@
error[E0080]: constant evaluation error
--> $DIR/conditional_array_execution.rs:13:19
|
13 | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; //~ E0080
| ^^^^^ attempt to subtract with overflow
|
note: inside call to FOO
--> $DIR/conditional_array_execution.rs:13:1
--> $DIR/conditional_array_execution.rs:16:20
|
13 | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; //~ E0080
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | println!("{}", FOO); //~ E0080
| ^^^ referenced constant has errors

error[E0080]: constant evaluation error
--> $DIR/conditional_array_execution.rs:16:20
|
16 | println!("{}", FOO); //~ E0080
| ^^^ attempt to subtract with overflow
|
note: inside call to main
--> $DIR/conditional_array_execution.rs:16:20
--> $DIR/conditional_array_execution.rs:13:19
|
16 | println!("{}", FOO); //~ E0080
| ^^^
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; //~ E0080
| ^^^^^ attempt to subtract with overflow

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0080"
9 changes: 9 additions & 0 deletions src/test/ui/const-eval/index_out_of_bound.stderr
@@ -0,0 +1,9 @@
error[E0080]: constant evaluation error
--> $DIR/index_out_of_bound.rs:11:19
|
LL | static FOO: i32 = [][0];
| ^^^^^ index out of bounds: the len is 0 but the index is 0 at $DIR/index_out_of_bound.rs:11:19: 11:24

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0080"
28 changes: 13 additions & 15 deletions src/test/ui/const-eval/issue-43197.stderr
@@ -1,29 +1,27 @@
warning: constant evaluation error: attempt to subtract with overflow
--> $DIR/issue-43197.rs:18:20
error[E0080]: constant evaluation error
--> $DIR/issue-43197.rs:20:23
|
LL | const X: u32 = 0-1; //~ ERROR constant evaluation error
| ^^^
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors

error[E0080]: constant evaluation error
--> $DIR/issue-43197.rs:20:26
|
= note: #[warn(const_err)] on by default
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors

warning: constant evaluation error: attempt to subtract with overflow
--> $DIR/issue-43197.rs:20:20
error[E0080]: constant evaluation error
--> $DIR/issue-43197.rs:19:24
|
LL | const Y: u32 = foo(0-1); //~ ERROR constant evaluation error
| ^^^^^^^^
| ^^^ attempt to subtract with overflow

error[E0080]: constant evaluation error
--> $DIR/issue-43197.rs:18:20
|
LL | const X: u32 = 0-1; //~ ERROR constant evaluation error
| ^^^ attempt to subtract with overflow

error[E0080]: constant evaluation error
--> $DIR/issue-43197.rs:20:24
|
LL | const Y: u32 = foo(0-1); //~ ERROR constant evaluation error
| ^^^ attempt to subtract with overflow

error: aborting due to 2 previous errors
error: aborting due to 4 previous errors

If you want more information on this error, try using "rustc --explain E0080"
15 changes: 0 additions & 15 deletions src/test/ui/const-expr-addr-operator.stderr
@@ -1,15 +0,0 @@
error[E0080]: constant evaluation error
--> $DIR/const-expr-addr-operator.rs:15:29
|
LL | const X: &'static u32 = &22; //~ ERROR constant evaluation error
| ^^^ unimplemented constant expression: address operator
|
note: for pattern here
--> $DIR/const-expr-addr-operator.rs:17:9
|
LL | X => 0,
| ^

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0080"
47 changes: 10 additions & 37 deletions src/test/ui/const-fn-error.stderr
@@ -1,62 +1,35 @@
<<<<<<< HEAD
warning: constant evaluation error: non-constant path in constant expression
--> $DIR/const-fn-error.rs:27:19
|
LL | let a : [i32; f(X)];
| ^^^^
|
= note: #[warn(const_err)] on by default

error[E0016]: blocks in constant functions are limited to items and tail expressions
--> $DIR/const-fn-error.rs:16:19
|
LL | let mut sum = 0; //~ ERROR blocks in constant functions are limited
=======
error[E0016]: blocks in constant functions are limited to items and tail expressions
--> $DIR/const-fn-error.rs:16:19
|
16 | let mut sum = 0;
>>>>>>> Produce instead of pointers
LL | let mut sum = 0;
| ^

error[E0015]: calls in constant functions are limited to constant functions, struct and enum constructors
--> $DIR/const-fn-error.rs:18:14
|
<<<<<<< HEAD
LL | for i in 0..x { //~ ERROR calls in constant functions
=======
18 | for i in 0..x {
>>>>>>> Report errors in statics during collecting instead of translating
LL | for i in 0..x {
| ^^^^

error[E0019]: constant function contains unimplemented expression type
--> $DIR/const-fn-error.rs:18:14
|
<<<<<<< HEAD
LL | for i in 0..x { //~ ERROR calls in constant functions
=======
18 | for i in 0..x {
>>>>>>> Report errors in statics during collecting instead of translating
LL | for i in 0..x {
| ^^^^

error[E0080]: constant evaluation error
<<<<<<< HEAD
--> $DIR/const-fn-error.rs:21:5
--> $DIR/const-fn-error.rs:18:14
|
LL | sum //~ ERROR E0080
| ^^^ non-constant path in constant expression
LL | for i in 0..x {
| ^^^^ calling non-const fn `<I as std::iter::IntoIterator><std::ops::Range<usize>>::into_iter`
...
LL | let a : [i32; f(X)];
| ---- inside call to `f`
|
note: for constant expression here
--> $DIR/const-fn-error.rs:27:13
--> $DIR/const-fn-error.rs:29:13
|
LL | let a : [i32; f(X)];
| ^^^^^^^^^^^
=======
--> $DIR/const-fn-error.rs:28:19
|
28 | let a : [i32; f(X)];
| ^^^^ miri failed: machine error: Cannot evaluate within constants: "calling non-const fn `<I as std::iter::IntoIterator><std::ops::Range<usize>>::into_iter`"
>>>>>>> Produce instead of pointers

error: aborting due to 4 previous errors

Expand Down

0 comments on commit aedd4c6

Please sign in to comment.