Add (..)
syntax for RTN
This commit is contained in:
parent
104aacb49f
commit
8b592db27a
44 changed files with 355 additions and 201 deletions
|
@ -55,7 +55,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
let trait_def = self.tcx().trait_def(trait_def_id);
|
||||
if !trait_def.paren_sugar {
|
||||
if trait_segment.args().parenthesized {
|
||||
if trait_segment.args().parenthesized == hir::GenericArgsParentheses::ParenSugar {
|
||||
// For now, require that parenthetical notation be used only with `Fn()` etc.
|
||||
let mut err = feature_err(
|
||||
&self.tcx().sess.parse_sess,
|
||||
|
@ -71,7 +71,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
let sess = self.tcx().sess;
|
||||
|
||||
if !trait_segment.args().parenthesized {
|
||||
if trait_segment.args().parenthesized != hir::GenericArgsParentheses::ParenSugar {
|
||||
// For now, require that parenthetical notation be used only with `Fn()` etc.
|
||||
let mut err = feature_err(
|
||||
&sess.parse_sess,
|
||||
|
@ -607,11 +607,19 @@ pub fn prohibit_assoc_ty_binding(
|
|||
span: Span,
|
||||
segment: Option<(&hir::PathSegment<'_>, Span)>,
|
||||
) {
|
||||
tcx.sess.emit_err(AssocTypeBindingNotAllowed { span, fn_trait_expansion: if let Some((segment, span)) = segment && segment.args().parenthesized {
|
||||
Some(ParenthesizedFnTraitExpansion { span, expanded_type: fn_trait_to_string(tcx, segment, false) })
|
||||
} else {
|
||||
None
|
||||
}});
|
||||
tcx.sess.emit_err(AssocTypeBindingNotAllowed {
|
||||
span,
|
||||
fn_trait_expansion: if let Some((segment, span)) = segment
|
||||
&& segment.args().parenthesized == hir::GenericArgsParentheses::ParenSugar
|
||||
{
|
||||
Some(ParenthesizedFnTraitExpansion {
|
||||
span,
|
||||
expanded_type: fn_trait_to_string(tcx, segment, false),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn fn_trait_to_string(
|
||||
|
|
|
@ -1087,7 +1087,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let tcx = self.tcx();
|
||||
|
||||
let return_type_notation =
|
||||
binding.gen_args.parenthesized && tcx.features().return_type_notation;
|
||||
binding.gen_args.parenthesized == hir::GenericArgsParentheses::ReturnTypeNotation;
|
||||
|
||||
let candidate = if return_type_notation {
|
||||
if self.trait_defines_associated_item_named(
|
||||
|
|
|
@ -1461,7 +1461,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
depth: usize,
|
||||
generic_args: &'tcx hir::GenericArgs<'tcx>,
|
||||
) {
|
||||
if generic_args.parenthesized {
|
||||
if generic_args.parenthesized == hir::GenericArgsParentheses::ParenSugar {
|
||||
self.visit_fn_like_elision(
|
||||
generic_args.inputs(),
|
||||
Some(generic_args.bindings[0].ty()),
|
||||
|
@ -1653,7 +1653,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
// `for<'a> T::Trait<'a, x(): for<'b> Other<'b>>`
|
||||
// this is going to expand to something like:
|
||||
// `for<'a> for<'r, T> <T as Trait<'a>>::x::<'r, T>::{opaque#0}: for<'b> Other<'b>`.
|
||||
if binding.gen_args.parenthesized {
|
||||
if binding.gen_args.parenthesized == hir::GenericArgsParentheses::ReturnTypeNotation {
|
||||
let bound_vars = if let Some(type_def_id) = type_def_id
|
||||
&& self.tcx.def_kind(type_def_id) == DefKind::Trait
|
||||
// FIXME(return_type_notation): We could bound supertrait methods.
|
||||
|
|
|
@ -565,7 +565,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
/// type Map = HashMap<String>;
|
||||
/// ```
|
||||
fn suggest_adding_args(&self, err: &mut Diagnostic) {
|
||||
if self.gen_args.parenthesized {
|
||||
if self.gen_args.parenthesized != hir::GenericArgsParentheses::No {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -962,7 +962,11 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
|
||||
let msg = format!(
|
||||
"remove these {}generics",
|
||||
if self.gen_args.parenthesized { "parenthetical " } else { "" },
|
||||
if self.gen_args.parenthesized == hir::GenericArgsParentheses::ParenSugar {
|
||||
"parenthetical "
|
||||
} else {
|
||||
""
|
||||
},
|
||||
);
|
||||
|
||||
err.span_suggestion(span, &msg, "", Applicability::MaybeIncorrect);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue