zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.61k stars 72 forks source link

error[E0284]: type annotation needed #105

Closed samvv closed 3 months ago

samvv commented 3 months ago

Hi, I'm getting the following error on this snippet:

Report::build(ReportKind::Error, "foobar", d.offset)
    .with_message(d.message())
    .finish()
    .print((
        "foobar",
        Source::from(d.file.text())
    ))
    .unwrap()
error[E0283]: type annotations needed
   --> src/diagnostic.rs:363:9
    |
363 |         Report::build(ReportKind::Error, "fooba", d.offset)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `U`
    |
    = note: multiple `impl`s satisfying `_: From<&str>` found in the `clap_builder` crate:
            - impl From<&'static str> for Id;
            - impl From<&'static str> for Str;
            - impl From<&'static str> for clap::builder::OsStr;
            - impl From<&'static str> for clap::builder::StyledStr;
    = note: required for `&str` to implement `Into<_>`
note: required by a bound in `ariadne::Report::<'_, S>::build`
   --> /home/samvv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ariadne-0.4.0/src/lib.rs:159:22
    |
159 |     pub fn build<Id: Into<<S::SourceId as ToOwned>::Owned>>(kind: ReportKind, src_id: Id, offset: usize) -> ReportBuilder<S> {
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Report::<'_, S>::build`

Does anyone know what's happening here? In particular, I have no idea what the impls from clap_builder are doing there. They are not imported.

samvv commented 3 months ago

Never mind I think I found the problem ... I'm not creating a label, which makes the Rust type checker fail to infer S as indicated by a previous (unposted error).

Sorry for the noise!