Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E0164] Neither tuple struct nor tuple variant used as a pattern #2565

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

MahadMuhammad
Copy link
Contributor

Neither a tuple struct nor a tuple variant was used as a pattern - E0164

Checking if pattern has items, before returing solves ICE. Added error code and rich location.


gcc/rust/ChangeLog:

* ast/rust-pattern.h: No need of assertion, we are handling it.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Added check which emits error instead of using assertion.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Added rich location and error code.

gcc/testsuite/ChangeLog:

* rust/compile/match5.rs: Updated comment for dejagnu.
* rust/compile/pattern-struct.rs: New test for ICE.

Checking if pattern has items, before returing solves ICE.
Added error code and rich location.
Also, fixes Rust-GCC#2430

gcc/rust/ChangeLog:

	* ast/rust-pattern.h: No need of assertion, we are handling it.
	* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
	Added check which emits error instead of using assertion.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/match5.rs:
	Updated comment for dejagnu.
	* rust/compile/pattern-struct.rs: New test for ICE.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
rust_error_at (
pattern.get_locus (),
rich_locus, ErrorCode::E0164,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, rustc 1.49.0 emits E0532 & rustc 1.71.0 emits E0164

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Go with the latest one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the latest one :)

rust_assert (has_items ());
return items;
}
std::unique_ptr<TupleStructItems> &get_items () { return items; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find @dkm has been fixing these too. Keep your eye out for them :D

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@philberty philberty added this pull request to the merge queue Aug 17, 2023
Merged via the queue into Rust-GCC:master with commit 294c590 Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Neither tuple struct nor a tuple variant was used as a pattern - Internal Compiler Error
3 participants