Rust-GCC / Rust-GCC/gccrs

ICE: `unable to find relevant lang item: Range`

Open
#4,469 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

Code
struct Foo;
trait ConvertToFoo {
    fn to_foo(self) -> Foo;
}
impl ConvertToFoo for usize
where
    usize: ConvertToFoo,
{
    fn to_foo(self) -> Foo {
        Foo
    }
}
#[allow(unused_must_use)]
fn main() {
    (0..10).map(|x| x.to_foo());
}

Meta

1a91028

Error output
<output>
Backtrace

crab1: internal compiler error: at temp_w3_iter_79_original_var_1.rs:21:6, unable to find relevant lang item: Range
0x2c1ef7b internal_error(char const*, ...)
  ../../gcc/diagnostic-global-context.cc:787
0xbafba0 rust_be_internal_error_at(unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
  ../../gcc/rust/rust-diagnostics.cc:173
0xbb0a59 rust_internal_error_at(unsigned long, char const*, ...)
  ../../gcc/rust/rust-diagnostics.cc:182
0xeb201e Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::RangeFromToExpr&)
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:707
0xeabe1c Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:51
0xeadc10 ???
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.h:62
0xeabe1c Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:51
0xeae6a6 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::MethodCallExpr&)
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1388
0xeabe1c Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:51
0xeb8910 ???
  ../../gcc/rust/typecheck/rust-hir-type-check-stmt.h:33
0xeb910b Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt&)
  ../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
0xead5a1 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:638
0xeabe1c Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
  ../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:51
0xe9827b Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Function&)
  ../../gcc/rust/typecheck/rust-hir-type-check-item.cc:598
0xe9190d Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
  ../../gcc/rust/typecheck/rust-hir-type-check-item.cc:57
0xe9190d Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
  ../../gcc/rust/typecheck/rust-hir-type-check-item.cc:43
0xe4c12b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
  ../../gcc/rust/typecheck/rust-hir-type-check.cc:71
0xd11bcf Rust::Session::compile_crate(char const*)
  ../../gcc/rust/rust-session-manager.cc:763
/home/gccrs/build/gcc/crab1 /tmp/trait_fuzzer_rustc_mccq13oz/temp_w3_iter_79_original_var_1.rs -frust-incomplete-and-experimental-compiler-do-not-use
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.


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ICE with the Rust snippet using gccrs at revision 1a91028. Start in gcc/rust/typecheck/rust-hir-type-check-expr.cc at TypeCheckExpr::visit(RangeFromToExpr), especially around line 707, and trace how the Range lang item is resolved. Done means this example no longer emits the internal compiler error and has regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.