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

Self generic injection causes metadata dump issue #2349

Open
P-E-P opened this issue Jun 29, 2023 · 2 comments
Open

Self generic injection causes metadata dump issue #2349

P-E-P opened this issue Jun 29, 2023 · 2 comments
Assignees
Labels

Comments

@P-E-P
Copy link
Member

P-E-P commented Jun 29, 2023

Dump process shall dump all generics in order to be accurate, but an implicit Self generic is injected during name-resolution step. This means, the dump used for metadata export does contain this implicit Self and cannot compile anymore.

Code

See disabled test trait_import0.rs

Meta

Error output

Failure to parse metadata.

Details

crab1: internal compiler error: in linemap_ordinary_map_lookup, at libcpp/line-map.cc:1101
0x395fae3 linemap_ordinary_map_lookup(line_maps const*, unsigned int)
	/home/patryp/Documents/gccrs/build/libcpp/../../libcpp/line-map.cc:1101
0x395f4fc linemap_lookup(line_maps const*, unsigned int)
	/home/patryp/Documents/gccrs/build/libcpp/../../libcpp/line-map.cc:1057
0x3961831 linemap_location_in_system_header_p(line_maps*, unsigned int)
	/home/patryp/Documents/gccrs/build/libcpp/../../libcpp/line-map.cc:1323
0x1609e8a in_system_header_at(unsigned int)
	../../gcc/input.h:202
0x1e094df set_inlining_locations(diagnostic_context*, diagnostic_info*)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/tree-diagnostic.cc:358
0x38e2372 get_any_inlining_info(diagnostic_context*, diagnostic_info*)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/diagnostic.cc:1222
0x38dd34c diagnostic_enabled(diagnostic_context*, diagnostic_info*)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/diagnostic.cc:1431
0x38dd606 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/diagnostic.cc:1545
0x38de7f1 diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/diagnostic.cc:1756
0x38dfbfc error_at(unsigned int, char const*, ...)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/diagnostic.cc:2079
0x1078e50 rust_be_error_at(Location, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/rust/rust-diagnostics.cc:183
0x1078f15 rust_error_at(Location, char const*, ...)
	/home/patryp/Documents/gccrs/build/gcc/../../gcc/rust/rust-diagnostics.cc:192
0x111d3ab std::unique_ptr<Rust::AST::GenericParam, std::default_delete<Rust::AST::GenericParam> > Rust::Parser<Rust::Lexer>::parse_generic_param<bool (*)(Rust::TokenId)>(bool (*)(Rust::TokenId))
	../../gcc/rust/parse/rust-parse-impl.h:3135
0x111c5c1 std::vector<std::unique_ptr<Rust::AST::GenericParam, std::default_delete<Rust::AST::GenericParam> >, std::allocator<std::unique_ptr<Rust::AST::GenericParam, std::default_delete<Rust::AST::GenericParam> > > > Rust::Parser<Rust::Lexer>::parse_generic_params<bool (*)(Rust::TokenId)>(bool (*)(Rust::TokenId))
	../../gcc/rust/parse/rust-parse-impl.h:3168
0x111b105 Rust::Parser<Rust::Lexer>::parse_generic_params_in_angles()
	../../gcc/rust/parse/rust-parse-impl.h:3004
0x1116f5a Rust::Parser<Rust::Lexer>::parse_trait(Rust::AST::Visibility, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gcc/rust/parse/rust-parse-impl.h:4913
0x111057c Rust::Parser<Rust::Lexer>::parse_vis_item(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gcc/rust/parse/rust-parse-impl.h:1374
0x110ef75 Rust::Parser<Rust::Lexer>::parse_item(bool)
	../../gcc/rust/parse/rust-parse-impl.h:1117
0x10caa79 Rust::Parser<Rust::Lexer>::parse_items()
	../../gcc/rust/parse/rust-parse-impl.h:415
0x11d5f67 Rust::Parser<Rust::Lexer>::parse_crate()
	../../gcc/rust/parse/rust-parse-impl.h:444

@P-E-P P-E-P added the bug label Jun 29, 2023
@P-E-P P-E-P changed the title Self generic injection causes dump issue Self generic injection causes metadata dump issue Jun 29, 2023
@CohenArthur CohenArthur added this to the Procedural Macros 1 milestone Jun 30, 2023
@philberty philberty self-assigned this Jun 30, 2023
@philberty
Copy link
Member

Thanks for this, I want to re look at our metadata output pass for this case.

@philberty
Copy link
Member

  // we need to inject an implicit self TypeParam here
  // FIXME: which location should be used for Rust::Identifier `Self`?
  AST::TypeParam *implicit_self
    = new AST::TypeParam ({"Self"}, trait.get_locus ());
  trait.insert_implict_self (
    std::unique_ptr<AST::GenericParam> (implicit_self));
  CanonicalPath Self = CanonicalPath::get_big_self (trait.get_node_id ());

See rust-ast-resolve-item.cc:819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants