-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
Remove astconv usage in diagnostic Fixes #107775 Location of the test sucks, I know, but I needed to put it somewhere 😓 The issue here is that the root cause of the issue has nothing to do with what's being tested, so I couldn't really give it a better name. Oh well.
- Loading branch information
Showing
3 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// edition: 2021 | ||
|
||
use std::collections::HashMap; | ||
use std::future::Future; | ||
use std::pin::Pin; | ||
|
||
pub trait Trait { | ||
fn do_something<'async_trait>(byte: u8) | ||
-> | ||
Pin<Box<dyn Future<Output = ()> + | ||
Send + 'async_trait>>; | ||
} | ||
|
||
pub struct Struct; | ||
|
||
impl Trait for Struct { | ||
fn do_something<'async_trait>(byte: u8) | ||
-> | ||
Pin<Box<dyn Future<Output = ()> + | ||
Send + 'async_trait>> { | ||
Box::pin( | ||
|
||
async move { let byte = byte; let _: () = {}; }) | ||
} | ||
} | ||
|
||
pub struct Map { | ||
map: HashMap<u16, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>>>, | ||
} | ||
|
||
impl Map { | ||
pub fn new() -> Self { | ||
let mut map = HashMap::new(); | ||
map.insert(1, Struct::do_something); | ||
Self { map } | ||
//~^ ERROR mismatched types | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-107775.rs:35:16 | ||
| | ||
LL | map.insert(1, Struct::do_something); | ||
| - -------------------- this is of type `fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` | ||
| | | ||
| this is of type `{integer}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` | ||
LL | Self { map } | ||
| ^^^ expected `HashMap<u16, fn(u8) -> Pin<...>>`, found `HashMap<{integer}, ...>` | ||
| | ||
= note: expected struct `HashMap<u16, fn(_) -> Pin<Box<(dyn Future<Output = ()> + Send + 'static)>>>` | ||
found struct `HashMap<{integer}, fn(_) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |