Generalize reference-to-reference check to cover all positions
Checking this in check_type_ref allows it to apply anywhere that a
reference is written, such as return position which was not covered by
the previous logic.
diff --git a/syntax/check.rs b/syntax/check.rs
index a90db49..3e121b5 100644
--- a/syntax/check.rs
+++ b/syntax/check.rs
@@ -151,6 +151,10 @@
match ty.inner {
Type::Fn(_) | Type::Void(_) => {}
+ Type::Ref(_) => {
+ cx.error(ty, "C++ does not allow references to references");
+ return;
+ }
_ => return,
}
@@ -230,11 +234,6 @@
);
}
}
- if let Type::Ref(ity) = &arg.ty {
- if let Type::Ref(_) = &ity.inner {
- cx.error(arg, "Passing a reference to a reference is not supported");
- }
- }
}
if let Some(ty) = &efn.ret {