@@ -56,36 +56,11 @@ crate fn annotate_err_with_kind(
56
56
} ;
57
57
}
58
58
59
- /// Instead of e.g. `vec![a, b, c]` in a pattern context, suggest `[a, b, c]`.
60
- fn suggest_slice_pat ( e : & mut DiagnosticBuilder < ' _ > , site_span : Span , parser : & Parser < ' _ > ) {
61
- let mut suggestion = None ;
62
- if let Ok ( code) = parser. sess . source_map ( ) . span_to_snippet ( site_span) {
63
- if let Some ( bang) = code. find ( '!' ) {
64
- suggestion = Some ( code[ bang + 1 ..] . to_string ( ) ) ;
65
- }
66
- }
67
- if let Some ( suggestion) = suggestion {
68
- e. span_suggestion (
69
- site_span,
70
- "use a slice pattern here instead" ,
71
- suggestion,
72
- Applicability :: MachineApplicable ,
73
- ) ;
74
- } else {
75
- e. span_label ( site_span, "use a slice pattern here instead" ) ;
76
- }
77
- e. help (
78
- "for more information, see https://doc.rust-lang.org/edition-guide/\
79
- rust-2018/slice-patterns.html",
80
- ) ;
81
- }
82
-
83
59
fn emit_frag_parse_err (
84
60
mut e : DiagnosticBuilder < ' _ > ,
85
61
parser : & Parser < ' _ > ,
86
62
orig_parser : & mut Parser < ' _ > ,
87
63
site_span : Span ,
88
- macro_ident : Ident ,
89
64
arm_span : Span ,
90
65
kind : AstFragmentKind ,
91
66
) {
@@ -113,9 +88,6 @@ fn emit_frag_parse_err(
113
88
e. span_label ( site_span, "in this macro invocation" ) ;
114
89
}
115
90
match kind {
116
- AstFragmentKind :: Pat if macro_ident. name == sym:: vec => {
117
- suggest_slice_pat ( & mut e, site_span, parser) ;
118
- }
119
91
// Try a statement if an expression is wanted but failed and suggest adding `;` to call.
120
92
AstFragmentKind :: Expr => match parse_ast_fragment ( orig_parser, AstFragmentKind :: Stmts ) {
121
93
Err ( mut err) => err. cancel ( ) ,
@@ -143,7 +115,7 @@ impl<'a> ParserAnyMacro<'a> {
143
115
let fragment = match parse_ast_fragment ( parser, kind) {
144
116
Ok ( f) => f,
145
117
Err ( err) => {
146
- emit_frag_parse_err ( err, parser, snapshot, site_span, macro_ident , arm_span, kind) ;
118
+ emit_frag_parse_err ( err, parser, snapshot, site_span, arm_span, kind) ;
147
119
return kind. dummy ( site_span) ;
148
120
}
149
121
} ;
0 commit comments