@@ -143,8 +143,15 @@ impl<'a> Parser<'a> {
143143 let lo = self . token . span ;
144144 let vis = self . parse_visibility ( FollowedByType :: No ) ?;
145145 let mut def = self . parse_defaultness ( ) ;
146- let kind =
147- self . parse_item_kind ( & mut attrs, mac_allowed, lo, & vis, & mut def, fn_parse_mode) ?;
146+ let kind = self . parse_item_kind (
147+ & mut attrs,
148+ mac_allowed,
149+ lo,
150+ & vis,
151+ & mut def,
152+ fn_parse_mode,
153+ false ,
154+ ) ?;
148155 if let Some ( ( ident, kind) ) = kind {
149156 self . error_on_unconsumed_default ( def, & kind) ;
150157 let span = lo. to ( self . prev_token . span ) ;
@@ -205,11 +212,12 @@ impl<'a> Parser<'a> {
205212 vis : & Visibility ,
206213 def : & mut Defaultness ,
207214 fn_parse_mode : FnParseMode ,
215+ kw_case_insensitive : bool ,
208216 ) -> PResult < ' a , Option < ItemInfo > > {
209217 let def_final = def == & Defaultness :: Final ;
210218 let mut def = || mem:: replace ( def, Defaultness :: Final ) ;
211219
212- let info = if self . eat_keyword ( kw:: Use ) {
220+ let info = if self . eat_keyword_case ( kw:: Use , kw_case_insensitive ) {
213221 self . parse_use_item ( ) ?
214222 } else if self . check_fn_front_matter ( def_final) {
215223 // FUNCTION ITEM
@@ -286,6 +294,17 @@ impl<'a> Parser<'a> {
286294 } else if self . isnt_macro_invocation ( ) && vis. kind . is_pub ( ) {
287295 self . recover_missing_kw_before_item ( ) ?;
288296 return Ok ( None ) ;
297+ } else if self . isnt_macro_invocation ( ) && !kw_case_insensitive {
298+ // Recover wrong cased keywords
299+ return self . parse_item_kind (
300+ attrs,
301+ macros_allowed,
302+ lo,
303+ vis,
304+ & mut def ( ) ,
305+ fn_parse_mode,
306+ true ,
307+ ) ;
289308 } else if macros_allowed && self . check_path ( ) {
290309 // MACRO INVOCATION ITEM
291310 ( Ident :: empty ( ) , ItemKind :: MacCall ( P ( self . parse_item_macro ( vis) ?) ) )
0 commit comments