Skip to content
This repository was archived by the owner on Aug 6, 2023. It is now read-only.

Macro error when compiling #373

Closed
jeanmanguy opened this issue Sep 9, 2020 · 4 comments · Fixed by #368
Closed

Macro error when compiling #373

jeanmanguy opened this issue Sep 9, 2020 · 4 comments · Fixed by #368
Labels

Comments

@jeanmanguy
Copy link

Describe the bug

Hi, I would like to try your library but sadly tui 0.10 doesn't compile. Something with the crossterm backend and some macro apparently. Am I doing something wrong?

   Compiling tui v0.10.0
error[E0599]: no method named `flush` found for struct `std::string::String` in the current scope
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:64:19
   |
64 |         map_error(queue!(string, MoveTo(0, 0)))?;
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `std::string::String`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
note: `backend::Backend` defines an item `flush`, perhaps you need to implement it
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\mod.rs:29:1
   |
29 | pub trait Backend {
   | ^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `flush` found for struct `std::string::String` in the current scope
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:67:27
   |
67 |                 map_error(queue!(string, MoveTo(x, y)))?;
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `std::string::String`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
note: `backend::Backend` defines an item `flush`, perhaps you need to implement it
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\mod.rs:29:1
   |
29 | pub trait Backend {
   | ^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `flush` found for struct `std::string::String` in the current scope
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:81:27
   |
81 |                 map_error(queue!(string, SetForegroundColor(color)))?;
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `std::string::String`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
note: `backend::Backend` defines an item `flush`, perhaps you need to implement it
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\mod.rs:29:1
   |
29 | pub trait Backend {
   | ^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `flush` found for struct `std::string::String` in the current scope
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:86:27
   |
86 |                 map_error(queue!(string, SetBackgroundColor(color)))?;
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `std::string::String`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
note: `backend::Backend` defines an item `flush`, perhaps you need to implement it
  --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\mod.rs:29:1
   |
29 | pub trait Backend {
   | ^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `flush` found for type parameter `W` in the current scope
   --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:242:23
    |
242 |             map_error(queue!(w, SetAttribute(CAttribute::NormalIntensity)))?;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `W`
    |
    = help: items from traits can only be used if the type parameter is bounded by the trait
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following traits define an item `flush`, perhaps you need to restrict type parameter `W` with one of them:
    |
236 |     fn queue<W: backend::Backend>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^^^
236 |     fn queue<W: std::io::Write>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^

error[E0599]: no method named `flush` found for type parameter `W` in the current scope
   --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:245:23
    |
245 |             map_error(queue!(w, SetAttribute(CAttribute::NoUnderline)))?;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `W`
    |
    = help: items from traits can only be used if the type parameter is bounded by the trait
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following traits define an item `flush`, perhaps you need to restrict type parameter `W` with one of them:
    |
236 |     fn queue<W: backend::Backend>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^^^
236 |     fn queue<W: std::io::Write>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^

error[E0599]: no method named `flush` found for type parameter `W` in the current scope
   --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:250:23
    |
250 |             map_error(queue!(w, SetAttribute(CAttribute::Bold)))?;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `W`
    |
    = help: items from traits can only be used if the type parameter is bounded by the trait
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following traits define an item `flush`, perhaps you need to restrict type parameter `W` with one of them:
    |
236 |     fn queue<W: backend::Backend>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^^^
236 |     fn queue<W: std::io::Write>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^

error[E0599]: no method named `flush` found for type parameter `W` in the current scope
   --> C:\Users\Jean\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tui-0.10.0\src\backend\crossterm.rs:253:23
    |
253 |             map_error(queue!(w, SetAttribute(CAttribute::Underlined)))?;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `W`
    |
    = help: items from traits can only be used if the type parameter is bounded by the trait
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following traits define an item `flush`, perhaps you need to restrict type parameter `W` with one of them:
    |
236 |     fn queue<W: backend::Backend>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^^^
236 |     fn queue<W: std::io::Write>(&self, mut w: W) -> io::Result<()>
    |              ^^^^^^^^^^^^^^^^^

error: aborting due to 8 previous errors

To Reproduce

I added Tui with crossterm as dependencies

[dependencies]
tui = { version = "0.10", features = ["crossterm"], default-features = false }
cargo build

Interestingly, 0.8 compiles and 0.9 doesn't.

[dependencies]
tui = { version = "0.8", features = ["crossterm"], default-features = false }

Demos don't work either, I get the same error.

cargo run --example crossterm_demo --no-default-features --features="crossterm" --release -- --tick-rate 200

Expected behavior

Tui to compile.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Windows 10
  • Terminal Emulator: N/A
  • Font: N/A
  • Crate version: from 0.9 to 0.10
  • Backend: crossterm

Additional context

Toolchain:
stable-x86_64-pc-windows-msvc (default)
rustc 1.46.0 (04488afe3 2020-08-24)

@jeanmanguy jeanmanguy added the bug label Sep 9, 2020
@spenserblack
Copy link

spenserblack commented Sep 9, 2020

I'm also experiencing this in my CI. It might be Windows-only -- Linux is fine. It seems that crossterm 0.17.8 introduced a change that breaks tui with the crossterm feature. It's fine when crossterm is 0.17.7. Try adding crossterm = "0.17.7" to your Cargo.toml. I think that will force tui to then use 0.17.7, and then tui should compile.

@jeanmanguy
Copy link
Author

Yes, it works with crossterm = "=0.17.7" after deleting Cargo.lock. Thank you.

Hopefully that will help figuring out a fix.

@extrawurst
Copy link
Contributor

Having the same issue in gitui: gitui-org/gitui#279

alvinhochun added a commit to alvinhochun/tui-rs that referenced this issue Sep 10, 2020
Crossterm might actually do WinAPI calls instead of writing ANSI excape
codes so writing to an intermediate String may cause issues on older
versions of Windows. It also fails to compile with Crossterm 0.17.8 due
to Crossterm now expecting the writer to support `flush`, which String
doesn't.

Fixes fdehau#373
@alvinhochun
Copy link
Contributor

I proposed a fix in PR #368.

fdehau pushed a commit that referenced this issue Sep 20, 2020
…and fix build with Crossterm 0.17.8 (#368)

* Support more style modifiers on Windows
* Change Crossterm backend to write directly to buffer instead of String

Crossterm might actually do WinAPI calls instead of writing ANSI excape
codes so writing to an intermediate String may cause issues on older
versions of Windows. It also fails to compile with Crossterm 0.17.8 due
to Crossterm now expecting the writer to support `flush`, which String
doesn't.

Fixes #373
TheLostLambda pushed a commit to TheLostLambda/tui-rs that referenced this issue Sep 24, 2020
…and fix build with Crossterm 0.17.8 (fdehau#368)

* Support more style modifiers on Windows
* Change Crossterm backend to write directly to buffer instead of String

Crossterm might actually do WinAPI calls instead of writing ANSI excape
codes so writing to an intermediate String may cause issues on older
versions of Windows. It also fails to compile with Crossterm 0.17.8 due
to Crossterm now expecting the writer to support `flush`, which String
doesn't.

Fixes fdehau#373
24seconds pushed a commit to 24seconds/tui-rs that referenced this issue Nov 30, 2020
…and fix build with Crossterm 0.17.8 (fdehau#368)

* Support more style modifiers on Windows
* Change Crossterm backend to write directly to buffer instead of String

Crossterm might actually do WinAPI calls instead of writing ANSI excape
codes so writing to an intermediate String may cause issues on older
versions of Windows. It also fails to compile with Crossterm 0.17.8 due
to Crossterm now expecting the writer to support `flush`, which String
doesn't.

Fixes fdehau#373
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants