diff --git a/tests/ui/errors/auxiliary/file-debuginfo.rs b/tests/ui/errors/auxiliary/file-debuginfo.rs new file mode 100644 index 0000000000000..08113ec26bfd4 --- /dev/null +++ b/tests/ui/errors/auxiliary/file-debuginfo.rs @@ -0,0 +1,11 @@ +//@ compile-flags: --remap-path-prefix={{src-base}}=remapped +//@ compile-flags: -Zremap-path-scope=debuginfo + +#[macro_export] +macro_rules! my_file { + () => { file!() } +} + +pub fn file() -> &'static str { + file!() +} diff --git a/tests/ui/errors/auxiliary/file-diag.rs b/tests/ui/errors/auxiliary/file-diag.rs new file mode 100644 index 0000000000000..f29c349f703b2 --- /dev/null +++ b/tests/ui/errors/auxiliary/file-diag.rs @@ -0,0 +1,11 @@ +//@ compile-flags: --remap-path-prefix={{src-base}}=remapped +//@ compile-flags: -Zremap-path-scope=diagnostics + +#[macro_export] +macro_rules! my_file { + () => { file!() } +} + +pub fn file() -> &'static str { + file!() +} diff --git a/tests/ui/errors/auxiliary/file-macro.rs b/tests/ui/errors/auxiliary/file-macro.rs new file mode 100644 index 0000000000000..11abc0549a7b8 --- /dev/null +++ b/tests/ui/errors/auxiliary/file-macro.rs @@ -0,0 +1,11 @@ +//@ compile-flags: --remap-path-prefix={{src-base}}=remapped +//@ compile-flags: -Zremap-path-scope=macro + +#[macro_export] +macro_rules! my_file { + () => { file!() } +} + +pub fn file() -> &'static str { + file!() +} diff --git a/tests/ui/errors/auxiliary/file.rs b/tests/ui/errors/auxiliary/file.rs new file mode 100644 index 0000000000000..63a7b3b58f0f5 --- /dev/null +++ b/tests/ui/errors/auxiliary/file.rs @@ -0,0 +1,8 @@ +#[macro_export] +macro_rules! my_file { + () => { file!() } +} + +pub fn file() -> &'static str { + file!() +} diff --git a/tests/ui/errors/auxiliary/trait-debuginfo.rs b/tests/ui/errors/auxiliary/trait-debuginfo.rs new file mode 100644 index 0000000000000..d5a0825fe6d13 --- /dev/null +++ b/tests/ui/errors/auxiliary/trait-debuginfo.rs @@ -0,0 +1,4 @@ +//@ compile-flags: --remap-path-prefix={{src-base}}=remapped +//@ compile-flags: -Zremap-path-scope=debuginfo + +pub trait Trait: std::fmt::Display {} diff --git a/tests/ui/errors/auxiliary/trait-diag.rs b/tests/ui/errors/auxiliary/trait-diag.rs new file mode 100644 index 0000000000000..e07961a276a9d --- /dev/null +++ b/tests/ui/errors/auxiliary/trait-diag.rs @@ -0,0 +1,4 @@ +//@ compile-flags: --remap-path-prefix={{src-base}}=remapped +//@ compile-flags: -Zremap-path-scope=diagnostics + +pub trait Trait: std::fmt::Display {} diff --git a/tests/ui/errors/auxiliary/trait-macro.rs b/tests/ui/errors/auxiliary/trait-macro.rs new file mode 100644 index 0000000000000..48673d04ee16f --- /dev/null +++ b/tests/ui/errors/auxiliary/trait-macro.rs @@ -0,0 +1,4 @@ +//@ compile-flags: --remap-path-prefix={{src-base}}=remapped +//@ compile-flags: -Zremap-path-scope=macro + +pub trait Trait: std::fmt::Display {} diff --git a/tests/ui/errors/auxiliary/trait.rs b/tests/ui/errors/auxiliary/trait.rs new file mode 100644 index 0000000000000..0e7e5400aac59 --- /dev/null +++ b/tests/ui/errors/auxiliary/trait.rs @@ -0,0 +1 @@ +pub trait Trait: std::fmt::Display {} diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr new file mode 100644 index 0000000000000..3ddff11798de3 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr @@ -0,0 +1,17 @@ +error[E0277]: `A` doesn't implement `std::fmt::Display` + --> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL + | +LL | impl r#trait::Trait for A {} + | ^ `A` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `A` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Trait` + --> $DIR/auxiliary/trait.rs:LL:COL + | +LL | pub trait Trait: std::fmt::Display {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr new file mode 100644 index 0000000000000..85c781425b16a --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr @@ -0,0 +1,17 @@ +error[E0277]: `A` doesn't implement `std::fmt::Display` + --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL + | +LL | impl r#trait::Trait for A {} + | ^ `A` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `A` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Trait` + --> $DIR/auxiliary/trait-debuginfo.rs:LL:COL + | +LL | pub trait Trait: std::fmt::Display {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr new file mode 100644 index 0000000000000..792ea7925ad56 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr @@ -0,0 +1,17 @@ +error[E0277]: `A` doesn't implement `std::fmt::Display` + --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL + | +LL | impl r#trait::Trait for A {} + | ^ `A` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `A` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Trait` + --> $DIR/auxiliary/trait-diag.rs:LL:COL + | +LL | pub trait Trait: std::fmt::Display {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr new file mode 100644 index 0000000000000..d13333d2e4825 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr @@ -0,0 +1,17 @@ +error[E0277]: `A` doesn't implement `std::fmt::Display` + --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL + | +LL | impl r#trait::Trait for A {} + | ^ `A` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `A` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Trait` + --> $DIR/auxiliary/trait-macro.rs:LL:COL + | +LL | pub trait Trait: std::fmt::Display {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.rs b/tests/ui/errors/remap-path-prefix-diagnostics.rs new file mode 100644 index 0000000000000..fac7e937cb0b8 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.rs @@ -0,0 +1,57 @@ +// This test exercises `-Zremap-path-scope`, diagnostics printing paths and dependency. +// +// We test different combinations with/without remap in deps, with/without remap in this +// crate but always in deps and always here but never in deps. + +//@ revisions: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps +//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps +//@ revisions: not-diag-in-deps + +//@[with-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped +//@[with-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped +//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped +//@[not-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped + +//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics +//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro +//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo +//@[not-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics + +//@[with-diag-in-deps] aux-build:trait-diag.rs +//@[with-macro-in-deps] aux-build:trait-macro.rs +//@[with-debuginfo-in-deps] aux-build:trait-debuginfo.rs +//@[only-diag-in-deps] aux-build:trait-diag.rs +//@[only-macro-in-deps] aux-build:trait-macro.rs +//@[only-debuginfo-in-deps] aux-build:trait-debuginfo.rs +//@[not-diag-in-deps] aux-build:trait.rs + +// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically +// as the remapped revision will not begin with $SRC_DIR_REAL, +// so we have to do it ourselves. +//@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:COL" + +#[cfg(any(with_diag_in_deps, only_diag_in_deps))] +extern crate trait_diag as r#trait; + +#[cfg(any(with_macro_in_deps, only_macro_in_deps))] +extern crate trait_macro as r#trait; + +#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))] +extern crate trait_debuginfo as r#trait; + +#[cfg(not_diag_in_deps)] +extern crate r#trait as r#trait; + +struct A; + +impl r#trait::Trait for A {} +//[with-macro-in-deps]~^ ERROR `A` doesn't implement `std::fmt::Display` +//[with-debuginfo-in-deps]~^^ ERROR `A` doesn't implement `std::fmt::Display` +//[only-diag-in-deps]~^^^ ERROR `A` doesn't implement `std::fmt::Display` +//[only-macro-in-deps]~^^^^ ERROR `A` doesn't implement `std::fmt::Display` +//[only-debuginfo-in-deps]~^^^^^ ERROR `A` doesn't implement `std::fmt::Display` + +//[with-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display` +//[not-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display` + +fn main() {} diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr new file mode 100644 index 0000000000000..85c781425b16a --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr @@ -0,0 +1,17 @@ +error[E0277]: `A` doesn't implement `std::fmt::Display` + --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL + | +LL | impl r#trait::Trait for A {} + | ^ `A` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `A` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Trait` + --> $DIR/auxiliary/trait-debuginfo.rs:LL:COL + | +LL | pub trait Trait: std::fmt::Display {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr new file mode 100644 index 0000000000000..08f7fb2c73642 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr @@ -0,0 +1,17 @@ +error[E0277]: `A` doesn't implement `std::fmt::Display` + --> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL + | +LL | impl r#trait::Trait for A {} + | ^ `A` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `A` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Trait` + --> remapped/errors/auxiliary/trait-diag.rs:LL:COL + | +LL | pub trait Trait: std::fmt::Display {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr new file mode 100644 index 0000000000000..d13333d2e4825 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr @@ -0,0 +1,17 @@ +error[E0277]: `A` doesn't implement `std::fmt::Display` + --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL + | +LL | impl r#trait::Trait for A {} + | ^ `A` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `A` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Trait` + --> $DIR/auxiliary/trait-macro.rs:LL:COL + | +LL | pub trait Trait: std::fmt::Display {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout b/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout deleted file mode 100644 index 3bbdcbb8655b2..0000000000000 --- a/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout +++ /dev/null @@ -1 +0,0 @@ -remapped/errors/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.not-macro-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.not-macro-in-deps.run.stdout new file mode 100644 index 0000000000000..13d4611ae543c --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.not-macro-in-deps.run.stdout @@ -0,0 +1,3 @@ +file::my_file!() = remapped/errors/remap-path-prefix-macro.rs +file::file() = $DIR/auxiliary/file.rs +file!() = remapped/errors/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.only-debuginfo-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.only-debuginfo-in-deps.run.stdout new file mode 100644 index 0000000000000..b2c62ac88c04c --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.only-debuginfo-in-deps.run.stdout @@ -0,0 +1,3 @@ +file::my_file!() = $DIR/remap-path-prefix-macro.rs +file::file() = $DIR/auxiliary/file-debuginfo.rs +file!() = $DIR/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.only-diag-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.only-diag-in-deps.run.stdout new file mode 100644 index 0000000000000..e64cc0723619c --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.only-diag-in-deps.run.stdout @@ -0,0 +1,3 @@ +file::my_file!() = $DIR/remap-path-prefix-macro.rs +file::file() = $DIR/auxiliary/file-diag.rs +file!() = $DIR/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.only-macro-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.only-macro-in-deps.run.stdout new file mode 100644 index 0000000000000..b1a93a5bc1ea2 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.only-macro-in-deps.run.stdout @@ -0,0 +1,3 @@ +file::my_file!() = $DIR/remap-path-prefix-macro.rs +file::file() = remapped/errors/auxiliary/file-macro.rs +file!() = $DIR/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.rs b/tests/ui/errors/remap-path-prefix-macro.rs index 665156027c995..3e93843f91641 100644 --- a/tests/ui/errors/remap-path-prefix-macro.rs +++ b/tests/ui/errors/remap-path-prefix-macro.rs @@ -1,12 +1,47 @@ +// This test exercises `-Zremap-path-scope`, macros (like file!()) and dependency. +// +// We test different combinations with/without remap in deps, with/without remap in +// this crate but always in deps and always here but never in deps. + //@ run-pass //@ check-run-results -//@ revisions: normal with-macro-scope without-macro-scope -//@ compile-flags: --remap-path-prefix={{src-base}}=remapped -//@ [with-macro-scope]compile-flags: -Zremap-path-scope=macro,diagnostics -//@ [without-macro-scope]compile-flags: -Zremap-path-scope=diagnostics -// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file. +//@ revisions: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps +//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps +//@ revisions: not-macro-in-deps + +//@[with-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped +//@[with-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped +//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped +//@[not-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped + +//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics +//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro +//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo +//@[not-macro-in-deps] compile-flags: -Zremap-path-scope=macro + +//@[with-diag-in-deps] aux-build:file-diag.rs +//@[with-macro-in-deps] aux-build:file-macro.rs +//@[with-debuginfo-in-deps] aux-build:file-debuginfo.rs +//@[only-diag-in-deps] aux-build:file-diag.rs +//@[only-macro-in-deps] aux-build:file-macro.rs +//@[only-debuginfo-in-deps] aux-build:file-debuginfo.rs +//@[not-macro-in-deps] aux-build:file.rs + +#[cfg(any(with_diag_in_deps, only_diag_in_deps))] +extern crate file_diag as file; + +#[cfg(any(with_macro_in_deps, only_macro_in_deps))] +extern crate file_macro as file; + +#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))] +extern crate file_debuginfo as file; + +#[cfg(not_macro_in_deps)] +extern crate file; fn main() { - println!("{}", file!()); + println!("file::my_file!() = {}", file::my_file!()); + println!("file::file() = {}", file::file()); + println!("file!() = {}", file!()); } diff --git a/tests/ui/errors/remap-path-prefix-macro.with-debuginfo-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-debuginfo-in-deps.run.stdout new file mode 100644 index 0000000000000..b2c62ac88c04c --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.with-debuginfo-in-deps.run.stdout @@ -0,0 +1,3 @@ +file::my_file!() = $DIR/remap-path-prefix-macro.rs +file::file() = $DIR/auxiliary/file-debuginfo.rs +file!() = $DIR/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.with-diag-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-diag-in-deps.run.stdout new file mode 100644 index 0000000000000..e64cc0723619c --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.with-diag-in-deps.run.stdout @@ -0,0 +1,3 @@ +file::my_file!() = $DIR/remap-path-prefix-macro.rs +file::file() = $DIR/auxiliary/file-diag.rs +file!() = $DIR/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.with-macro-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-macro-in-deps.run.stdout new file mode 100644 index 0000000000000..5c1781dda1615 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.with-macro-in-deps.run.stdout @@ -0,0 +1,3 @@ +file::my_file!() = remapped/errors/remap-path-prefix-macro.rs +file::file() = remapped/errors/auxiliary/file-macro.rs +file!() = remapped/errors/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout deleted file mode 100644 index 3bbdcbb8655b2..0000000000000 --- a/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout +++ /dev/null @@ -1 +0,0 @@ -remapped/errors/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout b/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout deleted file mode 100644 index 642823fec86a1..0000000000000 --- a/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout +++ /dev/null @@ -1 +0,0 @@ -$DIR/remap-path-prefix-macro.rs