summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/uninhabited_references.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/uninhabited_references.rs')
-rw-r--r--src/tools/clippy/tests/ui/uninhabited_references.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/uninhabited_references.rs b/src/tools/clippy/tests/ui/uninhabited_references.rs
new file mode 100644
index 000000000..cd07b590a
--- /dev/null
+++ b/src/tools/clippy/tests/ui/uninhabited_references.rs
@@ -0,0 +1,22 @@
+#![warn(clippy::uninhabited_references)]
+#![feature(never_type)]
+
+fn ret_uninh_ref() -> &'static std::convert::Infallible {
+ unsafe { std::mem::transmute(&()) }
+}
+
+macro_rules! ret_something {
+ ($name:ident, $ty:ty) => {
+ fn $name(x: &$ty) -> &$ty {
+ &*x
+ }
+ };
+}
+
+ret_something!(id_u32, u32);
+ret_something!(id_never, !);
+
+fn main() {
+ let x = ret_uninh_ref();
+ let _ = *x;
+}