<p dir="auto">With this code: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/retep998/term/commit/2b94c822fc0590a5f9bdc99fad541d0c3518f2a3/hovercard" href="https://github.com/retep998/term/commit/2b94c822fc0590a5f9bdc99fad541d0c3518f2a3">retep998/term@<tt>2b94c82</tt></a><br>
I get an ICE</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Peter@Win81-SSD MINGW64 ~/term
$ cargo run --example something
   Compiling kernel32-sys v0.1.0
   Compiling libc v0.1.6
   Compiling winapi v0.1.17
   Compiling term v0.2.7 (file:///C:/msys64/home/Peter/term)
examples\something.rs:19:14: 2:54 error: source trait is private
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/masterCONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', C:/msys64/home/Peter/rust/src/libcore\option.rs:330


Could not compile `term`.

To learn more, run the command again with --verbose.

Peter@Win81-SSD MINGW64 ~/term
$ rustc -vV
rustc 1.1.0-dev (9c88f3be1 2015-04-27) (built 2015-04-27)
binary: rustc
commit-hash: 9c88f3be126d0fe02a92c20e1d78192f4b648401
commit-date: 2015-04-27
build-date: 2015-04-27
host: x86_64-pc-windows-gnu
release: 1.1.0-dev"><pre class="notranslate"><code class="notranslate">Peter@Win81-SSD MINGW64 ~/term
$ cargo run --example something
   Compiling kernel32-sys v0.1.0
   Compiling libc v0.1.6
   Compiling winapi v0.1.17
   Compiling term v0.2.7 (file:///C:/msys64/home/Peter/term)
examples\something.rs:19:14: 2:54 error: source trait is private
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/masterCONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', C:/msys64/home/Peter/rust/src/libcore\option.rs:330


Could not compile `term`.

To learn more, run the command again with --verbose.

Peter@Win81-SSD MINGW64 ~/term
$ rustc -vV
rustc 1.1.0-dev (9c88f3be1 2015-04-27) (built 2015-04-27)
binary: rustc
commit-hash: 9c88f3be126d0fe02a92c20e1d78192f4b648401
commit-date: 2015-04-27
build-date: 2015-04-27
host: x86_64-pc-windows-gnu
release: 1.1.0-dev
</code></pre></div>
<p dir="auto">Backtrace by <a class="user-mention notranslate" data-hovercard-type="organization" data-hovercard-url="/orgs/kballard/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/kballard">@kballard</a> using rustc 1.1.0-nightly (<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/5fb0259edfbc4034cfbcf827ab91d6118b7ae848/hovercard" href="https://github.com/rust-lang/rust/commit/5fb0259edfbc4034cfbcf827ab91d6118b7ae848"><tt>5fb0259</tt></a> 2015-04-26) (built 2015-04-26)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ env RUST_BACKTRACE=1 cargo run --example something
   Compiling term v0.2.7 (file:///Users/kevin/Dev/rust/Scratch/term)
examples/something.rs:19:14: 2:54 error: source trait is private
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcore/option.rs:330

stack backtrace:
   1:        0x105cb7b3f - sys::backtrace::write::h7c4b7b31b5a98994KVr
   2:        0x105cc0242 - panicking::on_panic::h130becb52f065864NVv
   3:        0x105c7c985 - rt::unwind::begin_unwind_inner::hf2ec506d50a3ea22wDv
   4:        0x105c7d7bc - rt::unwind::begin_unwind_fmt::he465542fba1a288eCCv
   5:        0x105cbfd9c - rust_begin_unwind
   6:        0x105d0f7b5 - panicking::panic_fmt::h39c9227a84864bb7yKy
   7:        0x105449ce3 - codemap::CodeMap::span_to_lines::h8832e04ed2aff1a62gA
   8:        0x10548fd2b - diagnostic::emit::h695a3e055df98e351UB
   9:        0x10548d4cc - diagnostic::EmitterWriter.Emitter::emit::h786e8cf93696a544JRB
  10:        0x10543ff39 - diagnostic::SpanHandler::span_err::h9f68fad8e64a9d63PnB
  11:        0x102e69e33 - session::Session::span_err::h2d09ffe9b87a2a3fIOp
  12:        0x102879295 - PrivacyVisitor&lt;'a, 'tcx&gt;::report_error::had53c10fa374641a2Ra
  13:        0x10287c29b - PrivacyVisitor&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_expr::h1cd280cef77a740dHhb
  14:        0x10287dcc3 - visit::Visitor::visit_block::h7884039954563752346
  15:        0x10287d549 - visit::Visitor::visit_fn::h18293213297878176316
  16:        0x10287b631 - PrivacyVisitor&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_item::h83709f09c8dd29dfxdb
  17:        0x10288241a - check_crate::h0ad7434cff2b8431EVb
  18:        0x102437393 - driver::phase_3_run_analysis_passes::h84861191833defe7tGa
  19:        0x102419588 - driver::compile_input::h65cad254ac62afa6Qba
  20:        0x1024d8613 - run_compiler::hbd6a992aacaf1248F4b
  21:        0x1024d5d7a - boxed::F.FnBox&lt;A&gt;::call_box::h9480122591250505076
  22:        0x1024d52c7 - rt::unwind::try::try_fn::h5956310425634165804
  23:        0x105d42618 - rust_try_inner
  24:        0x105d42605 - rust_try
  25:        0x1024d559e - boxed::F.FnBox&lt;A&gt;::call_box::h8195565033996650298
  26:        0x105cbec3d - sys::thread::Thread::new::thread_start::h8efe8b1c3780385fvYu
  27:     0x7fff94dfe267 - _pthread_body
  28:     0x7fff94dfe1e4 - _pthread_start

Could not compile `term`.

To learn more, run the command again with --verbose."><pre class="notranslate"><code class="notranslate">$ env RUST_BACKTRACE=1 cargo run --example something
   Compiling term v0.2.7 (file:///Users/kevin/Dev/rust/Scratch/term)
examples/something.rs:19:14: 2:54 error: source trait is private
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcore/option.rs:330

stack backtrace:
   1:        0x105cb7b3f - sys::backtrace::write::h7c4b7b31b5a98994KVr
   2:        0x105cc0242 - panicking::on_panic::h130becb52f065864NVv
   3:        0x105c7c985 - rt::unwind::begin_unwind_inner::hf2ec506d50a3ea22wDv
   4:        0x105c7d7bc - rt::unwind::begin_unwind_fmt::he465542fba1a288eCCv
   5:        0x105cbfd9c - rust_begin_unwind
   6:        0x105d0f7b5 - panicking::panic_fmt::h39c9227a84864bb7yKy
   7:        0x105449ce3 - codemap::CodeMap::span_to_lines::h8832e04ed2aff1a62gA
   8:        0x10548fd2b - diagnostic::emit::h695a3e055df98e351UB
   9:        0x10548d4cc - diagnostic::EmitterWriter.Emitter::emit::h786e8cf93696a544JRB
  10:        0x10543ff39 - diagnostic::SpanHandler::span_err::h9f68fad8e64a9d63PnB
  11:        0x102e69e33 - session::Session::span_err::h2d09ffe9b87a2a3fIOp
  12:        0x102879295 - PrivacyVisitor&lt;'a, 'tcx&gt;::report_error::had53c10fa374641a2Ra
  13:        0x10287c29b - PrivacyVisitor&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_expr::h1cd280cef77a740dHhb
  14:        0x10287dcc3 - visit::Visitor::visit_block::h7884039954563752346
  15:        0x10287d549 - visit::Visitor::visit_fn::h18293213297878176316
  16:        0x10287b631 - PrivacyVisitor&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_item::h83709f09c8dd29dfxdb
  17:        0x10288241a - check_crate::h0ad7434cff2b8431EVb
  18:        0x102437393 - driver::phase_3_run_analysis_passes::h84861191833defe7tGa
  19:        0x102419588 - driver::compile_input::h65cad254ac62afa6Qba
  20:        0x1024d8613 - run_compiler::hbd6a992aacaf1248F4b
  21:        0x1024d5d7a - boxed::F.FnBox&lt;A&gt;::call_box::h9480122591250505076
  22:        0x1024d52c7 - rt::unwind::try::try_fn::h5956310425634165804
  23:        0x105d42618 - rust_try_inner
  24:        0x105d42605 - rust_try
  25:        0x1024d559e - boxed::F.FnBox&lt;A&gt;::call_box::h8195565033996650298
  26:        0x105cbec3d - sys::thread::Thread::new::thread_start::h8efe8b1c3780385fvYu
  27:     0x7fff94dfe267 - _pthread_body
  28:     0x7fff94dfe1e4 - _pthread_start

Could not compile `term`.

To learn more, run the command again with --verbose.
</code></pre></div>
<p dir="auto">This error is related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="56910226" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/22050" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/22050/hovercard" href="https://github.com/rust-lang/rust/issues/22050">#22050</a>, not sure if it's a dupe. Some of the following code snippets rely on the <a href="https://crates.io/crates/term" rel="nofollow">term</a> library (but the issue seems to be in Rust, not <code class="notranslate">term</code>).</p>
<p dir="auto">The following builds fine:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn foo() {
    let mut s = String::new();
    writeln!(s, &quot;foo&quot;).unwrap();
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-k">mut</span> s = <span class="pl-smi">String</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">writeln</span><span class="pl-en">!</span><span class="pl-kos">(</span>s, <span class="pl-s">"foo"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">unwrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This gives an error:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="extern crate term;

fn foo() {
    let mut t = term::stdout().unwrap();
    writeln!(t, &quot;foo&quot;).unwrap();
}"><pre class="notranslate"><span class="pl-k">extern</span> <span class="pl-k">crate</span> term<span class="pl-kos">;</span>

<span class="pl-k">fn</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-k">mut</span> t = term<span class="pl-kos">::</span><span class="pl-en">stdout</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">unwrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">writeln</span><span class="pl-en">!</span><span class="pl-kos">(</span>t, <span class="pl-s">"foo"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">unwrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="lib.rs:5:5: 5:23 error: source trait is private
lib.rs:5     writeln!(t, &quot;foo&quot;).unwrap();"><pre class="notranslate"><code class="notranslate">lib.rs:5:5: 5:23 error: source trait is private
lib.rs:5     writeln!(t, "foo").unwrap();
</code></pre></div>
<p dir="auto">This is the error mentioned in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="56910226" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/22050" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/22050/hovercard" href="https://github.com/rust-lang/rust/issues/22050">#22050</a>. Importing <code class="notranslate">std::io::Write</code> fixes the error. However, if <code class="notranslate">println</code> is used, we get no errors:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="extern crate term;

fn foo() {
    let mut t = term::stdout().unwrap();
    writeln!(t, &quot;foo&quot;).unwrap();
    println!(&quot;foo&quot;);
}"><pre class="notranslate"><span class="pl-k">extern</span> <span class="pl-k">crate</span> term<span class="pl-kos">;</span>

<span class="pl-k">fn</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-k">mut</span> t = term<span class="pl-kos">::</span><span class="pl-en">stdout</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">unwrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">writeln</span><span class="pl-en">!</span><span class="pl-kos">(</span>t, <span class="pl-s">"foo"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">unwrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"foo"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>