-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gccrs: fix ICE in borrows to invalid expressions
We need to check if the borrowed value is valid before creating the reference type. Otherwise this will lead to an ICE. Fixes #3140 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check for error * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): likewise and remove debug error gcc/testsuite/ChangeLog: * rust/compile/issue-3046.rs: remove old error message * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3140.rs: New test. Signed-off-by: Philip Herron <[email protected]>
- Loading branch information
Showing
5 changed files
with
33 additions
and
10 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
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 @@ | ||
enum State { | ||
Succeeded, | ||
Failed, | ||
} | ||
|
||
fn print_on_failure(state: &State) { | ||
let mut num = 0; | ||
match *state { | ||
// error: expected unit struct, unit variant or constant, found tuple | ||
// variant `State::Failed` | ||
State::Failed => { | ||
num = 1; | ||
} | ||
State::Succeeded => { | ||
num = 2; | ||
} | ||
_ => (), | ||
} | ||
} | ||
|
||
fn main() { | ||
let b = State::Failed(1); | ||
// { dg-error "expected function, tuple struct or tuple variant, found struct .State." "" { target *-*-* } .-1 } | ||
|
||
print_on_failure(&b); | ||
// { dg-error "cannot find value .b. in this scope" "" { target *-*-* } .-1 } | ||
} |
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