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: cannot relate bound region: ReLateBound(103, BrAnon(1)) <= ReStatic #17905

Closed
shanemhansen opened this issue Oct 10, 2014 · 2 comments · Fixed by #19780
Closed

ICE: cannot relate bound region: ReLateBound(103, BrAnon(1)) <= ReStatic #17905

shanemhansen opened this issue Oct 10, 2014 · 2 comments · Fixed by #19780
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@shanemhansen
Copy link

Internal compiler error when compiling the code below. When I change &str to String
and "shane" to "shane".to_string() it compiles.

#[deriving(Show)]
struct Pair<T,V>(T,V);
impl Pair<&str, int> {
    fn say(self: &Pair<&str, int>) {
        println!("{}", self);
    }
}
fn main() {
    let result = &Pair("shane", 1i);
    result.say();
}

Error message:

shane@tuva ~/hello_world $ RUST_BACKTRACE=1 rustc ./src/main.rs 
src/main.rs:3:11: 3:15 error: missing lifetime specifier [E0106]
src/main.rs:3 impl Pair<&str, int> {
                        ^~~~
src/main.rs:4:12: 4:37 error: internal compiler error: cannot relate bound region: ReLateBound(103, BrAnon(1)) <= ReStatic
src/main.rs:4     fn say(self: &Pair<&str, int>) {
                         ^~~~~~~~~~~~~~~~~~~~~~~~~
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:113

stack backtrace:
   1:     0x7f958b037f50 - rt::backtrace::imp::write::hb1f1803d8941cd7dEAq
   2:     0x7f958b03b0e0 - failure::on_fail::h9fbd63160481d8b76Vq
   3:     0x7f958f76a8c0 - unwind::begin_unwind_inner::h7014ce12ee89c8aeIxd
   4:     0x7f958e0e3d40 - unwind::begin_unwind::h3159935999110321135
   5:     0x7f958e0e3cc0 - diagnostic::SpanHandler::span_bug::ha33c2c4484455dbeGMF
   6:     0x7f958ff7be70 - driver::session::Session::span_bug::h3cd2ce290cf89fe6wtx
   7:     0x7f95903fa0b0 - middle::typeck::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h51eb89a0d2c3a361s47
   8:     0x7f95903b7e20 - middle::typeck::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_eqregion::hf308420b28e474f1R37
   9:     0x7f95903b7aa0 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::regions::hf373312c5711a8earX3
  10:     0x7f95903b1a00 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::tys::ha8209bdf143531b5E43
  11:     0x7f95903bb350 - middle::typeck::infer::combine::Combine::substs::h2013094428453956443
  12:     0x7f95903b1a00 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::tys::ha8209bdf143531b5E43
  13:     0x7f959013b300 - middle::typeck::infer::InferCtxt<'a, 'tcx>::eq_types::hf8e3ea7365746f51Bqd
  14:     0x7f95904156b0 - middle::typeck::infer::mk_eqty::closure.136122
  15:     0x7f9590414e40 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_if_ok::closure.136065
  16:     0x7f959072f0c0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_if_ok::closure.136086
  17:     0x7f95903acad0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::try::h56945167629248360
  18:     0x7f95904150f0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h14894066604232688873
  19:     0x7f95902fa800 - middle::typeck::infer::mk_eqty::hfb5b58a0e241c71aFVc
  20:     0x7f95902c13c0 - middle::typeck::require_same_types::h3a3aae4338560a2eT1j
  21:     0x7f95904bf760 - middle::typeck::collect::check_method_self_type::h17716824198498991828
  22:     0x7f959041f820 - middle::typeck::collect::convert::h19400805faaf8aa3zwf
  23:     0x7f95904193d0 - middle::typeck::collect::collect_item_types::hb509bd5bd824bdd1qxe
  24:     0x7f958fdc7fc0 - util::common::time::h4598558106411716556
  25:     0x7f95905dcad0 - middle::typeck::check_crate::h6a2949805af7a059Edk
  26:     0x7f95906470d0 - driver::driver::phase_3_run_analysis_passes::h9e1666443d557039EKw
  27:     0x7f95906428e0 - driver::driver::compile_input::h27eaa5feb1d31b23qrw
  28:     0x7f95906c4ca0 - driver::run_compiler::hc7f0df9c8d364f42HhA
  29:     0x7f95906c4b80 - driver::run::closure.146507
  30:     0x7f958fde0f10 - task::TaskBuilder<S>::try_future::closure.101318
  31:     0x7f958fde0d00 - task::TaskBuilder<S>::spawn_internal::closure.101289
  32:     0x7f958fab0e10 - task::spawn_opts::closure.8455
  33:     0x7f958f7bf980 - rust_try_inner
  34:     0x7f958f7bf970 - rust_try
  35:     0x7f958f768380 - unwind::try::h562b1387da651c61qmd
  36:     0x7f958f768210 - task::Task::run::h50cf282b32182c7f4Bc
  37:     0x7f958fab0b80 - task::spawn_opts::closure.8395
  38:     0x7f958f769960 - thread::thread_start::hbc67389ff8ce258afWc
  39:     0x7f958a3e50c0 - start_thread
  40:     0x7f958f431f89 - __clone
  41:                0x0 - <unknown>
@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 10, 2014
@kaseyc
Copy link
Contributor

kaseyc commented Oct 10, 2014

Could this be due to the lifetime elision changes, and the issues discussed in #17822?

@mahkoh
Copy link
Contributor

mahkoh commented Oct 10, 2014

Someone please update the title.

@alexcrichton alexcrichton changed the title ICE ICE: cannot relate bound region: ReLateBound(103, BrAnon(1)) <= ReStatic Oct 11, 2014
@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 19, 2014
bors added a commit that referenced this issue Dec 18, 2014
Closes #5988.
Closes #10176.
Closes #10456.
Closes #12744.
Closes #13264.
Closes #13324.
Closes #14182.
Closes #15381.
Closes #15444.
Closes #15480.
Closes #15756.
Closes #16822.
Closes #16966.
Closes #17351.
Closes #17503.
Closes #17545.
Closes #17771.
Closes #17816.
Closes #17897.
Closes #17905.
Closes #18188.
Closes #18232.
Closes #18345.
Closes #18389.
Closes #18400.
Closes #18502.
Closes #18611.
Closes #18783.
Closes #19009.
Closes #19081.
Closes #19098.
Closes #19127.
Closes #19135.
lnicola pushed a commit to lnicola/rust that referenced this issue Aug 29, 2024
…-keyword, r=Veykril

fix: Properly account for editions in names

This PR touches a lot of parts. But the main changes are changing `hir_expand::Name` to be raw edition-dependently and only when necessary (unrelated to how the user originally wrote the identifier), and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware (this was done in rust-lang#17896, but the FIXMEs were fixed here).

It is possible that I missed some cases, but most IDE parts should properly escape (or not escape) identifiers now.

The rules of thumb are:

 - If we show the identifier to the user, its rawness should be determined by the edition of the edited crate. This is nice for IDE features, but really important for changes we insert to the source code.
 - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update tests when an edition becomes stable, to avoid churn).
 - For debugging tools (helper methods and logs), I used `Edition::LATEST`.

Reviewing notes:

This is a really big PR but most of it is mechanical translation. I changed `Name` displayers to require an edition, and followed the compiler errors. Most methods just propagate the edition requirement. The interesting cases are mostly in `ide-assists`, as sometimes the correct crate to fetch the edition from requires awareness (there may be two). `ide-completions` and `ide-diagnostics` were solved pretty easily by introducing an edition field to their context. `ide` contains many features, for most of them it was propagated to the top level function and there the edition was fetched based on the file.

I also fixed all FIXMEs from rust-lang#17896. Some required introducing an edition parameter (usually not for many methods after the changes to `Name`), some were changed to a new method `is_any_identifier()` because they really want any possible keyword.

Fixes rust-lang#17895.
Fixes rust-lang#17774.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants