-
Notifications
You must be signed in to change notification settings - Fork 969
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [naga wgsl-in] add tests for
@must_use
- Loading branch information
1 parent
150a204
commit b3f5e81
Showing
1 changed file
with
53 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,53 @@ | ||
fn main() { } | ||
|
||
@must_use | ||
fn a() -> i32 { return 10; } | ||
|
||
@must_use | ||
fn b() -> bool { return false; } | ||
|
||
// use as return | ||
fn z() -> i32 { | ||
return a(); | ||
} | ||
|
||
// use in expression | ||
fn y() -> bool { | ||
return a() == 10; | ||
} | ||
|
||
// use in short circuited expression | ||
fn x() -> bool { | ||
return false && a() == 10; | ||
} | ||
|
||
// assignment and use as return | ||
fn w() -> i32 { | ||
let called_a = a(); | ||
return called_a; | ||
} | ||
|
||
// assignment and use before return | ||
fn v() -> i32 { | ||
let called_a = a(); | ||
let used_a = 1 + called_a; | ||
return used_a; | ||
} | ||
|
||
// use in condition | ||
fn u() -> i32 { | ||
if(b()) { | ||
return 1; | ||
} else { | ||
return 2; | ||
} | ||
} | ||
|
||
// use in skipped branch | ||
fn t() -> i32 { | ||
if(true) { | ||
return 1; | ||
} else { | ||
return a(); | ||
} | ||
} |