diff options
| author | bors <bors@rust-lang.org> | 2019-03-31 17:21:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-03-31 17:21:14 +0000 |
| commit | 4fac5c98b22faa7fce2d5d64bf34c61340883302 (patch) | |
| tree | 9c75e0759b74f210c61fcc192fdd1b05d9784df9 /src/test | |
| parent | a89c03a30a1e8f1cd190114b765d01752d3ce8d8 (diff) | |
| parent | 34454451a19210341263ea32962d96f41faec2a5 (diff) | |
| download | rust-4fac5c98b22faa7fce2d5d64bf34c61340883302.tar.gz rust-4fac5c98b22faa7fce2d5d64bf34c61340883302.zip | |
Auto merge of #59590 - Centril:rollup, r=Centril
Rollup of 7 pull requests Successful merges: - #58805 (Lint for redundant imports) - #59506 (Use platform dependent mcount function) - #59519 (rustc_target: factor out common fields of non-Single Variants.) - #59580 (Allow closure to unsafe fn coercion) - #59581 (Stabilize refcell_replace_swap feature) - #59583 (match match match match match) - #59587 (Remove #[doc(hidden)] from Error::type_id) Failed merges: r? @ghost
Diffstat (limited to 'src/test')
18 files changed, 127 insertions, 20 deletions
diff --git a/src/test/codegen/instrument-mcount.rs b/src/test/codegen/instrument-mcount.rs new file mode 100644 index 00000000000..c72d09f7a03 --- /dev/null +++ b/src/test/codegen/instrument-mcount.rs @@ -0,0 +1,7 @@ +// ignore-tidy-linelength +// compile-flags: -Z instrument-mcount + +#![crate_type = "lib"] + +// CHECK: attributes #{{.*}} "instrument-function-entry-inlined"="{{.*}}mcount{{.*}}" "no-frame-pointer-elim"="true" +pub fn foo() {} diff --git a/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs b/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs new file mode 100644 index 00000000000..36777693fab --- /dev/null +++ b/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs @@ -0,0 +1,5 @@ +fn main() { + let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); }; + //~^ ERROR E0133 + let _: unsafe fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK +} diff --git a/src/test/run-pass/binding/match-arm-statics.rs b/src/test/run-pass/binding/match-arm-statics.rs index 359c3921158..5f7e357eeb2 100644 --- a/src/test/run-pass/binding/match-arm-statics.rs +++ b/src/test/run-pass/binding/match-arm-statics.rs @@ -45,8 +45,6 @@ pub mod glfw { } fn issue_6533() { - use glfw; - fn action_to_str(state: glfw::InputState) -> &'static str { use glfw::{RELEASE, PRESS, REPEAT}; match state { diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 56222fa46f7..8c17b01e2bd 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -238,7 +238,6 @@ pub fn main() { // Basic test to make sure that we can invoke the `write!` macro with an // fmt::Write instance. fn test_write() { - use std::fmt::Write; let mut buf = String::new(); write!(&mut buf, "{}", 3); { @@ -267,7 +266,6 @@ fn test_print() { // Just make sure that the macros are defined, there's not really a lot that we // can do with them just yet (to test the output) fn test_format_args() { - use std::fmt::Write; let mut buf = String::new(); { let w = &mut buf; diff --git a/src/test/run-pass/invalid_const_promotion.rs b/src/test/run-pass/invalid_const_promotion.rs index 1524373895d..2775aac0156 100644 --- a/src/test/run-pass/invalid_const_promotion.rs +++ b/src/test/run-pass/invalid_const_promotion.rs @@ -25,7 +25,6 @@ fn foo() { #[cfg(unix)] fn check_status(status: std::process::ExitStatus) { - use libc; use std::os::unix::process::ExitStatusExt; assert!(status.signal() == Some(libc::SIGILL) diff --git a/src/test/run-pass/issues/issue-38556.rs b/src/test/run-pass/issues/issue-38556.rs index 0cc247f5b9c..63fd9db08ff 100644 --- a/src/test/run-pass/issues/issue-38556.rs +++ b/src/test/run-pass/issues/issue-38556.rs @@ -9,6 +9,5 @@ macro_rules! reexport { reexport!(); fn main() { - use Bar; fn f(_: Bar) {} } diff --git a/src/test/run-pass/issues/issue-39367.rs b/src/test/run-pass/issues/issue-39367.rs index bd92224bce1..484cd782a09 100644 --- a/src/test/run-pass/issues/issue-39367.rs +++ b/src/test/run-pass/issues/issue-39367.rs @@ -15,7 +15,6 @@ fn arena() -> &'static ArenaSet<Vec<u8>> { fn require_sync<T: Sync>(_: &T) { } unsafe fn __stability() -> &'static ArenaSet<Vec<u8>> { use std::mem::transmute; - use std::boxed::Box; static mut DATA: *const ArenaSet<Vec<u8>> = 0 as *const ArenaSet<Vec<u8>>; static mut ONCE: Once = ONCE_INIT; diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs index 72d6d680622..9f868d6e5c3 100644 --- a/src/test/run-pass/out-of-stack.rs +++ b/src/test/run-pass/out-of-stack.rs @@ -36,7 +36,6 @@ fn loud_recurse() { #[cfg(unix)] fn check_status(status: std::process::ExitStatus) { - use libc; use std::os::unix::process::ExitStatusExt; assert!(!status.success()); diff --git a/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs b/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs index 15449a6b83e..566b3581046 100644 --- a/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs +++ b/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs @@ -4,6 +4,8 @@ // compile-flags:--extern xcrate // edition:2018 +#![allow(unused_imports)] + use xcrate::Z; fn f() { diff --git a/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs b/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs index ca47d9736f6..626e1ae71bc 100644 --- a/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs +++ b/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs @@ -28,7 +28,6 @@ where T : Convert<U> } fn main() { - use std::default::Default; // T = i16, U = u32 test(22_i16, Default::default(), 2, 4); diff --git a/src/test/run-pass/typeck-closure-to-unsafe-fn-ptr.rs b/src/test/run-pass/typeck-closure-to-unsafe-fn-ptr.rs new file mode 100644 index 00000000000..fe15b912d60 --- /dev/null +++ b/src/test/run-pass/typeck-closure-to-unsafe-fn-ptr.rs @@ -0,0 +1,7 @@ +unsafe fn call_unsafe(func: unsafe fn() -> ()) -> () { + func() +} + +pub fn main() { + unsafe { call_unsafe(|| {}); } +} diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 7ce7e29e872..ae4de92ff74 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -127,6 +127,21 @@ fn punch_card() -> impl std::fmt::Debug { ..=.. ..=.. .. ..=..=.. ..=..=.. .. .. ..=.. .. } +fn r#match() { + let val = match match match match match () { + () => () + } { + () => () + } { + () => () + } { + () => () + } { + () => () + }; + assert_eq!(val, ()); +} + pub fn main() { strange(); funny(); @@ -142,4 +157,5 @@ pub fn main() { union(); special_characters(); punch_card(); + r#match(); } diff --git a/src/test/ui/lint/lint-unused-imports.rs b/src/test/ui/lint/lint-unused-imports.rs index 9c5b206203c..4754d888076 100644 --- a/src/test/ui/lint/lint-unused-imports.rs +++ b/src/test/ui/lint/lint-unused-imports.rs @@ -66,6 +66,7 @@ mod bar { fn g() { use self::g; //~ ERROR unused import: `self::g` + //~^ ERROR the item `g` is imported redundantly fn f() { self::g(); } @@ -75,6 +76,7 @@ fn g() { #[allow(unused_variables)] fn h() { use test2::foo; //~ ERROR unused import: `test2::foo` + //~^ ERROR the item `foo` is imported redundantly let foo = 0; } diff --git a/src/test/ui/lint/lint-unused-imports.stderr b/src/test/ui/lint/lint-unused-imports.stderr index f9a54f477f9..96d71a228a5 100644 --- a/src/test/ui/lint/lint-unused-imports.stderr +++ b/src/test/ui/lint/lint-unused-imports.stderr @@ -34,14 +34,36 @@ error: unused import: `foo::Square` LL | use foo::Square; | ^^^^^^^^^^^ +error: the item `g` is imported redundantly + --> $DIR/lint-unused-imports.rs:68:9 + | +LL | / fn g() { +LL | | use self::g; + | | ^^^^^^^ +LL | | +LL | | fn f() { +LL | | self::g(); +LL | | } +LL | | } + | |_- the item `g` is already defined here + error: unused import: `self::g` --> $DIR/lint-unused-imports.rs:68:9 | LL | use self::g; | ^^^^^^^ +error: the item `foo` is imported redundantly + --> $DIR/lint-unused-imports.rs:78:9 + | +LL | use test2::{foo, bar}; + | --- the item `foo` is already imported here +... +LL | use test2::foo; + | ^^^^^^^^^^ + error: unused import: `test2::foo` - --> $DIR/lint-unused-imports.rs:77:9 + --> $DIR/lint-unused-imports.rs:78:9 | LL | use test2::foo; | ^^^^^^^^^^ @@ -52,5 +74,5 @@ error: unused import: `test::B2` LL | use test::B2; | ^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 10 previous errors diff --git a/src/test/ui/lint/use-redundant.rs b/src/test/ui/lint/use-redundant.rs new file mode 100644 index 00000000000..328f8232baf --- /dev/null +++ b/src/test/ui/lint/use-redundant.rs @@ -0,0 +1,27 @@ +// compile-pass +#![warn(unused_imports)] + +use crate::foo::Bar; //~ WARNING first import + +mod foo { + pub type Bar = i32; +} + +fn baz() -> Bar { + 3 +} + +mod m1 { pub struct S {} } +mod m2 { pub struct S {} } + +use m1::*; +use m2::*; + +fn main() { + use crate::foo::Bar; //~ WARNING redundant import + let _a: Bar = 3; + baz(); + + use m1::S; //~ WARNING redundant import + let _s = S {}; +} diff --git a/src/test/ui/lint/use-redundant.stderr b/src/test/ui/lint/use-redundant.stderr new file mode 100644 index 00000000000..fbd9f81f18f --- /dev/null +++ b/src/test/ui/lint/use-redundant.stderr @@ -0,0 +1,27 @@ +warning: unused import: `m1::*` + --> $DIR/use-redundant.rs:17:5 + | +LL | use m1::*; + | ^^^^^ + | +note: lint level defined here + --> $DIR/use-redundant.rs:2:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +warning: unused import: `m2::*` + --> $DIR/use-redundant.rs:18:5 + | +LL | use m2::*; + | ^^^^^ + +warning: the item `Bar` is imported redundantly + --> $DIR/use-redundant.rs:21:9 + | +LL | use crate::foo::Bar; + | --------------- the item `Bar` is already imported here +... +LL | use crate::foo::Bar; + | ^^^^^^^^^^^^^^^ + diff --git a/src/test/ui/rust-2018/future-proofing-locals.rs b/src/test/ui/rust-2018/future-proofing-locals.rs index 1e53c2d1dac..2c388cf3713 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.rs +++ b/src/test/ui/rust-2018/future-proofing-locals.rs @@ -1,6 +1,7 @@ // edition:2018 #![allow(non_camel_case_types)] +#![allow(unused_imports)] mod T { pub struct U; diff --git a/src/test/ui/rust-2018/future-proofing-locals.stderr b/src/test/ui/rust-2018/future-proofing-locals.stderr index 4d666d22afe..7021489a6dd 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.stderr +++ b/src/test/ui/rust-2018/future-proofing-locals.stderr @@ -1,53 +1,53 @@ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:13:9 + --> $DIR/future-proofing-locals.rs:14:9 | LL | use T as _; | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:14:9 + --> $DIR/future-proofing-locals.rs:15:9 | LL | use T::U; | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:15:9 + --> $DIR/future-proofing-locals.rs:16:9 | LL | use T::*; | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:19:9 + --> $DIR/future-proofing-locals.rs:20:9 | LL | use T; | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:25:9 + --> $DIR/future-proofing-locals.rs:26:9 | LL | use x as _; | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:31:9 + --> $DIR/future-proofing-locals.rs:32:9 | LL | use x; | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:37:17 + --> $DIR/future-proofing-locals.rs:38:17 | LL | use x; | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:45:10 + --> $DIR/future-proofing-locals.rs:46:10 | LL | use {T as _, x}; | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:45:18 + --> $DIR/future-proofing-locals.rs:46:18 | LL | use {T as _, x}; | ^ |
