diff options
| author | bors <bors@rust-lang.org> | 2022-08-25 02:32:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-25 02:32:11 +0000 |
| commit | 9b9bc6359973482891699bbc5eecedaf34a60503 (patch) | |
| tree | 9e3e576cf00fad6255b93a7ff98f2b296ffaeb0d /compiler/rustc_parse/src/parser | |
| parent | 5462da52ba9edc77c2a7e4fc77aaf3b977d41ad1 (diff) | |
| parent | f2878a656b944ceed6f4a98d7e255784266a3dc0 (diff) | |
| download | rust-9b9bc6359973482891699bbc5eecedaf34a60503.tar.gz rust-9b9bc6359973482891699bbc5eecedaf34a60503.zip | |
Auto merge of #100977 - JohnTitor:rollup-8hc7rxh, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #99332 (Stabilize `#![feature(label_break_value)]`) - #99954 (let-else: break out to one scope higher for let-else) - #100188 (Parser will not suggest invalid expression when use public) - #100780 (save_analysis: Migrate diagnostic) - #100808 (Migrate `rustc_interface` diagnostics ) - #100921 (Add a warning about `Option/Result::and()` being eagerly evaluated) - #100960 (rustdoc: ayu code color selector more specific) - #100964 (Sync rustc_codegen_cranelift) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 24 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index b8884dd32d6..f2d79ce756c 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -22,7 +22,7 @@ use rustc_errors::{ use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed}; use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; use rustc_span::source_map::Spanned; -use rustc_span::symbol::{kw, Ident}; +use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::{Span, SpanSnippetError, DUMMY_SP}; use std::ops::{Deref, DerefMut}; @@ -977,15 +977,6 @@ impl<'a> Parser<'a> { let mut err = self.struct_span_err(self.token.span, &msg_exp); if let TokenKind::Ident(symbol, _) = &self.prev_token.kind { - if symbol.as_str() == "public" { - err.span_suggestion_short( - self.prev_token.span, - "write `pub` instead of `public` to make the item public", - "pub", - appl, - ); - } - if ["def", "fun", "func", "function"].contains(&symbol.as_str()) { err.span_suggestion_short( self.prev_token.span, @@ -996,6 +987,19 @@ impl<'a> Parser<'a> { } } + // `pub` may be used for an item or `pub(crate)` + if self.prev_token.is_ident_named(sym::public) + && (self.token.can_begin_item() + || self.token.kind == TokenKind::OpenDelim(Delimiter::Parenthesis)) + { + err.span_suggestion_short( + self.prev_token.span, + "write `pub` instead of `public` to make the item public", + "pub", + appl, + ); + } + // Add suggestion for a missing closing angle bracket if '>' is included in expected_tokens // there are unclosed angle brackets if self.unmatched_angle_bracket_count > 0 diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 17117cbc8fb..18aa109d7a6 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2014,10 +2014,6 @@ impl<'a> Parser<'a> { } } - if let Some(label) = opt_label { - self.sess.gated_spans.gate(sym::label_break_value, label.ident.span); - } - if self.token.is_whole_block() { self.sess.emit_err(InvalidBlockMacroSegment { span: self.token.span, |
