Skip to content

mismatched types error without location info #70987

Closed
@joachimm

Description

@joachimm

I am a complete beginner to rust, I tried the below code. I have tried to minimise as well as I could but the issue go away if I remove the use cached::Cached stuff, and the underlying error is then presented (wrong type for warp::redirect), I also have tried this outside the DropBox folder without any difference :

#![deny(warnings)]

use std::sync::{Arc, Mutex};
use warp::Filter;
use warp::http::Uri;
use uuid::Uuid;
use cached::Cached;

#[tokio::main]
async fn main() {
    pretty_env_logger::init();

    let claim_cache : Arc<Mutex<cached::stores::SizedCache<Uuid, Vec<Uuid>>>>= Arc::new(Mutex::new(cached::stores::SizedCache::with_size(500)));

    let create = warp::post()
        .and(warp::path("create"))
        .map(move || {
                let uuid = Uuid::new_v4();
                let mut cache = claim_cache.lock().unwrap();
                let _invitees = cache.cache_get_mut(&uuid);
                let uuid = uuid.to_urn();
                let string = format!("/?claim/{}", uuid);
                let uri: Uri = string.parse().unwrap();
                // fix:   warp::redirect(uri)

                warp::redirect(Uri::from_static(uri))
            }
        );


    warp::serve(create).run(([127, 0, 0, 1], 3030)).await;
}

With this Cargo.toml

[package]
name = "sandstorm"
version = "0.1.0"
authors = ["Joachim Mårtensson <removed-just-in-case>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "0.2", features = ["macros"] }
warp = "0.2"
pretty_env_logger = "0.4.0"
cached = "0.12.0"
uuid= {version = "0.8.1", features = ["serde", "v4"] }

I expected to see this happen:
An Error message detailing, with a line number and column, what is wrong with my code and ideally how to fix it.
Something like:

error[E0308]: mismatched types
  --> src/main.rs:19:49
   |
19 |                 warp::redirect(Uri::from_static(uri))
   |                                                 ^^^ expected `&str`, found struct `http::uri::Uri`

error: aborting due to previous error

Instead, this happened:
I get error output without any pointers to where the issue is.
Compiling sandstorm v0.1.0 (/Users/joachimm/Dropbox/sandstorm)

error[E0308]: mismatched types

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `sandstorm`.

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

Meta

rustc --version --verbose:

rustc 1.42.0 (b8cedc004 2020-03-09)
binary: rustc
commit-hash: b8cedc00407a4c56a3bda1ed605c6fc166655447
commit-date: 2020-03-09
host: x86_64-apple-darwin
release: 1.42.0
LLVM version: 9.0
Backtrace

$ RUST_BACKTRACE=1 cargo build
   Compiling sandstorm v0.1.0 (/Users/joachimm/Dropbox/sandstorm)
error[E0308]: mismatched types

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `sandstorm`.

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

</p>
</details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions