forked from bazelbuild/rules_rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustdoc_test: substitute the root of the current crate (bazelbuild#1777)
Otherwise a trivial little crate with no rust_library dependencies, and a build script dependency, fails. This is unusual because most crates complex enough to have a build script also have other dependencies, I ran into while minimizing a test case for another bug.
- Loading branch information
1 parent
a52041f
commit 4e89d52
Showing
5 changed files
with
83 additions
and
0 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,3 @@ | ||
fn main() { | ||
println!("cargo:rustc-env=CONST=xyz"); | ||
} |
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,28 @@ | ||
#[cfg(feature = "with_proc_macro")] | ||
use rustdoc_proc_macro::make_answer; | ||
|
||
#[cfg(feature = "with_proc_macro")] | ||
make_answer!(); | ||
|
||
#[cfg(feature = "with_build_script")] | ||
pub const CONST: &str = env!("CONST"); | ||
|
||
/// The answer to the ultimate question | ||
/// ``` | ||
/// fn answer() -> u32 { 42 } | ||
/// assert_eq!(answer(), 42); | ||
/// ``` | ||
#[cfg(not(feature = "with_proc_macro"))] | ||
pub fn answer() -> u32 { | ||
42 | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_answer() { | ||
assert_eq!(answer(), 42); | ||
} | ||
} |
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