From 5363911d8537eff55c09239a68e831f2a7bc724d Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 19 Jul 2018 22:41:09 -0400 Subject: [PATCH 1/6] Add tests for #34784 Closes #34784 --- src/test/compile-fail/issue-34784.rs | 20 ++++++++++++++++++++ src/test/run-pass/issue-34784.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/test/compile-fail/issue-34784.rs create mode 100644 src/test/run-pass/issue-34784.rs diff --git a/src/test/compile-fail/issue-34784.rs b/src/test/compile-fail/issue-34784.rs new file mode 100644 index 0000000000000..5c510b4a10d83 --- /dev/null +++ b/src/test/compile-fail/issue-34784.rs @@ -0,0 +1,20 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const C: *const [u8; 4] = b"abcd"; + +fn main() { + match C { + C => {} + //~^ ERROR this expression will panic at runtime + _ => {} + } +} + diff --git a/src/test/run-pass/issue-34784.rs b/src/test/run-pass/issue-34784.rs new file mode 100644 index 0000000000000..c9a214e0cedd0 --- /dev/null +++ b/src/test/run-pass/issue-34784.rs @@ -0,0 +1,28 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const C: *const u8 = &0; + +fn foo(x: *const u8) { + match x { + C => {} + _ => {} + } +} + +const D: *const [u8; 4] = b"abcd"; + +fn main() { + match D { + D => {} + _ => {} + } +} + From 63ed6a19aa653e0264b565bad2015c3a2fe482ed Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Mon, 23 Jul 2018 21:24:18 -0400 Subject: [PATCH 2/6] Add test for #33264 Closes #33264 --- src/test/run-pass/issue-33264.rs | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/run-pass/issue-33264.rs diff --git a/src/test/run-pass/issue-33264.rs b/src/test/run-pass/issue-33264.rs new file mode 100644 index 0000000000000..cb4b227548aab --- /dev/null +++ b/src/test/run-pass/issue-33264.rs @@ -0,0 +1,39 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// only-x86_64 + +#![allow(dead_code, non_upper_case_globals)] +#![feature(asm)] + +#[repr(C)] +pub struct D32x4(f32,f32,f32,f32); + +impl D32x4 { + fn add(&self, vec: Self) -> Self { + unsafe { + let ret: Self; + asm!(" + movaps $1, %xmm1 + movaps $2, %xmm2 + addps %xmm1, %xmm2 + movaps $xmm1, $0 + " + : "=r"(ret) + : "1"(self), "2"(vec) + : "xmm1", "xmm2" + ); + ret + } + } +} + +fn main() { } + From bbbbf2dc323ebecae08d84249813fa8c29eec910 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 19 Jul 2018 23:01:34 -0400 Subject: [PATCH 3/6] Add run-pass test for #44005 Closes #44005 --- src/test/run-pass/issue-44005.rs | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/run-pass/issue-44005.rs diff --git a/src/test/run-pass/issue-44005.rs b/src/test/run-pass/issue-44005.rs new file mode 100644 index 0000000000000..a53026f36ab70 --- /dev/null +++ b/src/test/run-pass/issue-44005.rs @@ -0,0 +1,39 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo<'a> { + type Bar; + fn foo(&'a self) -> Self::Bar; +} + +impl<'a, 'b, T: 'a> Foo<'a> for &'b T { + type Bar = &'a T; + fn foo(&'a self) -> &'a T { + self + } +} + +pub fn uncallable(x: T, f: F) + where T: for<'a> Foo<'a>, + F: for<'a> Fn(>::Bar) +{ + f(x.foo()); +} + +pub fn catalyst(x: &i32) { + broken(x, |_| {}) +} + +pub fn broken(x: &i32, f: F) { + uncallable(x, |y| f(y)); +} + +fn main() { } + From 8c5ef0a09a55032c1b0b922b8b8ec5cc2672452e Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 19 Jul 2018 23:09:45 -0400 Subject: [PATCH 4/6] Add compile-fail test for #42060 Closes #42060 --- src/test/compile-fail/issue-42060.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/compile-fail/issue-42060.rs diff --git a/src/test/compile-fail/issue-42060.rs b/src/test/compile-fail/issue-42060.rs new file mode 100644 index 0000000000000..23df42d03c4e0 --- /dev/null +++ b/src/test/compile-fail/issue-42060.rs @@ -0,0 +1,22 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let thing = (); + let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant + //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] +} + +fn f(){ + let q = 1; + ::N //~ ERROR attempt to use a non-constant value in a constant + //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] +} + From 3290774fa999d93f3b44b6830f2ad42e06ebe43c Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 19 Jul 2018 23:15:49 -0400 Subject: [PATCH 5/6] Add compile-fail test for #43196 Closes #43196 --- src/test/compile-fail/issue-43196.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/compile-fail/issue-43196.rs diff --git a/src/test/compile-fail/issue-43196.rs b/src/test/compile-fail/issue-43196.rs new file mode 100644 index 0000000000000..ff53c9a5a5498 --- /dev/null +++ b/src/test/compile-fail/issue-43196.rs @@ -0,0 +1,17 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + | +} +//~^ ERROR expected `|`, found `}` +| +//~^ ERROR expected item, found `|` + From 715005c1a76129f7d2c0e85f2ef0af96a8c2add6 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 19 Jul 2018 23:30:42 -0400 Subject: [PATCH 6/6] Update compile-fail tests to be ui tests --- src/test/compile-fail/issue-34784.rs | 20 -------------- src/test/{compile-fail => ui}/issue-42060.rs | 0 src/test/ui/issue-42060.stderr | 28 ++++++++++++++++++++ src/test/{compile-fail => ui}/issue-43196.rs | 0 src/test/ui/issue-43196.stderr | 16 +++++++++++ 5 files changed, 44 insertions(+), 20 deletions(-) delete mode 100644 src/test/compile-fail/issue-34784.rs rename src/test/{compile-fail => ui}/issue-42060.rs (100%) create mode 100644 src/test/ui/issue-42060.stderr rename src/test/{compile-fail => ui}/issue-43196.rs (100%) create mode 100644 src/test/ui/issue-43196.stderr diff --git a/src/test/compile-fail/issue-34784.rs b/src/test/compile-fail/issue-34784.rs deleted file mode 100644 index 5c510b4a10d83..0000000000000 --- a/src/test/compile-fail/issue-34784.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -const C: *const [u8; 4] = b"abcd"; - -fn main() { - match C { - C => {} - //~^ ERROR this expression will panic at runtime - _ => {} - } -} - diff --git a/src/test/compile-fail/issue-42060.rs b/src/test/ui/issue-42060.rs similarity index 100% rename from src/test/compile-fail/issue-42060.rs rename to src/test/ui/issue-42060.rs diff --git a/src/test/ui/issue-42060.stderr b/src/test/ui/issue-42060.stderr new file mode 100644 index 0000000000000..69abac8ee7e3a --- /dev/null +++ b/src/test/ui/issue-42060.stderr @@ -0,0 +1,28 @@ +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/issue-42060.rs:13:23 + | +LL | let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant + | ^^^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/issue-42060.rs:19:13 + | +LL | ::N //~ ERROR attempt to use a non-constant value in a constant + | ^ non-constant value + +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/issue-42060.rs:13:16 + | +LL | let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant + | ^^^^^^^^^^^^^ reserved keyword + +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/issue-42060.rs:19:6 + | +LL | ::N //~ ERROR attempt to use a non-constant value in a constant + | ^^^^^^^^^ reserved keyword + +error: aborting due to 4 previous errors + +Some errors occurred: E0435, E0516. +For more information about an error, try `rustc --explain E0435`. diff --git a/src/test/compile-fail/issue-43196.rs b/src/test/ui/issue-43196.rs similarity index 100% rename from src/test/compile-fail/issue-43196.rs rename to src/test/ui/issue-43196.rs diff --git a/src/test/ui/issue-43196.stderr b/src/test/ui/issue-43196.stderr new file mode 100644 index 0000000000000..2418f517168a4 --- /dev/null +++ b/src/test/ui/issue-43196.stderr @@ -0,0 +1,16 @@ +error: expected `|`, found `}` + --> $DIR/issue-43196.rs:13:1 + | +LL | | + | - expected `|` here +LL | } + | ^ unexpected token + +error: expected item, found `|` + --> $DIR/issue-43196.rs:15:1 + | +LL | | + | ^ expected item + +error: aborting due to 2 previous errors +