Rust-GCC / Rust-GCC/gccrs

ICE `in check_type_privacy, at rust/checks/errors/privacy/rust-privacy-reporter.cc`

Open
#3,948 0 comments 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

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
struct Foo {
    field: i32,
}

impl Foo {
    fn foo<'a>(&'x self, x: &'a Foo) -> &'a Foo {}
}

original:

struct Foo {
    field: i32,
}

impl Foo {
    fn foo<'a>(&'x self, x: &'a Foo) -> &'a Foo {

        if true { x } else { self } //~ ERROR lifetime mismatch

    }
}

fn main() {}

Version information:

5c3e2adc695b04a199d37cacd8c23b14fdab914f

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5c3e2adc695b04a199d37cacd8c23b14fdab914f/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc#L283-L295

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

/tmp/icemaker_global_tempdir.xovF16RFaxLD/rustc_testrunner_tmpdir_reporting.jUEMnhXgv2O3/mvce.rs:6:16: note: failed to resolve lifetime
    6 |     fn foo<'a>(&'x self, x: &'a Foo) -> &'a Foo {}
      |                ^
crab1: internal compiler error: in check_type_privacy, at rust/checks/errors/privacy/rust-privacy-reporter.cc:289
0x2fec938 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
	../../gcc/diagnostic.cc:1803
0x902d13 Rust::Privacy::PrivacyReporter::check_type_privacy(Rust::HIR::Type const&)
	../../gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc:289
0x1015c98 ???
	../../gcc/rust/checks/errors/privacy/rust-privacy-reporter.h:143
0x101455f ???
	../../gcc/rust/checks/errors/privacy/rust-privacy-reporter.h:151
0x1014f10 Rust::Privacy::PrivacyReporter::go(Rust::HIR::Crate&)
	../../gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc:89
0x1011815 Rust::Privacy::Resolver::resolve(Rust::HIR::Crate&)
	../../gcc/rust/checks/errors/privacy/rust-privacy-check.cc:43
0xdb97d7 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:701
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

Start with the reduced Rust testcase and reproduce it using the command shown in the issue. Inspect check_type_privacy in gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc around lines 283-295, following the backtrace into the privacy checker. Done means the testcase no longer triggers an internal compiler error and reports the lifetime problem normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.