Skip to content

Commit 1c5ff29

Browse files
committed
Rebase fallout
1 parent d2e682a commit 1c5ff29

31 files changed

+69
-319
lines changed

src/librustc_lint/builtin.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,49 +1547,6 @@ impl LintPass for UnusedBrokenConst {
15471547
lint_array!()
15481548
}
15491549
}
1550-
1551-
fn validate_const<'a, 'tcx>(
1552-
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
1553-
constant: &ty::Const<'tcx>,
1554-
param_env: ty::ParamEnv<'tcx>,
1555-
gid: ::rustc::mir::interpret::GlobalId<'tcx>,
1556-
what: &str,
1557-
) {
1558-
let ecx = ::rustc_mir::const_eval::mk_eval_cx(tcx, gid.instance, param_env).unwrap();
1559-
let result = (|| {
1560-
let op = ecx.const_to_op(constant)?;
1561-
let mut ref_tracking = ::rustc_mir::interpret::RefTracking::new(op);
1562-
while let Some((op, mut path)) = ref_tracking.todo.pop() {
1563-
ecx.validate_operand(
1564-
op,
1565-
&mut path,
1566-
Some(&mut ref_tracking),
1567-
/* const_mode */ true,
1568-
)?;
1569-
}
1570-
Ok(())
1571-
})();
1572-
if let Err(err) = result {
1573-
let (trace, span) = ecx.generate_stacktrace(None);
1574-
let err = ::rustc::mir::interpret::ConstEvalErr {
1575-
error: err,
1576-
stacktrace: trace,
1577-
span,
1578-
};
1579-
let err = err.struct_error(
1580-
tcx.at(span),
1581-
&format!("this {} likely exhibits undefined behavior", what),
1582-
);
1583-
if let Some(mut err) = err {
1584-
err.note("The rules on what exactly is undefined behavior aren't clear, \
1585-
so this check might be overzealous. Please open an issue on the rust compiler \
1586-
repository if you believe it should not be considered undefined behavior",
1587-
);
1588-
err.emit();
1589-
}
1590-
}
1591-
}
1592-
15931550
fn check_const(cx: &LateContext, body_id: hir::BodyId) {
15941551
let def_id = cx.tcx.hir.body_owner_def_id(body_id);
15951552
let is_static = cx.tcx.is_static(def_id).is_some();

src/librustc_mir/const_eval.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use rustc::ty::{self, Ty, TyCtxt, Instance, query::TyCtxtAt};
2424
use rustc::ty::layout::{self, Size, LayoutOf, TyLayout};
2525
use rustc::ty::subst::Subst;
2626
use rustc::traits::Reveal;
27-
use rustc::util::nodemap::FxHashSet;
2827
use rustc_data_structures::indexed_vec::IndexVec;
2928
use rustc_data_structures::fx::FxHashMap;
3029
use rustc::util::common::ErrorReported;
@@ -36,7 +35,7 @@ use interpret::{self,
3635
PlaceTy, MemPlace, OpTy, Operand, Value, Pointer, Scalar, ConstValue,
3736
EvalResult, EvalError, EvalErrorKind, GlobalId, EvalContext, StackPopCleanup,
3837
Allocation, AllocId, MemoryKind,
39-
snapshot,
38+
snapshot, RefTracking,
4039
};
4140

4241
/// Number of steps until the detector even starts doing anything.
@@ -542,15 +541,13 @@ fn validate_const<'a, 'tcx>(
542541
let ecx = mk_eval_cx(tcx, cid.instance, key.param_env).unwrap();
543542
let val = (|| {
544543
let op = ecx.const_to_op(constant)?;
545-
let mut todo = vec![(op, Vec::new())];
546-
let mut seen = FxHashSet();
547-
seen.insert(op);
548-
while let Some((op, mut path)) = todo.pop() {
544+
let mut ref_tracking = RefTracking::new(op);
545+
while let Some((op, mut path)) = ref_tracking.todo.pop() {
549546
ecx.validate_operand(
550547
op,
551548
&mut path,
552-
&mut seen,
553-
&mut todo,
549+
Some(&mut ref_tracking),
550+
/* const_mode */ true,
554551
)?;
555552
}
556553
Ok(constant)

src/test/compile-fail/const-fn-error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const fn f(x: usize) -> usize {
1616
let mut sum = 0;
1717
//~^ let bindings in constant functions are unstable
1818
//~| statements in constant functions are unstable
19-
for i in 0..x { //~ ERROR E0080
19+
for i in 0..x {
2020
//~^ ERROR E0015
2121
//~| ERROR E0019
2222
sum += i;

src/test/compile-fail/issue-52443.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ fn main() {
1414
[(); {while true {break}; 0}]; //~ ERROR constant contains unimplemented expression type
1515
[(); { for _ in 0usize.. {}; 0}]; //~ ERROR calls in constants are limited to constant functions
1616
//~^ ERROR constant contains unimplemented expression type
17-
//~| ERROR evaluation of constant value failed
1817
}

src/test/ui/consts/const-call.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0015]: calls in constants are limited to constant functions, tuple struct
44
LL | let _ = [0; f(2)];
55
| ^^^^
66

7-
error[E0080]: evaluation of constant value failed
8-
--> $DIR/const-call.rs:16:17
9-
|
10-
LL | let _ = [0; f(2)];
11-
| ^^^^ calling non-const fn `f`
12-
13-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
148

159
For more information about this error, try `rustc --explain E0015`.

src/test/ui/consts/const-eval/conditional_array_execution.nll.stderr

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

src/test/ui/consts/const-eval/issue-43197.nll.stderr

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

src/test/ui/consts/const-eval/issue-43197.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/issue-43197.rs:20:5
2+
--> $DIR/issue-43197.rs:18:5
33
|
44
LL | const X: u32 = 0-1;
55
| ^^^^^^^^^^^^^^^---^
@@ -13,21 +13,21 @@ LL | #![warn(const_err)]
1313
| ^^^^^^^^^
1414

1515
warning: any use of this value will cause an error
16-
--> $DIR/issue-43197.rs:22:5
16+
--> $DIR/issue-43197.rs:20:5
1717
|
1818
LL | const Y: u32 = foo(0-1);
1919
| ^^^^^^^^^^^^^^^^^^^---^^
2020
| |
2121
| attempt to subtract with overflow
2222

2323
error[E0080]: evaluation of constant expression failed
24-
--> $DIR/issue-43197.rs:24:26
24+
--> $DIR/issue-43197.rs:22:26
2525
|
2626
LL | println!("{} {}", X, Y);
2727
| ^ referenced constant has errors
2828

2929
error[E0080]: evaluation of constant expression failed
30-
--> $DIR/issue-43197.rs:24:23
30+
--> $DIR/issue-43197.rs:22:23
3131
|
3232
LL | println!("{} {}", X, Y);
3333
| ^ referenced constant has errors

src/test/ui/consts/const-eval/issue-44578.nll.stderr

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

src/test/ui/consts/const-eval/issue-52442.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0080]: it is undefined behavior to use this value
88
--> $DIR/issue-52442.rs:12:11
99
|
1010
LL | [(); { &loop { break } as *const _ as usize } ]; //~ ERROR unimplemented expression type
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type usize
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits
1212
|
1313
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
1414

0 commit comments

Comments
 (0)