diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-12-21 12:32:59 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-12-28 11:27:57 +0200 |
| commit | e64f64a2fc1deb955b42542fa399f2fa2b609866 (patch) | |
| tree | c9b856eb84b258363a07ff747ffe8591a8251a4b /src/test | |
| parent | 864928297d0fc0675c5eae62a58d8488941d58cf (diff) | |
| download | rust-e64f64a2fc1deb955b42542fa399f2fa2b609866.tar.gz rust-e64f64a2fc1deb955b42542fa399f2fa2b609866.zip | |
rustc: separate bodies for static/(associated)const and embedded constants.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/E0513.rs | 19 | ||||
| -rw-r--r-- | src/test/compile-fail/associated-const-type-parameter-arrays-2.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/associated-const-type-parameter-arrays.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-27008.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/non-constant-expr-for-vec-repeat.rs | 7 | ||||
| -rw-r--r-- | src/test/compile-fail/repeat_count.rs | 21 | ||||
| -rw-r--r-- | src/test/incremental/hashes/consts.rs | 16 | ||||
| -rw-r--r-- | src/test/incremental/hashes/enum_defs.rs | 6 | ||||
| -rw-r--r-- | src/test/incremental/hashes/statics.rs | 24 | ||||
| -rw-r--r-- | src/test/incremental/string_constant.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs | 4 |
12 files changed, 53 insertions, 64 deletions
diff --git a/src/test/compile-fail/E0513.rs b/src/test/compile-fail/E0513.rs deleted file mode 100644 index 726e2326524..00000000000 --- a/src/test/compile-fail/E0513.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem; - -fn main() { - unsafe { - let size = mem::size_of::<u32>(); - mem::transmute_copy::<u32, [u8; size]>(&8_8); //~ ERROR E0513 - //~| NOTE no type for variable - } -} diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs b/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs index c3fa39659b9..7c3f7a1d574 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs @@ -25,8 +25,10 @@ impl Foo for Def { } pub fn test<A: Foo, B: Foo>() { - let _array = [4; <A as Foo>::Y]; //~ ERROR E0080 - //~| non-constant path in constant + let _array = [4; <A as Foo>::Y]; + //~^ ERROR cannot use an outer type parameter in this context [E0402] + //~| ERROR constant evaluation error [E0080] + //~| non-constant path in constant } fn main() { diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays.rs b/src/test/compile-fail/associated-const-type-parameter-arrays.rs index ddf16a2278e..dcf87d5f0fc 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arrays.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arrays.rs @@ -26,7 +26,9 @@ impl Foo for Def { pub fn test<A: Foo, B: Foo>() { let _array: [u32; <A as Foo>::Y]; - //~^ ERROR the trait bound `A: Foo` is not satisfied + //~^ ERROR cannot use an outer type parameter in this context [E0402] + //~| ERROR constant evaluation error [E0080] + //~| non-constant path in constant } fn main() { diff --git a/src/test/compile-fail/issue-27008.rs b/src/test/compile-fail/issue-27008.rs index e89bff025e0..f80135848e0 100644 --- a/src/test/compile-fail/issue-27008.rs +++ b/src/test/compile-fail/issue-27008.rs @@ -16,6 +16,4 @@ fn main() { //~| expected type `usize` //~| found type `S` //~| expected usize, found struct `S` - //~| ERROR expected `usize` for repeat count, found struct [E0306] - //~| expected `usize` } diff --git a/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs b/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs index b5401f7d124..691d8d31b41 100644 --- a/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs +++ b/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs @@ -12,8 +12,8 @@ fn main() { fn bar(n: isize) { - // FIXME (#24414): This error message needs improvement. let _x: [isize; n]; - //~^ ERROR no type for local variable + //~^ ERROR attempt to use a non-constant value in a constant [E0435] + //~| ERROR constant evaluation error [E0080] } } diff --git a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs index a6f88a57b91..f4769a78587 100644 --- a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs +++ b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs @@ -13,8 +13,9 @@ fn main() { fn bar(n: usize) { let _x = [0; n]; - //~^ ERROR constant evaluation error - //~| non-constant path in constant expression - //~| NOTE `n` is a variable + //~^ ERROR attempt to use a non-constant value in a constant [E0435] + //~| NOTE non-constant used with constant + //~| NOTE unresolved path in constant expression + //~| ERROR constant evaluation error [E0080] } } diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index 5d5113ce07c..a716f3e29d4 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -13,43 +13,30 @@ fn main() { let n = 1; let a = [0; n]; - //~^ ERROR constant evaluation error - //~| non-constant path in constant expression + //~^ ERROR attempt to use a non-constant value in a constant [E0435] let b = [0; ()]; //~^ ERROR mismatched types //~| expected type `usize` //~| found type `()` //~| expected usize, found () - //~| ERROR expected `usize` for repeat count, found tuple [E0306] - //~| expected `usize` let c = [0; true]; //~^ ERROR mismatched types //~| expected usize, found bool - //~| ERROR expected `usize` for repeat count, found boolean [E0306] - //~| expected `usize` let d = [0; 0.5]; //~^ ERROR mismatched types //~| expected type `usize` //~| found type `{float}` //~| expected usize, found floating-point variable - //~| ERROR expected `usize` for repeat count, found float [E0306] - //~| expected `usize` let e = [0; "foo"]; //~^ ERROR mismatched types //~| expected type `usize` //~| found type `&'static str` //~| expected usize, found reference - //~| ERROR expected `usize` for repeat count, found string literal [E0306] - //~| expected `usize` let f = [0; -4_isize]; - //~^ ERROR constant evaluation error - //~| expected usize, found isize - //~| ERROR mismatched types + //~^ ERROR mismatched types //~| expected usize, found isize let f = [0_usize; -1_isize]; - //~^ ERROR constant evaluation error - //~| expected usize, found isize - //~| ERROR mismatched types + //~^ ERROR mismatched types //~| expected usize, found isize struct G { g: (), @@ -59,6 +46,4 @@ fn main() { //~| expected type `usize` //~| found type `main::G` //~| expected usize, found struct `main::G` - //~| ERROR expected `usize` for repeat count, found struct [E0306] - //~| expected `usize` } diff --git a/src/test/incremental/hashes/consts.rs b/src/test/incremental/hashes/consts.rs index 10c02d84b38..28e85c94b66 100644 --- a/src/test/incremental/hashes/consts.rs +++ b/src/test/incremental/hashes/consts.rs @@ -66,8 +66,10 @@ const CONST_CHANGE_TYPE_2: Option<u64> = None; const CONST_CHANGE_VALUE_1: i16 = 1; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] const CONST_CHANGE_VALUE_1: i16 = 2; @@ -78,8 +80,10 @@ const CONST_CHANGE_VALUE_1: i16 = 2; const CONST_CHANGE_VALUE_2: i16 = 1 + 1; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] const CONST_CHANGE_VALUE_2: i16 = 1 + 2; @@ -89,8 +93,10 @@ const CONST_CHANGE_VALUE_2: i16 = 1 + 2; const CONST_CHANGE_VALUE_3: i16 = 2 + 3; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] const CONST_CHANGE_VALUE_3: i16 = 2 * 3; @@ -100,8 +106,10 @@ const CONST_CHANGE_VALUE_3: i16 = 2 * 3; const CONST_CHANGE_VALUE_4: i16 = 1 + 2 * 3; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] const CONST_CHANGE_VALUE_4: i16 = 1 + 2 * 4; diff --git a/src/test/incremental/hashes/enum_defs.rs b/src/test/incremental/hashes/enum_defs.rs index aa17a24be23..da3a953d11e 100644 --- a/src/test/incremental/hashes/enum_defs.rs +++ b/src/test/incremental/hashes/enum_defs.rs @@ -108,8 +108,10 @@ enum EnumChangeValueCStyleVariant0 { } #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] enum EnumChangeValueCStyleVariant0 { @@ -126,6 +128,8 @@ enum EnumChangeValueCStyleVariant1 { #[cfg(not(cfail1))] #[rustc_dirty(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_clean(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] enum EnumChangeValueCStyleVariant1 { diff --git a/src/test/incremental/hashes/statics.rs b/src/test/incremental/hashes/statics.rs index ac67e434901..7c6da3ba9fe 100644 --- a/src/test/incremental/hashes/statics.rs +++ b/src/test/incremental/hashes/statics.rs @@ -119,9 +119,11 @@ static STATIC_CHANGE_TYPE_2: Option<u16> = None; static STATIC_CHANGE_VALUE_1: i16 = 1; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] static STATIC_CHANGE_VALUE_1: i16 = 2; @@ -131,9 +133,11 @@ static STATIC_CHANGE_VALUE_1: i16 = 2; static STATIC_CHANGE_VALUE_2: i16 = 1 + 1; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] static STATIC_CHANGE_VALUE_2: i16 = 1 + 2; @@ -142,9 +146,11 @@ static STATIC_CHANGE_VALUE_2: i16 = 1 + 2; static STATIC_CHANGE_VALUE_3: i16 = 2 + 3; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] static STATIC_CHANGE_VALUE_3: i16 = 2 * 3; @@ -153,9 +159,11 @@ static STATIC_CHANGE_VALUE_3: i16 = 2 * 3; static STATIC_CHANGE_VALUE_4: i16 = 1 + 2 * 3; #[cfg(not(cfail1))] -#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] static STATIC_CHANGE_VALUE_4: i16 = 1 + 2 * 4; diff --git a/src/test/incremental/string_constant.rs b/src/test/incremental/string_constant.rs index ba8d3cc934b..8651a67bae2 100644 --- a/src/test/incremental/string_constant.rs +++ b/src/test/incremental/string_constant.rs @@ -23,14 +23,14 @@ fn main() { } mod x { #[cfg(rpass1)] pub fn x() { - println!("1"); + println!("{}", "1"); } #[cfg(rpass2)] #[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] #[rustc_dirty(label="TransCrateItem", cfg="rpass2")] pub fn x() { - println!("2"); + println!("{}", "2"); } } diff --git a/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs b/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs index c6892757c68..e1b1b441894 100644 --- a/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs +++ b/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs @@ -41,12 +41,12 @@ impl LintPass for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_fn(&mut self, cx: &LateContext, - fk: FnKind, _: &hir::FnDecl, expr: &hir::Expr, + fk: FnKind, _: &hir::FnDecl, body: &hir::Body, span: Span, node: ast::NodeId) { if let FnKind::Closure(..) = fk { return } - let mut extent = cx.tcx.region_maps.node_extent(expr.id); + let mut extent = cx.tcx.region_maps.node_extent(body.value.id); while let Some(parent) = cx.tcx.region_maps.opt_encl_scope(extent) { extent = parent; } |
