Skip to content

Smol 2.0 (async-net 2.0) causes trait error "not implemented" when trying tiberius::SqlBrowser::connect_named #386

@powpingdone

Description

@powpingdone

With the following file contents:

Cargo.toml

[package]
name = "a"
version = "0.1.0"
edition = "2024"

[dependencies]
async-net = "2.0.0"
smol = "2.0.2"
tiberius = { version = "0.12.3", features = ["sql-browser-smol"] }

src/main.rs

use tiberius::SqlBrowser;

fn main() {
    smol::block_on(async move {
        let config = tiberius::Config::new();
        // Weird syntax to show bug, as if you just do it directly it doesn't show the trait error.
        let socket = <async_net::TcpStream as SqlBrowser>::connect_named(&config).await.unwrap();
    });
}

This produces the following error:

   Compiling a v0.1.0 (/home/powpingdone/extern/a)
error[E0277]: the trait bound `async_net::TcpStream: SqlBrowser` is not satisfied
 --> src/main.rs:6:23
  |
6 |         let socket = <async_net::TcpStream as SqlBrowser>::connect_named(&config).await.unwrap();
  |                       ^^^^^^^^^^^^^^^^^^^^ the trait `SqlBrowser` is not implemented for `async_net::TcpStream`
  |
  = help: the trait `SqlBrowser` is implemented for `async_net::tcp::TcpStream`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `a` (bin "a") due to 1 previous error

However, you cannot use async_net::tcp::TcpStream from async_net 2.0 due to it being a private definition. Likely fix is defining SqlBrowser on async_net::TcpStream directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions