Make sure the documentation scope doesn't imply other scopes

This commit is contained in:
Urgau
2026-01-24 12:43:23 +01:00
parent fbab2c0e92
commit 3d6a5b5158
8 changed files with 86 additions and 7 deletions
+13
View File
@@ -0,0 +1,13 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: --remap-path-scope=documentation -Zunstable-options
#[macro_export]
macro_rules! my_file {
() => {
file!()
};
}
pub fn file() -> &'static str {
file!()
}
+4
View File
@@ -0,0 +1,4 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: --remap-path-scope=documentation -Zunstable-options
pub trait Trait: std::fmt::Display {}
@@ -0,0 +1,20 @@
error[E0277]: `A` doesn't implement `std::fmt::Display`
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | impl r#trait::Trait for A {}
| ^ unsatisfied trait bound
|
help: the trait `std::fmt::Display` is not implemented for `A`
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | struct A;
| ^^^^^^^^
note: required by a bound in `Trait`
--> $DIR/auxiliary/trait-doc.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`.
@@ -3,26 +3,30 @@
// 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: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps with-doc-in-deps
//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps only-doc-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
//@[with-doc-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: --remap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: --remap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo
//@[with-doc-in-deps] compile-flags: --remap-path-scope=documentation -Zunstable-options
//@[not-diag-in-deps] compile-flags: --remap-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
//@[with-doc-in-deps] aux-build:trait-doc.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
//@[only-doc-in-deps] aux-build:trait-doc.rs
//@[not-diag-in-deps] aux-build:trait.rs
// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically
@@ -39,6 +43,9 @@
#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))]
extern crate trait_debuginfo as r#trait;
#[cfg(any(with_doc_in_deps, only_doc_in_deps))]
extern crate trait_doc as r#trait;
#[cfg(not_diag_in_deps)]
extern crate r#trait as r#trait;
@@ -47,9 +54,11 @@
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-doc-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`
//[only-doc-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`
@@ -0,0 +1,20 @@
error[E0277]: `A` doesn't implement `std::fmt::Display`
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | impl r#trait::Trait for A {}
| ^ unsatisfied trait bound
|
help: the trait `std::fmt::Display` is not implemented for `A`
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | struct A;
| ^^^^^^^^
note: required by a bound in `Trait`
--> $DIR/auxiliary/trait-doc.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`.
@@ -0,0 +1,3 @@
file::my_file!() = $DIR/remap-path-prefix-macro.rs
file::file() = $DIR/auxiliary/file-doc.rs
file!() = $DIR/remap-path-prefix-macro.rs
+9 -2
View File
@@ -6,26 +6,30 @@
//@ run-pass
//@ check-run-results
//@ 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: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps with-doc-in-deps
//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps only-doc-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
//@[with-doc-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: --remap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: --remap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo
//@[with-doc-in-deps] compile-flags: --remap-path-scope=documentation -Zunstable-options
//@[not-macro-in-deps] compile-flags: --remap-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
//@[with-doc-in-deps] aux-build:file-doc.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
//@[only-doc-in-deps] aux-build:file-doc.rs
//@[not-macro-in-deps] aux-build:file.rs
#[cfg(any(with_diag_in_deps, only_diag_in_deps))]
@@ -37,6 +41,9 @@
#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))]
extern crate file_debuginfo as file;
#[cfg(any(with_doc_in_deps, only_doc_in_deps))]
extern crate file_doc as file;
#[cfg(not_macro_in_deps)]
extern crate file;
@@ -0,0 +1,3 @@
file::my_file!() = $DIR/remap-path-prefix-macro.rs
file::file() = $DIR/auxiliary/file-doc.rs
file!() = $DIR/remap-path-prefix-macro.rs