From c0861d3a9d33d535542bbeb48d35271161c87ebf Mon Sep 17 00:00:00 2001 From: codehorseman Date: Wed, 16 Mar 2022 20:12:30 +0800 Subject: [PATCH 1/4] resolve the conflict in compiler/rustc_session/src/parse.rs Signed-off-by: codehorseman --- src/lists.rs | 2 +- src/types.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lists.rs b/src/lists.rs index 7aa0315f18c2..29d75585eb72 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -575,7 +575,7 @@ pub(crate) struct ListItems<'a, I, F1, F2, F3> pub(crate) fn extract_pre_comment(pre_snippet: &str) -> (Option, ListItemCommentStyle) { let trimmed_pre_snippet = pre_snippet.trim(); // Both start and end are checked to support keeping a block comment inline with - // the item, even if there are preceeding line comments, while still supporting + // the item, even if there are preceding line comments, while still supporting // a snippet that starts with a block comment but also contains one or more // trailing single line comments. // https://github.com/rust-lang/rustfmt/issues/3025 diff --git a/src/types.rs b/src/types.rs index 5de30129266a..a49d473a13f3 100644 --- a/src/types.rs +++ b/src/types.rs @@ -251,7 +251,7 @@ fn rewrite_segment( match **args { ast::GenericArgs::AngleBracketed(ref data) if !data.args.is_empty() => { // HACK: squeeze out the span between the identifier and the parameters. - // The hack is requried so that we don't remove the separator inside macro calls. + // The hack is required so that we don't remove the separator inside macro calls. // This does not work in the presence of comment, hoping that people are // sane about where to put their comment. let separator_snippet = context From c1d351f6eee7f870ce5216e824709dccbdf69dff Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 22 Jan 2022 18:49:12 -0600 Subject: [PATCH 2/4] rustc_error: make ErrorReported impossible to construct There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name. --- src/parse/macros/lazy_static.rs | 2 +- src/parse/macros/mod.rs | 2 +- src/parse/session.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parse/macros/lazy_static.rs b/src/parse/macros/lazy_static.rs index 4c541de04be0..a8c2feec453c 100644 --- a/src/parse/macros/lazy_static.rs +++ b/src/parse/macros/lazy_static.rs @@ -16,7 +16,7 @@ macro_rules! parse_or { ($method:ident $(,)* $($arg:expr),* $(,)*) => { match parser.$method($($arg,)*) { Ok(val) => { - if parser.sess.span_diagnostic.has_errors() { + if parser.sess.span_diagnostic.has_errors().is_some() { parser.sess.span_diagnostic.reset_err_count(); return None; } else { diff --git a/src/parse/macros/mod.rs b/src/parse/macros/mod.rs index fd738908170f..3728f3a19b44 100644 --- a/src/parse/macros/mod.rs +++ b/src/parse/macros/mod.rs @@ -28,7 +28,7 @@ macro_rules! parse_macro_arg { let mut cloned_parser = (*parser).clone(); match $parser(&mut cloned_parser) { Ok(x) => { - if parser.sess.span_diagnostic.has_errors() { + if parser.sess.span_diagnostic.has_errors().is_some() { parser.sess.span_diagnostic.reset_err_count(); } else { // Parsing succeeded. diff --git a/src/parse/session.rs b/src/parse/session.rs index 40a6d708d8cc..a34ceed3fc91 100644 --- a/src/parse/session.rs +++ b/src/parse/session.rs @@ -235,7 +235,7 @@ pub(super) fn can_reset_errors(&self) -> bool { } pub(super) fn has_errors(&self) -> bool { - self.parse_sess.span_diagnostic.has_errors() + self.parse_sess.span_diagnostic.has_errors().is_some() } pub(super) fn reset_errors(&self) { From 4f89c51a5b3f27f38a7701d5243a80d7c1c44dff Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 20 Mar 2022 18:26:09 +0100 Subject: [PATCH 3/4] Take &mut Diagnostic in emit_diagnostic. Taking a Diagnostic by move would break the usual pattern `diag.label(..).emit()`. --- src/parse/session.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/parse/session.rs b/src/parse/session.rs index a34ceed3fc91..412f4434b9ea 100644 --- a/src/parse/session.rs +++ b/src/parse/session.rs @@ -225,8 +225,10 @@ pub(crate) fn get_original_snippet(&self, file_name: &FileName) -> Option) { - for diagnostic in diagnostics { - self.parse_sess.span_diagnostic.emit_diagnostic(&diagnostic); + for mut diagnostic in diagnostics { + self.parse_sess + .span_diagnostic + .emit_diagnostic(&mut diagnostic); } } From c2039d95c6fd5c27a90e768e79c630af374fcaf0 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sun, 27 Mar 2022 20:46:25 -0500 Subject: [PATCH 4/4] chore: bump toolchain --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 0d407f11994b..94b57d506c20 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2022-03-17" +channel = "nightly-2022-03-27" components = ["rustc-dev"]