summaryrefslogtreecommitdiffstats
path: root/tests/ui/typeck/issue-89856.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/typeck/issue-89856.fixed')
-rw-r--r--tests/ui/typeck/issue-89856.fixed18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/typeck/issue-89856.fixed b/tests/ui/typeck/issue-89856.fixed
new file mode 100644
index 000000000..3e1a006ef
--- /dev/null
+++ b/tests/ui/typeck/issue-89856.fixed
@@ -0,0 +1,18 @@
+// run-rustfix
+
+fn take_str_maybe(_: Option<&str>) { }
+fn main() {
+ let string = String::from("Hello, world");
+
+ let option: Option<String> = Some(string.clone());
+ take_str_maybe(option.as_deref());
+ //~^ ERROR: mismatched types [E0308]
+
+ let option_ref = Some(&string);
+ take_str_maybe(option_ref.map(|x| x.as_str()));
+ //~^ ERROR: mismatched types [E0308]
+
+ let option_ref_ref = option_ref.as_ref();
+ take_str_maybe(option_ref_ref.map(|x| x.as_str()));
+ //~^ ERROR: mismatched types [E0308]
+}