diff --git a/tests/ui/resolve/conflicting-primitive-names.rs b/tests/ui/resolve/conflicting-primitive-names.rs new file mode 100644 index 0000000000000..79b6990681d98 --- /dev/null +++ b/tests/ui/resolve/conflicting-primitive-names.rs @@ -0,0 +1,30 @@ +//@ check-pass +#![allow(non_camel_case_types)] +#![allow(unused)] + +// Ensure that primitives do not interfere with user types of similar names + +macro_rules! make_ty_mod { + ($modname:ident, $ty:tt) => { + mod $modname { + struct $ty { + a: i32, + } + + fn assignment() { + let $ty = (); + } + + fn access(a: $ty) -> i32 { + a.a + } + } + }; +} + +make_ty_mod!(check_f16, f16); +make_ty_mod!(check_f32, f32); +make_ty_mod!(check_f64, f64); +make_ty_mod!(check_f128, f128); + +fn main() {} diff --git a/tests/ui/resolve/primitive-f128.rs b/tests/ui/resolve/primitive-f128.rs new file mode 100644 index 0000000000000..5b57ed779e63f --- /dev/null +++ b/tests/ui/resolve/primitive-f128.rs @@ -0,0 +1,18 @@ +//@ check-pass +#![feature(f128)] + +// Same as the feature gate test but ensure we can use the types + +const A: f128 = 10.0; + +pub fn main() { + let a: f128 = 100.0; + let b = 0.0f128; + foo(1.23); +} + +fn foo(a: f128) {} + +struct Bar { + a: f128, +} diff --git a/tests/ui/resolve/primitive-f16.rs b/tests/ui/resolve/primitive-f16.rs new file mode 100644 index 0000000000000..7709b247d84f5 --- /dev/null +++ b/tests/ui/resolve/primitive-f16.rs @@ -0,0 +1,18 @@ +//@ check-pass +#![feature(f16)] + +// Same as the feature gate test but ensure we can use the types + +const A: f16 = 10.0; + +pub fn main() { + let a: f16 = 100.0; + let b = 0.0f16; + foo(1.23); +} + +fn foo(a: f16) {} + +struct Bar { + a: f16, +}