-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gccrs: add support for ref literal patterns
Fixes #3174 gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): make recursive * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): handle ref flag gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3174.rs: New test. Signed-off-by: Philip Herron <[email protected]>
- Loading branch information
Showing
4 changed files
with
52 additions
and
8 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
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 @@ | ||
extern "C" { | ||
fn printf(s: *const i8, ...); | ||
} | ||
|
||
enum Option { | ||
Some(i32), | ||
None, | ||
} | ||
|
||
impl Option { | ||
fn add(&mut self) { | ||
match *self { | ||
Option::Some(ref mut a) => *a += 1, | ||
Option::None => {} | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
unsafe { | ||
let mut a = Option::None; | ||
a.add(); | ||
let _s = "%d\n\0"; | ||
let _s = _s as *const str; | ||
let s = _s as *const i8; | ||
printf(s, a); | ||
} | ||
} |
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