tests: Move run-pass tests without naming conflicts to ui
This commit is contained in:
parent
ca9faa52f5
commit
9be35f82c1
3226 changed files with 64 additions and 196 deletions
7
src/test/ui/uniform-paths/auxiliary/issue-53691.rs
Normal file
7
src/test/ui/uniform-paths/auxiliary/issue-53691.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// edition:2018
|
||||
|
||||
mod m { pub fn f() {} }
|
||||
mod n { pub fn g() {} }
|
||||
|
||||
pub use m::f;
|
||||
pub use n::g;
|
||||
61
src/test/ui/uniform-paths/basic-nested.rs
Normal file
61
src/test/ui/uniform-paths/basic-nested.rs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// This test is similar to `basic.rs`, but nested in modules.
|
||||
|
||||
// run-pass
|
||||
// edition:2018
|
||||
|
||||
#![feature(decl_macro)]
|
||||
|
||||
#![allow(unused_imports)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
mod foo {
|
||||
// Test that ambiguity errors are not emitted between `self::test` and
|
||||
// `::test`, assuming the latter (crate) is not in `extern_prelude`.
|
||||
mod test {
|
||||
pub struct Foo(pub ());
|
||||
}
|
||||
pub use test::Foo;
|
||||
|
||||
// Test that qualified paths can refer to both the external crate and local item.
|
||||
mod std {
|
||||
pub struct io(pub ());
|
||||
}
|
||||
pub use ::std::io as std_io;
|
||||
pub use self::std::io as local_io;
|
||||
}
|
||||
|
||||
// Test that we can refer to the external crate unqualified
|
||||
// (when there isn't a local item with the same name).
|
||||
use std::io;
|
||||
|
||||
mod bar {
|
||||
// Also test the unqualified external crate import in a nested module,
|
||||
// to show that the above import doesn't resolve through a local `std`
|
||||
// item, e.g., the automatically injected `extern crate std;`, which in
|
||||
// the Rust 2018 should no longer be visible through `crate::std`.
|
||||
pub use std::io;
|
||||
|
||||
// Also test that items named `std` in other namespaces don't
|
||||
// cause ambiguity errors for the import from `std` above.
|
||||
pub fn std() {}
|
||||
pub macro std() {}
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
foo::Foo(());
|
||||
foo::std_io::stdout();
|
||||
foo::local_io(());
|
||||
io::stdout();
|
||||
bar::io::stdout();
|
||||
bar::std();
|
||||
bar::std!();
|
||||
|
||||
{
|
||||
// Test that having `io` in a module scope and a non-module
|
||||
// scope is allowed, when both resolve to the same definition.
|
||||
use std::io;
|
||||
use io::stdout;
|
||||
stdout();
|
||||
}
|
||||
}
|
||||
33
src/test/ui/uniform-paths/basic.rs
Normal file
33
src/test/ui/uniform-paths/basic.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// run-pass
|
||||
// edition:2018
|
||||
|
||||
#![allow(unused_imports)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
// Test that ambiguity errors are not emitted between `self::test` and
|
||||
// `::test`, assuming the latter (crate) is not in `extern_prelude`.
|
||||
mod test {
|
||||
pub struct Foo(pub ());
|
||||
}
|
||||
use test::Foo;
|
||||
|
||||
// Test that qualified paths can refer to both the external crate and local item.
|
||||
mod std {
|
||||
pub struct io(pub ());
|
||||
}
|
||||
use ::std::io as std_io;
|
||||
use self::std::io as local_io;
|
||||
|
||||
fn main() {
|
||||
Foo(());
|
||||
std_io::stdout();
|
||||
local_io(());
|
||||
|
||||
{
|
||||
// Test that having `std_io` in a module scope and a non-module
|
||||
// scope is allowed, when both resolve to the same definition.
|
||||
use ::std::io as std_io;
|
||||
use std_io::stdout;
|
||||
stdout();
|
||||
}
|
||||
}
|
||||
9
src/test/ui/uniform-paths/issue-53691.rs
Normal file
9
src/test/ui/uniform-paths/issue-53691.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// run-pass
|
||||
// aux-build:issue-53691.rs
|
||||
|
||||
extern crate issue_53691;
|
||||
|
||||
fn main() {
|
||||
issue_53691::f();
|
||||
issue_53691::g();
|
||||
}
|
||||
53
src/test/ui/uniform-paths/macros-nested.rs
Normal file
53
src/test/ui/uniform-paths/macros-nested.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// This test is similar to `macros.rs`, but nested in modules.
|
||||
|
||||
// run-pass
|
||||
// edition:2018
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
mod foo {
|
||||
// Test that ambiguity errors are not emitted between `self::test` and
|
||||
// `::test`, assuming the latter (crate) is not in `extern_prelude`.
|
||||
macro_rules! m1 {
|
||||
() => {
|
||||
mod test {
|
||||
pub struct Foo(pub ());
|
||||
}
|
||||
}
|
||||
}
|
||||
pub use test::Foo;
|
||||
m1!();
|
||||
|
||||
// Test that qualified paths can refer to both the external crate and local item.
|
||||
macro_rules! m2 {
|
||||
() => {
|
||||
mod std {
|
||||
pub struct io(pub ());
|
||||
}
|
||||
}
|
||||
}
|
||||
pub use ::std::io as std_io;
|
||||
pub use self::std::io as local_io;
|
||||
m2!();
|
||||
}
|
||||
|
||||
// Test that we can refer to the external crate unqualified
|
||||
// (when there isn't a local item with the same name).
|
||||
use std::io;
|
||||
|
||||
mod bar {
|
||||
// Also test the unqualified external crate import in a nested module,
|
||||
// to show that the above import doesn't resolve through a local `std`
|
||||
// item, e.g., the automatically injected `extern crate std;`, which in
|
||||
// the Rust 2018 should no longer be visible through `crate::std`.
|
||||
pub use std::io;
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
foo::Foo(());
|
||||
foo::std_io::stdout();
|
||||
foo::local_io(());
|
||||
io::stdout();
|
||||
bar::io::stdout();
|
||||
}
|
||||
36
src/test/ui/uniform-paths/macros.rs
Normal file
36
src/test/ui/uniform-paths/macros.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// This test is similar to `basic.rs`, but with macros defining local items.
|
||||
|
||||
// run-pass
|
||||
// edition:2018
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
// Test that ambiguity errors are not emitted between `self::test` and
|
||||
// `::test`, assuming the latter (crate) is not in `extern_prelude`.
|
||||
macro_rules! m1 {
|
||||
() => {
|
||||
mod test {
|
||||
pub struct Foo(pub ());
|
||||
}
|
||||
}
|
||||
}
|
||||
use test::Foo;
|
||||
m1!();
|
||||
|
||||
// Test that qualified paths can refer to both the external crate and local item.
|
||||
macro_rules! m2 {
|
||||
() => {
|
||||
mod std {
|
||||
pub struct io(pub ());
|
||||
}
|
||||
}
|
||||
}
|
||||
use ::std::io as std_io;
|
||||
use self::std::io as local_io;
|
||||
m2!();
|
||||
|
||||
fn main() {
|
||||
Foo(());
|
||||
std_io::stdout();
|
||||
local_io(());
|
||||
}
|
||||
98
src/test/ui/uniform-paths/same-crate.rs
Normal file
98
src/test/ui/uniform-paths/same-crate.rs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
// run-pass
|
||||
// edition:2018
|
||||
|
||||
pub const A: usize = 0;
|
||||
|
||||
pub mod foo {
|
||||
pub const B: usize = 1;
|
||||
|
||||
pub mod bar {
|
||||
pub const C: usize = 2;
|
||||
|
||||
pub enum E {
|
||||
V1(usize),
|
||||
V2(String),
|
||||
}
|
||||
|
||||
pub fn test() -> String {
|
||||
format!("{} {} {}", crate::A, crate::foo::B, C)
|
||||
}
|
||||
|
||||
pub fn test_use() -> String {
|
||||
use crate::A;
|
||||
use crate::foo::B;
|
||||
|
||||
format!("{} {} {}", A, B, C)
|
||||
}
|
||||
|
||||
pub fn test_enum() -> String {
|
||||
use E::*;
|
||||
match E::V1(10) {
|
||||
V1(i) => { format!("V1: {}", i) }
|
||||
V2(s) => { format!("V2: {}", s) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn test() -> String {
|
||||
format!("{} {} {}", crate::A, B, bar::C)
|
||||
}
|
||||
|
||||
pub fn test_use() -> String {
|
||||
use crate::A;
|
||||
use bar::C;
|
||||
|
||||
format!("{} {} {}", A, B, C)
|
||||
}
|
||||
|
||||
pub fn test_enum() -> String {
|
||||
use bar::E::*;
|
||||
match bar::E::V1(10) {
|
||||
V1(i) => { format!("V1: {}", i) }
|
||||
V2(s) => { format!("V2: {}", s) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn test() -> String {
|
||||
format!("{} {} {}", A, foo::B, foo::bar::C)
|
||||
}
|
||||
|
||||
pub fn test_use() -> String {
|
||||
use foo::B;
|
||||
use foo::bar::C;
|
||||
|
||||
format!("{} {} {}", A, B, C)
|
||||
}
|
||||
|
||||
pub fn test_enum() -> String {
|
||||
use foo::bar::E::*;
|
||||
match foo::bar::E::V1(10) {
|
||||
V1(i) => { format!("V1: {}", i) }
|
||||
V2(s) => { format!("V2: {}", s) }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let output = [
|
||||
test(),
|
||||
foo::test(),
|
||||
foo::bar::test(),
|
||||
test_use(),
|
||||
foo::test_use(),
|
||||
foo::bar::test_use(),
|
||||
test_enum(),
|
||||
foo::test_enum(),
|
||||
foo::bar::test_enum(),
|
||||
].join("\n");
|
||||
assert_eq!(output, "\
|
||||
0 1 2
|
||||
0 1 2
|
||||
0 1 2
|
||||
0 1 2
|
||||
0 1 2
|
||||
0 1 2
|
||||
V1: 10
|
||||
V1: 10
|
||||
V1: 10");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue