From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/mir-opt/simple_option_map_e2e.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/mir-opt/simple_option_map_e2e.rs (limited to 'tests/mir-opt/simple_option_map_e2e.rs') diff --git a/tests/mir-opt/simple_option_map_e2e.rs b/tests/mir-opt/simple_option_map_e2e.rs new file mode 100644 index 000000000..2acd2a227 --- /dev/null +++ b/tests/mir-opt/simple_option_map_e2e.rs @@ -0,0 +1,19 @@ +#[inline(always)] +fn map(slf: Option, f: F) -> Option +where + F: FnOnce(T) -> U, +{ + match slf { + Some(x) => Some(f(x)), + None => None, + } +} + +// EMIT_MIR simple_option_map_e2e.ezmap.PreCodegen.after.mir +pub fn ezmap(x: Option) -> Option { + map(x, |n| n + 1) +} + +fn main() { + assert_eq!(None, ezmap(None)); +} -- cgit v1.2.3