提交 f103b296 编写于 作者: B bors

Auto merge of #94865 - notriddle:notriddle/single-colon-path-not-const-generics, r=cjgillot

diagnostics: single colon within `<>` probably, not type ascription

Fixes #94812
......@@ -2073,6 +2073,19 @@ pub fn recover_const_arg(
let value = self.mk_expr_err(start.to(expr.span));
err.emit();
return Ok(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value }));
} else if token::Colon == snapshot.token.kind
&& expr.span.lo() == snapshot.token.span.hi()
&& matches!(expr.kind, ExprKind::Path(..))
{
// Find a mistake like "foo::var:A".
err.span_suggestion(
snapshot.token.span,
"write a path separator here",
"::".to_string(),
Applicability::MaybeIncorrect,
);
err.emit();
return Ok(GenericArg::Type(self.mk_ty(start.to(expr.span), TyKind::Err)));
} else if token::Comma == self.token.kind || self.token.kind.should_end_const_arg()
{
// Avoid the following output by checking that we consumed a full const arg:
......
pub mod foo {
pub mod bar {
pub struct A;
}
}
pub struct Foo {
a: Vec<foo::bar:A>,
//~^ ERROR expected
//~| HELP path separator
}
fn main() {}
error: expected one of `,` or `>`, found `:`
--> $DIR/single-colon-path-not-const-generics.rs:8:18
|
LL | a: Vec<foo::bar:A>,
| ^
| |
| expected one of `,` or `>`
| help: write a path separator here: `::`
error: aborting due to previous error
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册