mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Remove (..)
-style return type notation
This commit is contained in:
parent
a4966c9282
commit
d7d8971203
6 changed files with 2 additions and 101 deletions
|
@ -216,9 +216,6 @@ pub(super) fn lower_generic_args(
|
||||||
let arg = ConstRefOrPath::from_expr_opt(arg.expr());
|
let arg = ConstRefOrPath::from_expr_opt(arg.expr());
|
||||||
args.push(GenericArg::Const(arg))
|
args.push(GenericArg::Const(arg))
|
||||||
}
|
}
|
||||||
ast::GenericArg::ReturnTypeArg(_) => {
|
|
||||||
// FIXME: return type notation is experimental, we don't do anything with it yet.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ fn generic_arg(p: &mut Parser<'_>) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IDENT if p.nth(1) == T!['('] && p.nth_at(2, T![..]) => return_type_arg(p),
|
|
||||||
_ if p.at_ts(types::TYPE_FIRST) => type_arg(p),
|
_ if p.at_ts(types::TYPE_FIRST) => type_arg(p),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
|
@ -140,20 +139,3 @@ fn type_arg(p: &mut Parser<'_>) {
|
||||||
types::type_(p);
|
types::type_(p);
|
||||||
m.complete(p, TYPE_ARG);
|
m.complete(p, TYPE_ARG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test return_type_arg
|
|
||||||
// type T = S<foo(..): Send>;
|
|
||||||
pub(super) fn return_type_arg(p: &mut Parser<'_>) {
|
|
||||||
let m = p.start();
|
|
||||||
p.expect(IDENT);
|
|
||||||
p.expect(T!['(']);
|
|
||||||
p.expect(T![..]);
|
|
||||||
p.expect(T![')']);
|
|
||||||
if !p.at(T![:]) {
|
|
||||||
p.error("expected :");
|
|
||||||
m.abandon(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
generic_params::bounds(p);
|
|
||||||
m.complete(p, RETURN_TYPE_ARG);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
SOURCE_FILE
|
|
||||||
TYPE_ALIAS
|
|
||||||
TYPE_KW "type"
|
|
||||||
WHITESPACE " "
|
|
||||||
NAME
|
|
||||||
IDENT "T"
|
|
||||||
WHITESPACE " "
|
|
||||||
EQ "="
|
|
||||||
WHITESPACE " "
|
|
||||||
PATH_TYPE
|
|
||||||
PATH
|
|
||||||
PATH_SEGMENT
|
|
||||||
NAME_REF
|
|
||||||
IDENT "S"
|
|
||||||
GENERIC_ARG_LIST
|
|
||||||
L_ANGLE "<"
|
|
||||||
RETURN_TYPE_ARG
|
|
||||||
IDENT "foo"
|
|
||||||
L_PAREN "("
|
|
||||||
DOT2 ".."
|
|
||||||
R_PAREN ")"
|
|
||||||
COLON ":"
|
|
||||||
WHITESPACE " "
|
|
||||||
TYPE_BOUND_LIST
|
|
||||||
TYPE_BOUND
|
|
||||||
PATH_TYPE
|
|
||||||
PATH
|
|
||||||
PATH_SEGMENT
|
|
||||||
NAME_REF
|
|
||||||
IDENT "Send"
|
|
||||||
R_ANGLE ">"
|
|
||||||
SEMICOLON ";"
|
|
||||||
WHITESPACE "\n"
|
|
|
@ -1 +0,0 @@
|
||||||
type T = S<foo(..): Send>;
|
|
|
@ -46,7 +46,6 @@ GenericArg =
|
||||||
| AssocTypeArg
|
| AssocTypeArg
|
||||||
| LifetimeArg
|
| LifetimeArg
|
||||||
| ConstArg
|
| ConstArg
|
||||||
| ReturnTypeArg
|
|
||||||
|
|
||||||
TypeArg =
|
TypeArg =
|
||||||
Type
|
Type
|
||||||
|
@ -60,9 +59,6 @@ LifetimeArg =
|
||||||
ConstArg =
|
ConstArg =
|
||||||
Expr
|
Expr
|
||||||
|
|
||||||
ReturnTypeArg =
|
|
||||||
NameRef '(' '..' ')' ':' TypeBoundList
|
|
||||||
|
|
||||||
MacroCall =
|
MacroCall =
|
||||||
Attr* Path '!' TokenTree ';'?
|
Attr* Path '!' TokenTree ';'?
|
||||||
|
|
||||||
|
|
|
@ -142,18 +142,6 @@ impl ConstArg {
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ReturnTypeArg {
|
|
||||||
pub(crate) syntax: SyntaxNode,
|
|
||||||
}
|
|
||||||
impl ast::HasTypeBounds for ReturnTypeArg {}
|
|
||||||
impl ReturnTypeArg {
|
|
||||||
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
|
|
||||||
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
|
||||||
pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
|
|
||||||
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct TypeBoundList {
|
pub struct TypeBoundList {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
@ -1528,7 +1516,6 @@ pub enum GenericArg {
|
||||||
AssocTypeArg(AssocTypeArg),
|
AssocTypeArg(AssocTypeArg),
|
||||||
LifetimeArg(LifetimeArg),
|
LifetimeArg(LifetimeArg),
|
||||||
ConstArg(ConstArg),
|
ConstArg(ConstArg),
|
||||||
ReturnTypeArg(ReturnTypeArg),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -1878,17 +1865,6 @@ impl AstNode for ConstArg {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl AstNode for ReturnTypeArg {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_TYPE_ARG }
|
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
||||||
}
|
|
||||||
impl AstNode for TypeBoundList {
|
impl AstNode for TypeBoundList {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -3243,12 +3219,9 @@ impl From<LifetimeArg> for GenericArg {
|
||||||
impl From<ConstArg> for GenericArg {
|
impl From<ConstArg> for GenericArg {
|
||||||
fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) }
|
fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) }
|
||||||
}
|
}
|
||||||
impl From<ReturnTypeArg> for GenericArg {
|
|
||||||
fn from(node: ReturnTypeArg) -> GenericArg { GenericArg::ReturnTypeArg(node) }
|
|
||||||
}
|
|
||||||
impl AstNode for GenericArg {
|
impl AstNode for GenericArg {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
matches!(kind, TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG | RETURN_TYPE_ARG)
|
matches!(kind, TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG)
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
let res = match syntax.kind() {
|
let res = match syntax.kind() {
|
||||||
|
@ -3256,7 +3229,6 @@ impl AstNode for GenericArg {
|
||||||
ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
|
ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
|
||||||
LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
|
LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
|
||||||
CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
|
CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
|
||||||
RETURN_TYPE_ARG => GenericArg::ReturnTypeArg(ReturnTypeArg { syntax }),
|
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
Some(res)
|
Some(res)
|
||||||
|
@ -3267,7 +3239,6 @@ impl AstNode for GenericArg {
|
||||||
GenericArg::AssocTypeArg(it) => &it.syntax,
|
GenericArg::AssocTypeArg(it) => &it.syntax,
|
||||||
GenericArg::LifetimeArg(it) => &it.syntax,
|
GenericArg::LifetimeArg(it) => &it.syntax,
|
||||||
GenericArg::ConstArg(it) => &it.syntax,
|
GenericArg::ConstArg(it) => &it.syntax,
|
||||||
GenericArg::ReturnTypeArg(it) => &it.syntax,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4199,13 +4170,7 @@ impl AstNode for AnyHasTypeBounds {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
kind,
|
kind,
|
||||||
ASSOC_TYPE_ARG
|
ASSOC_TYPE_ARG | TRAIT | TYPE_ALIAS | LIFETIME_PARAM | TYPE_PARAM | WHERE_PRED
|
||||||
| RETURN_TYPE_ARG
|
|
||||||
| TRAIT
|
|
||||||
| TYPE_ALIAS
|
|
||||||
| LIFETIME_PARAM
|
|
||||||
| TYPE_PARAM
|
|
||||||
| WHERE_PRED
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -4368,11 +4333,6 @@ impl std::fmt::Display for ConstArg {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for ReturnTypeArg {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for TypeBoundList {
|
impl std::fmt::Display for TypeBoundList {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
|
Loading…
Reference in a new issue