Skip to content

Commit 44616e1

Browse files
Add test for the issue
1 parent 42c4f10 commit 44616e1

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
#![crate_type = "proc-macro"]
5+
6+
extern crate proc_macro;
7+
use proc_macro::TokenStream;
8+
9+
#[proc_macro_derive(Deserialize)]
10+
pub fn deserialize_derive(input: TokenStream) -> TokenStream {
11+
"impl Build {
12+
fn deserialize() -> Option<u64> {
13+
let x: Option<u32> = Some(0);
14+
Some(x? + 1)
15+
}
16+
}
17+
"
18+
.parse()
19+
.unwrap()
20+
}

tests/ui/proc-macro/issue-118809.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// aux-build: issue-118809.rs
2+
3+
#[macro_use]
4+
extern crate issue_118809;
5+
6+
#[derive(Deserialize)] //~ ERROR mismatched types [E0308]
7+
pub struct Build {
8+
}
9+
10+
fn main() {}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-118809.rs:6:10
3+
|
4+
LL | #[derive(Deserialize)]
5+
| ^^^^^^^^^^^
6+
| |
7+
| expected `u64`, found `u32`
8+
| arguments to this enum variant are incorrect
9+
|
10+
help: the type constructed contains `u32` due to the type of the argument passed
11+
--> $DIR/issue-118809.rs:6:10
12+
|
13+
LL | #[derive(Deserialize)]
14+
| ^^^^^^^^^^^ this argument influences the type of `Some`
15+
note: tuple variant defined here
16+
--> $SRC_DIR/core/src/option.rs:LL:COL
17+
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
18+
19+
error: aborting due to 1 previous error
20+
21+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)