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

Fix lookup of TuplePattern sub-pattern types #2848

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

powerboat9
Copy link
Collaborator

@powerboat9 powerboat9 commented Feb 12, 2024

Fixes the issue pointed out in this comment.

gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc
	(CompilePatternLet::visit):
	Lookup type of sub-pattern, not tuple pattern itself.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2847-b.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

LGTM, thanks :) can you change your PR's main comment so that #2847 isn't closed by this PR? the original code still causes an ICE

@powerboat9
Copy link
Collaborator Author

It looks like I managed to fix it

@CohenArthur
Copy link
Member

I checked out your commit and still get an ICE for the original testcase:

arthur@platypus ~/G/r/gccrs ((b8d8b5f9)) [1]> git log -1
commit b8d8b5f95625bbaa437fd167a57f4b0fe81b43e7 (HEAD, powerboat9/fix-let-u)
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Mon Feb 12 18:20:19 2024 -0500

    Fix lookup of TuplePattern sub-pattern types

    gcc/rust/ChangeLog:

            * backend/rust-compile-pattern.cc
            (CompilePatternLet::visit):
            Lookup type of sub-pattern, not tuple pattern itself.

    gcc/testsuite/ChangeLog:

            * rust/compile/issue-2847-b.rs: New test.

    Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
arthur@platypus ~/G/r/gccrs ((b8d8b5f9))> cat test.rs
fn myfun((x, _): (i32, i32)) -> i32 {
    x
}
arthur@platypus ~/G/r/gccrs ((b8d8b5f9))> build/gcc/crab1 test.rs
crab1: internal compiler error: in function_set_parameters, at rust/rust-gcc.cc:2284
0x1f448bf Backend::function_set_parameters(tree_node*, std::vector<Bvariable*, std::allocator<Bvariable*> > const&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-gcc.cc:2284
0x24345a7 Rust::Compile::HIRCompileBase::compile_function(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Rust::HIR::SelfParam&, std::vector<Rust::HIR::FunctionParam, std::allocator<Rust::HIR::FunctionParam> >&, Rust::HIR::FunctionQualifiers const&, Rust::HIR::Visibility&, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >&, unsigned int, Rust::HIR::BlockExpr*, Rust::Resolver::CanonicalPath const*, Rust::TyTy::FnType*)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/backend/rust-compile-base.cc:721
0x23f48bf Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/backend/rust-compile-item.cc:179
0x21e2f5d Rust::HIR::Function::accept_vis(Rust::HIR::HIRStmtVisitor&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/hir/tree/rust-hir.cc:4974
0x20ec894 Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, bool, unsigned int)
	../../gcc/rust/backend/rust-compile-item.h:38
0x20ea940 Rust::Compile::CompileCrate::go()
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/backend/rust-compile.cc:48
0x20ea87a Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/backend/rust-compile.cc:41
0x20d3811 Rust::Session::compile_crate(char const*)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:694
0x20d2da1 Rust::Session::handle_input_files(int, char const**)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:408
0x1f25322 grs_langhook_parse_file()
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-lang.cc:165
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

@powerboat9
Copy link
Collaborator Author

I fixed the issue pointed out in the linked comment, which seems to be mostly unrelated to #2847 itself

fn myfun() -> i32 {
    let (x, _) =  (1, 2);
    x
}

@CohenArthur CohenArthur added this pull request to the merge queue Feb 13, 2024
@CohenArthur
Copy link
Member

thanks :)

Merged via the queue into Rust-GCC:master with commit a471675 Feb 13, 2024
9 checks passed
@powerboat9 powerboat9 deleted the fix-let-u branch February 13, 2024 15:57
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.

2 participants