about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-03-30 14:12:12 +0000
committerbors <bors@rust-lang.org>2019-03-30 14:12:12 +0000
commitfc8581d7420b63b2cc5eac1c57a40de785859448 (patch)
treecb9a00e632f44a35f9d2320df2f4d63fb785fc34 /src/test
parent6c49da45441d29aadd5935dabbaa8dc09ebad33a (diff)
parent04ffaca71a16905d58161e51c1046daebe8dee0b (diff)
downloadrust-fc8581d7420b63b2cc5eac1c57a40de785859448.tar.gz
rust-fc8581d7420b63b2cc5eac1c57a40de785859448.zip
Auto merge of #59561 - Centril:rollup, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #59343 (rustc(codegen): uncache `def_symbol_name` prefix from `symbol_name`.)
 - #59380 (Fix invalid DWARF for enums when using ThinLTO)
 - #59463 (skip dyn keyword lint under macros)
 - #59539 (Fix infinite recursion)
 - #59544 (manifest: only include miri on the nightly channel)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/debuginfo/enum-thinlto.rs48
-rw-r--r--src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed81
-rw-r--r--src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs81
-rw-r--r--src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr133
-rw-r--r--src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs51
-rw-r--r--src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs56
-rw-r--r--src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs27
-rw-r--r--src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs25
8 files changed, 502 insertions, 0 deletions
diff --git a/src/test/debuginfo/enum-thinlto.rs b/src/test/debuginfo/enum-thinlto.rs
new file mode 100644
index 00000000000..7f15ed90e67
--- /dev/null
+++ b/src/test/debuginfo/enum-thinlto.rs
@@ -0,0 +1,48 @@
+// ignore-tidy-linelength
+
+// Require LLVM with DW_TAG_variant_part and a gdb that can read it.
+// min-system-llvm-version: 8.0
+// min-gdb-version: 8.2
+
+// compile-flags:-g -Z thinlto
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:run
+
+// gdb-command:print *abc
+// gdbr-check:$1 = enum_thinlto::ABC::TheA{x: 0, y: 8970181431921507452}
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *abc
+// lldbg-check:(enum_thinlto::ABC) $0 = ABC { }
+
+#![allow(unused_variables)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+#[derive(Debug)]
+enum ABC {
+    TheA { x: i64, y: i64 },
+    TheB (i64, i32, i32),
+}
+
+fn main() {
+    let abc = ABC::TheA { x: 0, y: 0x7c7c_7c7c_7c7c_7c7c };
+
+    f(&abc);
+}
+
+fn f(abc: &ABC) {
+    zzz(); // #break
+
+    println!("{:?}", abc);
+}
+
+fn zzz() {()}
diff --git a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed
new file mode 100644
index 00000000000..003736208ed
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed
@@ -0,0 +1,81 @@
+// Under the 2015 edition with the keyword_idents lint, `dyn` is not
+// entirely acceptable as an identifier. We currently do not attempt
+// to detect or fix uses of `dyn` under a macro. Since we are testing
+// this file via `rustfix`, we want the rustfix output to be
+// compilable; so the macros here carefully use `dyn` "correctly."
+
+// run-rustfix
+
+#![allow(non_camel_case_types)]
+#![deny(keyword_idents)]
+
+mod outer_mod {
+    pub mod r#dyn {
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+        pub struct r#dyn;
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+    }
+}
+use outer_mod::r#dyn::r#dyn;
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+
+fn main() {
+    match r#dyn { r#dyn => {} }
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+    macro_defn::r#dyn();
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+
+    macro_defn::boxed();
+}
+
+mod macro_defn {
+    use super::Trait;
+
+    macro_rules! r#dyn {
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+
+        // Note that we do not lint nor fix occurrences under macros
+        ($dyn:tt) => { (Box<dyn Trait>, Box<$dyn Trait>) }
+    }
+
+    pub fn r#dyn() -> ::outer_mod::r#dyn::r#dyn {
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+        ::outer_mod::r#dyn::r#dyn
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+    }
+
+
+
+    pub fn boxed() -> r#dyn!(
+        //~^ ERROR `dyn` is a keyword
+        //~| WARN was previously accepted
+
+            // Note that we do not lint nor fix occurrences under macros
+            dyn
+    )
+    {
+        (Box::new(1), Box::new(2))
+    }
+}
+
+pub trait Trait { }
+
+impl Trait for u32 { }
diff --git a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs
new file mode 100644
index 00000000000..0e5c39fc501
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs
@@ -0,0 +1,81 @@
+// Under the 2015 edition with the keyword_idents lint, `dyn` is not
+// entirely acceptable as an identifier. We currently do not attempt
+// to detect or fix uses of `dyn` under a macro. Since we are testing
+// this file via `rustfix`, we want the rustfix output to be
+// compilable; so the macros here carefully use `dyn` "correctly."
+
+// run-rustfix
+
+#![allow(non_camel_case_types)]
+#![deny(keyword_idents)]
+
+mod outer_mod {
+    pub mod dyn {
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+        pub struct dyn;
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+    }
+}
+use outer_mod::dyn::dyn;
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+
+fn main() {
+    match dyn { dyn => {} }
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+    macro_defn::dyn();
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+
+    macro_defn::boxed();
+}
+
+mod macro_defn {
+    use super::Trait;
+
+    macro_rules! dyn {
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+
+        // Note that we do not lint nor fix occurrences under macros
+        ($dyn:tt) => { (Box<dyn Trait>, Box<$dyn Trait>) }
+    }
+
+    pub fn dyn() -> ::outer_mod::dyn::dyn {
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+        ::outer_mod::dyn::dyn
+//~^ ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+//~| ERROR `dyn` is a keyword
+//~| WARN was previously accepted
+    }
+
+
+
+    pub fn boxed() -> dyn!(
+        //~^ ERROR `dyn` is a keyword
+        //~| WARN was previously accepted
+
+            // Note that we do not lint nor fix occurrences under macros
+            dyn
+    )
+    {
+        (Box::new(1), Box::new(2))
+    }
+}
+
+pub trait Trait { }
+
+impl Trait for u32 { }
diff --git a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr
new file mode 100644
index 00000000000..361727733bc
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr
@@ -0,0 +1,133 @@
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:13:13
+   |
+LL |     pub mod dyn {
+   |             ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+note: lint level defined here
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:10:9
+   |
+LL | #![deny(keyword_idents)]
+   |         ^^^^^^^^^^^^^^
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:16:20
+   |
+LL |         pub struct dyn;
+   |                    ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:21:16
+   |
+LL | use outer_mod::dyn::dyn;
+   |                ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:21:21
+   |
+LL | use outer_mod::dyn::dyn;
+   |                     ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:28:11
+   |
+LL |     match dyn { dyn => {} }
+   |           ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:28:17
+   |
+LL |     match dyn { dyn => {} }
+   |                 ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:33:17
+   |
+LL |     macro_defn::dyn();
+   |                 ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:43:18
+   |
+LL |     macro_rules! dyn {
+   |                  ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:51:12
+   |
+LL |     pub fn dyn() -> ::outer_mod::dyn::dyn {
+   |            ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:51:34
+   |
+LL |     pub fn dyn() -> ::outer_mod::dyn::dyn {
+   |                                  ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:51:39
+   |
+LL |     pub fn dyn() -> ::outer_mod::dyn::dyn {
+   |                                       ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:58:22
+   |
+LL |         ::outer_mod::dyn::dyn
+   |                      ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:58:27
+   |
+LL |         ::outer_mod::dyn::dyn
+   |                           ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `dyn` is a keyword in the 2018 edition
+  --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:67:23
+   |
+LL |     pub fn boxed() -> dyn!(
+   |                       ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: aborting due to 14 previous errors
+
diff --git a/src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs b/src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs
new file mode 100644
index 00000000000..f535791d7fb
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs
@@ -0,0 +1,51 @@
+// compile-pass
+
+// Under the 2015 edition with the keyword_idents lint, `dyn` is
+// not entirely acceptable as an identifier.
+//
+// We currently do not attempt to detect or fix uses of `dyn` as an
+// identifier under a macro, including under the declarative `macro`
+// forms from macros 1.2 and macros 2.0.
+
+#![feature(decl_macro)]
+#![allow(non_camel_case_types)]
+#![deny(keyword_idents)]
+
+mod outer_mod {
+    pub mod r#dyn {
+        pub struct r#dyn;
+    }
+}
+
+// Here we are illustrating that the current lint does not flag the
+// occurrences of `dyn` in this macro definition; however, it
+// certainly *could* (and it would be nice if it did), since these
+// occurrences are not compatible with the 2018 edition's
+// interpretation of `dyn` as a keyword.
+macro defn_has_dyn_idents() { ::outer_mod::dyn::dyn }
+
+struct X;
+trait Trait { fn hello(&self) { }}
+impl Trait for X { }
+
+macro tt_trait($arg:tt) { & $arg Trait }
+macro id_trait($id:ident) { & $id Trait }
+
+fn main() {
+    defn_has_dyn_idents!();
+
+    // Here we are illustrating that the current lint does not flag
+    // the occurrences of `dyn` in these macro invocations. It
+    // definitely should *not* flag the one in `tt_trait`, since that
+    // is expanding in a valid fashion to `&dyn Trait`.
+    //
+    // It is arguable whether it would be valid to flag the occurrence
+    // in `id_trait`, since that macro specifies that it takes an
+    // `ident` as its input.
+    fn f_tt(x: &X) -> tt_trait!(dyn) { x }
+    fn f_id(x: &X) -> id_trait!(dyn) { x }
+
+    let x = X;
+    f_tt(&x).hello();
+    f_id(&x).hello();
+}
diff --git a/src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs b/src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs
new file mode 100644
index 00000000000..27e49055868
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs
@@ -0,0 +1,56 @@
+// compile-pass
+
+// Under the 2015 edition with the keyword_idents lint, `dyn` is
+// not entirely acceptable as an identifier.
+//
+// We currently do not attempt to detect or fix uses of `dyn` as an
+// identifier under a macro.
+
+#![allow(non_camel_case_types)]
+#![deny(keyword_idents)]
+
+mod outer_mod {
+    pub mod r#dyn {
+        pub struct r#dyn;
+    }
+}
+
+// Here we are illustrating that the current lint does not flag the
+// occurrences of `dyn` in this macro definition; however, it
+// certainly *could* (and it would be nice if it did), since these
+// occurrences are not compatible with the 2018 edition's
+// interpretation of `dyn` as a keyword.
+macro_rules! defn_has_dyn_idents {
+    () => { ::outer_mod::dyn::dyn }
+}
+
+struct X;
+trait Trait { fn hello(&self) { }}
+impl Trait for X { }
+
+macro_rules! tt_trait {
+    ($arg:tt) => { & $arg Trait }
+}
+
+macro_rules! id_trait {
+    ($id:ident) => { & $id Trait }
+}
+
+fn main() {
+    defn_has_dyn_idents!();
+
+    // Here we are illustrating that the current lint does not flag
+    // the occurrences of `dyn` in these macro invocations. It
+    // definitely should *not* flag the one in `tt_trait`, since that
+    // is expanding in a valid fashion to `&dyn Trait`.
+    //
+    // It is arguable whether it would be valid to flag the occurrence
+    // in `id_trait`, since that macro specifies that it takes an
+    // `ident` as its input.
+    fn f_tt(x: &X) -> tt_trait!(dyn) { x }
+    fn f_id(x: &X) -> id_trait!(dyn) { x }
+
+    let x = X;
+    f_tt(&x).hello();
+    f_id(&x).hello();
+}
diff --git a/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs b/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs
new file mode 100644
index 00000000000..8cef5c2b349
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs
@@ -0,0 +1,27 @@
+// Under the 2015 edition without the keyword_idents lint, `dyn` is
+// entirely acceptable as an identifier.
+
+// compile-pass
+
+#![allow(non_camel_case_types)]
+
+mod outer_mod {
+    pub mod dyn {
+        pub struct dyn;
+    }
+}
+use outer_mod::dyn::dyn;
+
+fn main() {
+    match dyn { dyn => {} }
+    macro_defn::dyn();
+}
+mod macro_defn {
+    macro_rules! dyn {
+        () => { ::outer_mod::dyn::dyn }
+    }
+
+    pub fn dyn() -> ::outer_mod::dyn::dyn {
+        dyn!()
+    }
+}
diff --git a/src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs b/src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs
new file mode 100644
index 00000000000..ff3830d6175
--- /dev/null
+++ b/src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs
@@ -0,0 +1,25 @@
+// compile-pass
+
+// rust-lang/rust#56327: Some occurrences of `dyn` within a macro are
+// not instances of identifiers, and thus should *not* be caught by the
+// keyword_ident lint.
+//
+// Otherwise, rustfix replaces the type `Box<dyn Drop>` with
+// `Box<r#dyn Drop>`, which is injecting a bug rather than fixing
+// anything.
+
+#![deny(rust_2018_compatibility)]
+
+macro_rules! foo {
+    () => {
+        fn generated_foo() {
+            let _x: Box<dyn Drop>;
+        }
+    }
+}
+
+foo!();
+
+fn main() {
+    generated_foo();
+}