Skip to content

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 <[email protected]>
rich_locus.add_fixit_replace ("not a tuple struct or tuple variant");
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