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 with destructor with type param with a lifetime #15858

Closed
tomaka opened this issue Jul 21, 2014 · 1 comment
Closed

ICE with destructor with type param with a lifetime #15858

tomaka opened this issue Jul 21, 2014 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tomaka
Copy link
Contributor

tomaka commented Jul 21, 2014

This code triggers an ICE:

#![feature(unsafe_destructor)]


trait Bar<'b> {
    fn do_something(&mut self);
}

struct BarImpl<'b>;

impl<'b> Bar<'b> for BarImpl<'b> {
    fn do_something(&mut self) {}
}


struct Foo<B>;

#[unsafe_destructor]
impl<'b, B: Bar<'b>> Drop for Foo<B> {
    fn drop(&mut self) {}
}


fn main() {
    // note: the call to unitialized() is not important, it's just here
    // because the destructor needs to be called for the ICE to trigger
    let x: Foo<BarImpl> = unsafe { std::mem::uninitialized() };
}

Message:

<anon>:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'b (root type=None)
<anon>:1 #![feature(unsafe_destructor)]
         ^
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>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:115

I'm using today's nightly: rustc 0.12.0-pre-nightly (5e0a597a1a15e36ac7d855ca400e5add9d86716b 2014-07-20 01:06:36 +0000)

#0  0x61f88160 in rust_fail ()
   from C:\Compilation\Rust\bin\rustrt-4e7c5e5c.dll
#1  0x61f889e1 in unwind::begin_unwind_inner::h4fffee852aa633cckJd ()
   from C:\Compilation\Rust\bin\rustrt-4e7c5e5c.dll
#2  0x009592ca in _fu2550___ZN4heap5EMPTY20h1bc6e42db9ab7eee8baE ()
   from C:\Compilation\Rust\bin\syntax-4e7c5e5c.dll
#3  0x00959255 in diagnostic::SpanHandler::span_bug::hfc98dc31cc92aee7f2C ()
   from C:\Compilation\Rust\bin\syntax-4e7c5e5c.dll
#4  0x710b0efa in driver::session::Session::span_bug::hd325d65657ade8dcPox ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#5  0x712b77fb in _fu110___ZN6to_str10T.ToString9to_string15__STATIC_FMTSTR20h61
3140a9ab0b6801GtdE () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#6  0x712b8578 in middle::ty_fold::VecPerParamSpace$LT$T$GT$.TypeFoldable::fold_
with::closure.$x22closure$x22$LP$115430$RP$ ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#7  0x712b7ae0 in _fu972___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#8  0x712b78f4 in middle::ty_fold::TypeFolder::fold_substs::h1606627659973584159
5 () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#9  0x71436650 in middle::subst::T.Subst::subst_spanned::h794027968757634140
    () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#10 0x7146b40a in _fu5851___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#11 0x7142780a in _fu5823___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#12 0x7146adcd in _fu1380___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#13 0x7146958c in _fu1378___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#14 0x71378feb in _fu1133___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#15 0x712e75b1 in middle::trans::base::get_res_dtor::h3c36fb0ca7cdef9foXa ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#16 0x712e6e89 in middle::trans::glue::trans_struct_drop::hc402b180302545504cY
    () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#17 0x712e6db9 in middle::trans::glue::trans_struct_drop_flag::closure.$x22closu
re$x22$LP$115788$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#18 0x712e6b92 in middle::trans::base::with_cond::h275549e08aca791bLQb ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#19 0x712e14f9 in middle::trans::glue::make_drop_glue::as_closure.$x22as_closure
$x22$LP$115752$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#20 0x712e0763 in _fu1001___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#21 0x712dcbf8 in _fu9167___ZN11collections7hashmap5table25RawTable$LT$K$C$$x20V
$GT$8read_mut15__STATIC_FMTSTR20h52ee9d52ccb78170sKdE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#22 0x712dc135 in middle::trans::glue::drop_ty::h22c19447361d791f2ZX ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#23 0x712ea368 in middle::trans::glue::drop_ty::as_closure.$x22as_closure$x22$LP
$115802$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#24 0x71379c49 in middle::trans::base::iter_structural_ty::closure.$x22closure$x
22$LP$118686$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#25 0x713795df in middle::trans::expr::with_field_tys::h7611866981621909557 ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#26 0x712db7f0 in _fu113___ZN6to_str10T.ToString9to_string15__STATIC_FMTSTR20h61
3140a9ab0b6801GtdE () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#27 0x712e15d4 in middle::trans::glue::make_drop_glue::as_closure.$x22as_closure
$x22$LP$115752$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#28 0x712e0763 in _fu1001___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#29 0x712dcbf8 in _fu9167___ZN11collections7hashmap5table25RawTable$LT$K$C$$x20V
$GT$8read_mut15__STATIC_FMTSTR20h52ee9d52ccb78170sKdE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#30 0x712dc135 in middle::trans::glue::drop_ty::h22c19447361d791f2ZX ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#31 0x71409cd3 in middle::trans::cleanup::DropValue.Cleanup::trans::hda7eb6534d1
8d883gIv () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#32 0x712e9728 in _fu5647___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#33 0x713232c3 in _fu1071___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#34 0x7131084f in _fu1057___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#35 0x712d18b9 in _fu5623___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#36 0x712d1d28 in middle::trans::controlflow::trans_block::h34c351d171e17f4batX
() from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#37 0x713838df in _fu4142___ZN6option15Option$LT$T$GT$6unwrap15__STATIC_FMTSTR20
hffe20199f09050f08XlE () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#38 0x712c5620 in _fu5608___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#39 0x712c7517 in _fu5613___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#40 0x712f67aa in _fu12025___ZN3ast11LOCAL_CRATE20hc864dbb6979b191fsscE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#41 0x712f2386 in _fu5653___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#42 0x713016ec in _fu1039___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#43 0x7130042d in middle::trans::callee::trans_method_call::closure.$x22closure$
x22$LP$116143$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#44 0x712fbbfa in middle::trans::callee::trans_call_inner::hdd17f9ccbde0143d5j0
() from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#45 0x7130010e in _fu5669___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#46 0x7131038f in _fu1057___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#47 0x712d18b9 in _fu5623___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#48 0x712d1d28 in middle::trans::controlflow::trans_block::h34c351d171e17f4batX
() from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#49 0x713838df in _fu4142___ZN6option15Option$LT$T$GT$6unwrap15__STATIC_FMTSTR20
hffe20199f09050f08XlE () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#50 0x712c5620 in _fu5608___ZN9LOG_LEVEL20h2c6669d829f5eb70diaE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#51 0x71389b17 in _fu1163___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#52 0x712c0a58 in _fu8738___ZN11collections7hashmap5table25RawTable$LT$K$C$$x20V
$GT$4read15__STATIC_FMTSTR20h52ee9d52ccb78170qIdE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#53 0x71391bef in _fu1170___ZN3vec10PTR_MARKER20h9fed6267b1c4667cGIhE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#54 0x7171907a in driver::driver::phase_4_translate_to_llvm::h9a8bf621a6eccc8bCq
w () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#55 0x71711f52 in _fu3969___ZN4cell29Ref$LT$$x27b$C$$x20T$GT$.Drop4drop15__STATI
C_FMTSTR20hffe20199f09050f0xXiE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#56 0x717ad99e in _fu10354___ZN4cell32RefMut$LT$$x27b$C$$x20T$GT$.Drop4drop15__S
TATIC_FMTSTR20hffe20199f09050f0O1iE ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#57 0x717aaf1d in driver::main_args::closure.$x22closure$x22$LP$137115$RP$ ()
   from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#58 0x717bd18e in task::TaskBuilder$LT$S$GT$::try_future::closure.$x22closure$x2
2$LP$138258$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#59 0x717bd0a2 in task::TaskBuilder$LT$S$GT$::spawn_internal::closure.$x22closur
e$x22$LP$138235$RP$ () from C:\Compilation\Rust\bin\rustc-4e7c5e5c.dll
#60 0x70c30298 in task::spawn_opts::closure.$x22closure$x22$LP$8580$RP$ ()
   from C:\Compilation\Rust\bin\native-4e7c5e5c.dll
#61 0x61f88155 in unwind::try::try_fn::hc576b70e5db0056b6zd ()
   from C:\Compilation\Rust\bin\rustrt-4e7c5e5c.dll
#62 0x61fe73d6 in rust_try () from C:\Compilation\Rust\bin\rustrt-4e7c5e5c.dll
#63 0x61f85ea7 in unwind::try::h1113533bcbfe97bdJxd ()
   from C:\Compilation\Rust\bin\rustrt-4e7c5e5c.dll
#64 0x61f85c3a in task::Task::run::h22cb15a330ff15f29Xc ()
   from C:\Compilation\Rust\bin\rustrt-4e7c5e5c.dll
#65 0x70c30137 in task::spawn_opts::closure.$x22closure$x22$LP$8526$RP$ ()
   from C:\Compilation\Rust\bin\native-4e7c5e5c.dll
#66 0x61f87caf in thread::thread_start::h8291a389c91d62bbHkd ()
   from C:\Compilation\Rust\bin\rustrt-4e7c5e5c.dll
#67 0x767e338a in KERNEL32!BaseThreadInitThunk ()
   from C:\Windows\syswow64\kernel32.dll
#68 0x771c9f72 in ntdll!RtlInitializeExceptionChain ()
   from C:\Windows\system32\ntdll.dll
#69 0x771c9f45 in ntdll!RtlInitializeExceptionChain ()
   from C:\Windows\system32\ntdll.dll
#70 0x00000000 in ?? ()
@tomaka tomaka changed the title ICE with destructor for a type using a type with a lifetime ICE with destructor with type param with a lifetime Jul 21, 2014
tomaka referenced this issue in tomaka/hlua Jul 21, 2014
@alexcrichton
Copy link
Member

Closed by #16131

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
…as, r=Veykril

feat!: create alias when renaming an import.

![gif](https://github.com/rust-lang/rust-analyzer/assets/57047985/c593d9a8-b8a0-4e13-9e50-a69c7d0d8749)

Closes rust-lang#15858

Implemented:
- [x] - Prevent using `reserved` keywords (e.g self) and `_`.
- [x] - Rename other modules that might be referencing the import.
- [x] - Fix "broken" tests.
- [ ] - Rename **only** "direct" references.
- [ ] - Test more cases.

Future possibilities:
1. Also support `extern crate <name>` syntax.
2. Allow aliasing `self` when it is inside an `UseTreeList`.
~3. If import path already has an alias, "rename" the alias.~
~[4. Create alias even if path is not the last path segment.](rust-lang/rust-analyzer#16489 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants