Auto merge of #125863 - fmease:rej-CVarArgs-in-parse_ty_for_where_clause, r=compiler-errors
Reject `CVarArgs` in `parse_ty_for_where_clause` Fixes #125847. This regressed in #77035 where the `parse_ty` inside `parse_ty_where_predicate` was replaced with the at the time new `parse_ty_for_where_clause` which incorrectly stated it would permit CVarArgs (maybe a copy/paste error). r? parser
This commit is contained in:
commit
f67a1acc04
@ -194,7 +194,7 @@ pub(super) fn parse_ty_no_question_mark_recover(&mut self) -> PResult<'a, P<Ty>>
|
|||||||
pub(super) fn parse_ty_for_where_clause(&mut self) -> PResult<'a, P<Ty>> {
|
pub(super) fn parse_ty_for_where_clause(&mut self) -> PResult<'a, P<Ty>> {
|
||||||
self.parse_ty_common(
|
self.parse_ty_common(
|
||||||
AllowPlus::Yes,
|
AllowPlus::Yes,
|
||||||
AllowCVariadic::Yes,
|
AllowCVariadic::No,
|
||||||
RecoverQPath::Yes,
|
RecoverQPath::Yes,
|
||||||
RecoverReturnSign::OnlyFatArrow,
|
RecoverReturnSign::OnlyFatArrow,
|
||||||
None,
|
None,
|
||||||
@ -344,8 +344,9 @@ fn parse_ty_common(
|
|||||||
match allow_c_variadic {
|
match allow_c_variadic {
|
||||||
AllowCVariadic::Yes => TyKind::CVarArgs,
|
AllowCVariadic::Yes => TyKind::CVarArgs,
|
||||||
AllowCVariadic::No => {
|
AllowCVariadic::No => {
|
||||||
// FIXME(Centril): Should we just allow `...` syntactically
|
// FIXME(c_variadic): Should we just allow `...` syntactically
|
||||||
// anywhere in a type and use semantic restrictions instead?
|
// anywhere in a type and use semantic restrictions instead?
|
||||||
|
// NOTE: This may regress certain MBE calls if done incorrectly.
|
||||||
let guar = self
|
let guar = self
|
||||||
.dcx()
|
.dcx()
|
||||||
.emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
|
.emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
|
||||||
|
11
tests/ui/parser/macro/mbe-dotdotdot-may-not-begin-a-type.rs
Normal file
11
tests/ui/parser/macro/mbe-dotdotdot-may-not-begin-a-type.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// A bare `...` represents `CVarArgs` (`VaListImpl<'_>`) in function argument type
|
||||||
|
// position without being a proper type syntactically.
|
||||||
|
// This test ensures that we do not regress certain MBE calls would we ever promote
|
||||||
|
// `...` to a proper type syntactically.
|
||||||
|
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
macro_rules! ck { ($ty:ty) => { compile_error!(""); }; (...) => {}; }
|
||||||
|
ck!(...);
|
||||||
|
|
||||||
|
fn main() {}
|
@ -4,6 +4,10 @@ fn f1<'a>(x: u8, y: &'a ...) {}
|
|||||||
fn f2<'a>(x: u8, y: Vec<&'a ...>) {}
|
fn f2<'a>(x: u8, y: Vec<&'a ...>) {}
|
||||||
//~^ ERROR C-variadic type `...` may not be nested inside another type
|
//~^ ERROR C-variadic type `...` may not be nested inside another type
|
||||||
|
|
||||||
|
// Regression test for issue #125847.
|
||||||
|
fn f3() where for<> ...: {}
|
||||||
|
//~^ ERROR C-variadic type `...` may not be nested inside another type
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _recovery_witness: () = 0;
|
let _recovery_witness: () = 0;
|
||||||
//~^ ERROR: mismatched types
|
//~^ ERROR: mismatched types
|
||||||
|
@ -10,15 +10,21 @@ error[E0743]: C-variadic type `...` may not be nested inside another type
|
|||||||
LL | fn f2<'a>(x: u8, y: Vec<&'a ...>) {}
|
LL | fn f2<'a>(x: u8, y: Vec<&'a ...>) {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
|
error[E0743]: C-variadic type `...` may not be nested inside another type
|
||||||
|
--> $DIR/variadic-ffi-nested-syntactic-fail.rs:8:21
|
||||||
|
|
|
||||||
|
LL | fn f3() where for<> ...: {}
|
||||||
|
| ^^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/variadic-ffi-nested-syntactic-fail.rs:8:33
|
--> $DIR/variadic-ffi-nested-syntactic-fail.rs:12:33
|
||||||
|
|
|
|
||||||
LL | let _recovery_witness: () = 0;
|
LL | let _recovery_witness: () = 0;
|
||||||
| -- ^ expected `()`, found integer
|
| -- ^ expected `()`, found integer
|
||||||
| |
|
| |
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0743.
|
Some errors have detailed explanations: E0308, E0743.
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
For more information about an error, try `rustc --explain E0308`.
|
||||||
|
Loading…
Reference in New Issue
Block a user