about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-28 10:11:26 +0000
committerbors <bors@rust-lang.org>2018-05-28 10:11:26 +0000
commit16cd84ee22aeaa97c27eb608d117696dc7346425 (patch)
treec3df699bf6e0eaa501aed5df1bca0fa3b937b77c /src/librustc_errors
parent68e0e58df7669d548861751e9f710f85dfc39958 (diff)
parent98a04291e4db92ae86d7e3a20b5763cb926ebfbf (diff)
downloadrust-16cd84ee22aeaa97c27eb608d117696dc7346425.tar.gz
rust-16cd84ee22aeaa97c27eb608d117696dc7346425.zip
Auto merge of #50724 - zackmdavis:applicability_rush, r=Manishearth
add suggestion applicabilities to librustc and libsyntax

A down payment on #50723. Interested in feedback on whether my `MaybeIncorrect` vs. `MachineApplicable` judgement calls are well-calibrated (and that we have a consensus on what this means).

r? @Manishearth
cc @killercup @estebank
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/diagnostic.rs17
-rw-r--r--src/librustc_errors/diagnostic_builder.rs6
2 files changed, 23 insertions, 0 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index 81b32f436c8..de73295b499 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -330,6 +330,23 @@ impl Diagnostic {
         self
     }
 
+    pub fn span_suggestion_short_with_applicability(
+        &mut self, sp: Span, msg: &str, suggestion: String, applicability: Applicability
+    ) -> &mut Self {
+        self.suggestions.push(CodeSuggestion {
+            substitutions: vec![Substitution {
+                parts: vec![SubstitutionPart {
+                    snippet: suggestion,
+                    span: sp,
+                }],
+            }],
+            msg: msg.to_owned(),
+            show_code_when_inline: false,
+            applicability: applicability,
+        });
+        self
+    }
+
     pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self {
         self.span = sp.into();
         self
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs
index b813edadc57..562c28f0840 100644
--- a/src/librustc_errors/diagnostic_builder.rs
+++ b/src/librustc_errors/diagnostic_builder.rs
@@ -205,6 +205,12 @@ impl<'a> DiagnosticBuilder<'a> {
                                                  suggestions: Vec<String>,
                                                  applicability: Applicability)
                                                  -> &mut Self);
+    forward!(pub fn span_suggestion_short_with_applicability(&mut self,
+                                                             sp: Span,
+                                                             msg: &str,
+                                                             suggestion: String,
+                                                             applicability: Applicability)
+                                                             -> &mut Self);
     forward!(pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self);
     forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);