Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mismatched types error without location info #70987

Closed
joachimm opened this issue Apr 10, 2020 · 1 comment · Fixed by #72306
Closed

mismatched types error without location info #70987

joachimm opened this issue Apr 10, 2020 · 1 comment · Fixed by #72306
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@joachimm
Copy link

joachimm commented Apr 10, 2020

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>
@joachimm joachimm added the C-bug Category: This is a bug. label Apr 10, 2020
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 10, 2020
@Aaron1011
Copy link
Member

This will be fixed by #72306

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 20, 2020
…petrochenkov

Break tokens before checking if they are 'probably equal'

Fixes rust-lang#68489
Fixes rust-lang#70987

When checking two `TokenStreams` to see if they are 'probably equal',
we ignore the `IsJoint` information associated with each `TokenTree`.
However, the `IsJoint` information determines whether adjacent tokens
will be 'glued' (if possible) when construction the `TokenStream` - e.g.
`[Gt Gt]` can be 'glued' to `BinOp(Shr)`.

Since we are ignoring the `IsJoint` information, 'glued' and 'unglued'
tokens are equivalent for determining if two `TokenStreams` are
'probably equal'. Therefore, we need to 'unglue' all tokens in the
stream to avoid false negatives (which cause us to throw out the cached
tokens, losing span information).
@Aaron1011 Aaron1011 added the A-proc-macros Area: Procedural macros label May 21, 2020
@bors bors closed this as completed in 62d4e9e May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants