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 use_self on trait implementation in seperate file #4727

Closed
daxpedda opened this issue Oct 24, 2019 · 0 comments · Fixed by #4776
Closed

ICE with use_self on trait implementation in seperate file #4727

daxpedda opened this issue Oct 24, 2019 · 0 comments · Fixed by #4776
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@daxpedda
Copy link
Contributor

Most minimal case I could figure out:
lib.rs:

#![warn(clippy::use_self)]

mod module;

module.rs:

pub trait Trait {
	fn fun(par: &str) -> &str;
}

impl Trait for str {
	fn fun(par: &str) -> &str {
		&par[0..1]
	}
}

I played around a bit with this, following cases stop the ICE from triggering:

  • Implementing Trait for &str instead for str
  • Removing module.rs and having it defined in lib.rs
  • Doing something else in fun than indexing a str

The output:

cargo :     Checking ice-test v0.1.0 (C:\ice-test)
At line:1 char:1
+ cargo +nightly-2019-10-24 clippy *> output.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (    Checking ic...0 (C:\ice-test):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("src\\lib.rs"), BytePos(0)), end: (Real("src\\module.rs"), BytePos(41)) })', 
src\libcore\result.rs:1165:5

stack backtrace:
   0:     0x7ff9ca3a5629 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h99905b9bdd869405
   1:     0x7ff9ca3d35db - core::fmt::write::he42993c0fbc52473
   2:     0x7ff9ca3989f4 - <std::io::IoSlice as core::fmt::Debug>::fmt::h8559b5cde0785a61
   3:     0x7ff9ca3a9be9 - std::panicking::take_hook::hca300b53cb6483e1
   4:     0x7ff9ca3a983c - std::panicking::take_hook::hca300b53cb6483e1
   5:     0x7ff9b8233814 - rustc_driver::report_ice::h791a73b4b7354036
   6:     0x7ff9ca3aa46d - std::panicking::rust_panic_with_hook::ha7cfc6ccf6fcfc70
   7:     0x7ff9ca3a9fb4 - std::panicking::begin_panic_fmt::h31c79faaf0225e97
   8:     0x7ff9ca3a9e99 - rust_begin_unwind
   9:     0x7ff9ca3ccb59 - core::panicking::panic_fmt::h43ebb6ee7ce29706
  10:     0x7ff9ca3ccdaf - core::result::unwrap_failed::hd6c18a9f4959217d
  11:     0x7ff9b9fc056e - rustc_errors::emitter::is_case_difference::hd98bb8609477d08e
  12:     0x7ff9b9fb2e40 - rustc_errors::emitter::HumanReadableErrorType::new_emitter::hd82744bbf07a3d0a
  13:     0x7ff9b9fb4565 - <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic::hf74c6c73af652035
  14:     0x7ff9b9d7f273 - <syntax::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic::hcb1ee7b5d79d44ff
  15:     0x7ff9b9fad0f8 - rustc_errors::HandlerInner::emit_diagnostic::hec6a375b5a042de5
  16:     0x7ff9b9faf965 - rustc_errors::diagnostic_builder::DiagnosticBuilder::emit::h3ae8207a6b755a5e
  17:     0x7ff70778e05a - <unknown>
  18:     0x7ff7078ef5f0 - <unknown>
  19:     0x7ff7078efe16 - <unknown>
  20:     0x7ff70799583b - <unknown>
  21:     0x7ff7078efc75 - <unknown>
  22:     0x7ff9b952f2f0 - <rustc::lint::context::LateLintPassObjects as rustc::lint::LateLintPass>::check_item::hf428803c833320e1
  23:     0x7ff9b83a786c - rustc_interface::passes::BoxedGlobalCtxt::complete::h755aa5aedb4a18ce
  24:     0x7ff9b83bd71e - rustc_interface::passes::BoxedGlobalCtxt::complete::h755aa5aedb4a18ce
  25:     0x7ff9b83a7877 - rustc_interface::passes::BoxedGlobalCtxt::complete::h755aa5aedb4a18ce
  26:     0x7ff9b83b84ee - rustc_interface::passes::BoxedGlobalCtxt::complete::h755aa5aedb4a18ce
  27:     0x7ff9b83ac9f5 - rustc_interface::passes::BoxedGlobalCtxt::complete::h755aa5aedb4a18ce
  28:     0x7ff9b83abaaf - rustc_interface::passes::BoxedGlobalCtxt::complete::h755aa5aedb4a18ce
  29:     0x7ff9b82ade39 - <env_logger::filter::inner::Filter as core::fmt::Debug>::fmt::had697e9fb70f5628
  30:     0x7ff9b82afcf2 - <env_logger::filter::inner::Filter as core::fmt::Debug>::fmt::had697e9fb70f5628
  31:     0x7ff9ca3bbfc2 - _rust_maybe_catch_panic
  32:     0x7ff9b8386a45 - rustc_interface::passes::BoxedGlobalCtxt::complete::h755aa5aedb4a18ce
  33:     0x7ff9ca3bbfc2 - _rust_maybe_catch_panic
  34:     0x7ff9b82b43cb - rustc_interface::interface::parse_cfgspecs::h0a7c2c65a19710c1
  35:     0x7ff9b8358590 - rustc_interface::passes::BoxedResolver::to_expansion_result::h3512962e7f620bd7
  36:     0x7ff9b8279373 - <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt::h4ee18b40c3ec54a6
  37:     0x7ff9b827feed - <rustc::mir::Body as rustc_data_structures::graph::WithStartNode>::start_node::h0474409d4fc48e16
  38:     0x7ff9b820e749 - <syntax::ast::Attribute as core::ops::deref::Deref>::deref::h1ba0932f4b888baa
  39:     0x7ff9b8240f4d - <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt::h4ee18b40c3ec54a6
  40:     0x7ff9b8204eeb - <syntax::ast::Attribute as core::ops::deref::Deref>::deref::h1ba0932f4b888baa
  41:     0x7ff9b82e7f1b - <rustc_interface::util::ReplaceBodyWithLoop as syntax::mut_visit::MutVisitor>::visit_mac::h97efee51203582a1
  42:     0x7ff9b8204d8e - <syntax::ast::Attribute as core::ops::deref::Deref>::deref::h1ba0932f4b888baa
  43:     0x7ff9b824ea3c - <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt::h4ee18b40c3ec54a6
  44:     0x7ff9b8235921 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h32a65f08e8a1242f
  45:     0x7ff9b8254949 - <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt::h4ee18b40c3ec54a6
  46:     0x7ff9b826fd24 - <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt::h4ee18b40c3ec54a6
  47:     0x7ff9ca3bbfc2 - _rust_maybe_catch_panic
  48:     0x7ff9b827c012 - <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt::h4ee18b40c3ec54a6
  49:     0x7ff9ca387af7 - ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..mar
ker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  50:     0x7ff9ca3b9897 - std::sys::windows::thread::Thread::new::ha8c1c5acff515210
  51:     0x7ffa18e57974 - BaseThreadInitThunk
  52:     0x7ffa1a34a271 - RtlUserThreadStart

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0-nightly (4a8c5b20c 2019-10-23) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:

#0 [analysis] running analysis passes on this crate

end of query stack

error
: could not compile `ice-test`.

To learn more, run the command again with --verbose.
@flip1995 flip1995 added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 25, 2019
@ghost ghost mentioned this issue Nov 6, 2019
bors added a commit that referenced this issue Nov 8, 2019
Fix crash in `use-self` lint

Fixes #4727

changelog: Fix crash in `use-self` lint
bors added a commit that referenced this issue Nov 8, 2019
Fix crash in `use-self` lint

Fixes #4727

changelog: Fix crash in `use-self` lint
@bors bors closed this as completed in a952708 Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants