forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustdoc: make doctest span tweak a 2024 edition change
Fixes rust-lang#132203 This is a compatibility hack, because I think the new behavior is better. When an A `include_str!` B, and B `include_str!` C, the path to C should be resolved relative to B, not A. That's how `include!` itself works, so that's how `include_str!` with should work.
- Loading branch information
Showing
12 changed files
with
98 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//@ edition:2024 | ||
//@ compile-flags:-Z unstable-options | ||
#![crate_name="extern_macros"] | ||
#[macro_export] | ||
macro_rules! attrs_on_struct { | ||
( $( #[$attr:meta] )* ) => { | ||
$( #[$attr] )* | ||
pub struct ExpandedStruct; | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```rust | ||
let x = include_bytes!("relative-dir-empty-file"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
running 3 tests | ||
test $DIR/doctest-output.rs - (line 12) ... ok | ||
test $DIR/doctest-output.rs - ExpandedStruct (line 28) ... ok | ||
test $DIR/doctest-output.rs - foo::bar (line 22) ... ok | ||
|
||
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
running 3 tests | ||
test $DIR/doctest-output.rs - (line 12) ... ok | ||
test $DIR/doctest-output.rs - ExpandedStruct (line 28) ... ok | ||
test $DIR/doctest-output.rs - foo::bar (line 22) ... ok | ||
|
||
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2015.stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
running 1 test | ||
test $DIR/relative-path-include-bytes-132203.rs - (line 17) ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/relative-path-include-bytes-132203.rs - (line 17) stdout ---- | ||
error: couldn't read `$DIR/relative-dir-empty-file`: No such file or directory (os error 2) | ||
--> $DIR/relative-path-include-bytes-132203.rs:18:9 | ||
| | ||
LL | let x = include_bytes!("relative-dir-empty-file"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
|
||
failures: | ||
$DIR/relative-path-include-bytes-132203.rs - (line 17) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
6 changes: 6 additions & 0 deletions
6
tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2024.stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
running 1 test | ||
test $DIR/auxiliary/relative-dir.md - (line 1) ... ok | ||
|
||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
17 changes: 17 additions & 0 deletions
17
tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@ revisions: edition2015 edition2024 | ||
//@[edition2015]edition:2015 | ||
//@[edition2015]check-fail | ||
//@[edition2015]failure-status: 101 | ||
//@[edition2015]compile-flags:--test --test-args=--test-threads=1 | ||
//@[edition2024]edition:2024 | ||
//@[edition2024]check-pass | ||
//@[edition2024]compile-flags:--test --test-args=--test-threads=1 -Z unstable-options | ||
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" | ||
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
|
||
// https://github.com/rust-lang/rust/issues/132203 | ||
// This version, because it's edition2024, passes thanks to the new | ||
// relative path. The edition2015 version fails, because paths are | ||
// resolved relative to the rs file instead of relative to the md file. | ||
|
||
#![doc=include_str!("auxiliary/relative-dir.md")] |