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

ICE when implementing Default for () #3036

Closed
CohenArthur opened this issue May 23, 2024 · 0 comments · Fixed by #3177
Closed

ICE when implementing Default for () #3036

CohenArthur opened this issue May 23, 2024 · 0 comments · Fixed by #3177

Comments

@CohenArthur
Copy link
Member

I tried this code:

#[lang = "sized"]
trait Sized {}

#[stable(feature = "rust1", since = "1.0.0")]
pub trait Default: Sized {
    #[stable(feature = "rust1", since = "1.0.0")]
    fn default() -> Self;
}

impl Default for () {
    fn default() -> () {
        ()
    }
}

I expected to see this happen: no errors.

Instead, this happened:

arthur@platypus ~/G/r/gccrs (master)> build/gcc/crab1 test.rs
crab1: internal compiler error: in visit, at rust/resolve/rust-ast-resolve-item.cc:688
0x25d6586 Rust::Resolver::ResolveItem::visit(Rust::AST::TraitImpl&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/resolve/rust-ast-resolve-item.cc:688
0x226c3b0 Rust::AST::TraitImpl::accept_vis(Rust::AST::ASTVisitor&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/ast/rust-ast.cc:4791
0x25d30e6 Rust::Resolver::ResolveItem::go(Rust::AST::Item&, Rust::Resolver::CanonicalPath const&, Rust::Resolver::CanonicalPath const&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/resolve/rust-ast-resolve-item.cc:174
0x25c4a6b Rust::Resolver::NameResolution::go(Rust::AST::Crate&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/resolve/rust-ast-resolve.cc:105
0x25c4661 Rust::Resolver::NameResolution::Resolve(Rust::AST::Crate&)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/resolve/rust-ast-resolve.cc:58
0x23a82c9 Rust::Session::compile_crate(char const*)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:632
0x23a7b01 Rust::Session::handle_input_files(int, char const**)
	/home/arthur/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:416
0x2201ac2 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.
@philberty philberty self-assigned this Sep 20, 2024
philberty added a commit that referenced this issue Sep 20, 2024
The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
	* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
philberty added a commit that referenced this issue Sep 20, 2024
The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
	* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
philberty added a commit that referenced this issue Sep 26, 2024
The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
	* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
philberty added a commit that referenced this issue Sep 27, 2024
The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
	* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
github-merge-queue bot pushed a commit that referenced this issue Sep 27, 2024
The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
	* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
tschwinge pushed a commit that referenced this issue Dec 4, 2024
The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
	* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
dkm pushed a commit that referenced this issue Feb 27, 2025
The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
	* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants