-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for uniqueness of route macros
- Loading branch information
1 parent
8a1bb81
commit e50346e
Showing
3 changed files
with
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[test] | ||
fn ui() { | ||
let t = trybuild::TestCases::new(); | ||
t.pass(format!("tests/ui-pass/*.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,27 @@ | ||
#[macro_use] extern crate rocket; | ||
|
||
// Makes sure that the hashing of the proc macro's call site span | ||
// is enough, even if we're inside a declarative macro | ||
macro_rules! gen_routes { | ||
() => { | ||
#[get("/")] | ||
fn index() -> &'static str { | ||
"GET" | ||
} | ||
|
||
mod two { | ||
#[get("/")] | ||
fn index() -> &'static str { | ||
"GET" | ||
} | ||
} | ||
} | ||
} | ||
|
||
gen_routes!(); | ||
|
||
mod module { | ||
gen_routes!(); | ||
} | ||
|
||
fn main() {} |
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,18 @@ | ||
#[macro_use] extern crate rocket; | ||
|
||
#[get("/")] | ||
fn index() -> &'static str { | ||
"GET" | ||
} | ||
|
||
mod module { | ||
// This one has all the same macro inputs, and we need it to | ||
// generate a crate-wide unique identifier for the macro it | ||
// defines. | ||
#[get("/")] | ||
pub fn index() -> &'static str { | ||
"whatever" | ||
} | ||
} | ||
|
||
fn main() {} |