+/// Create a suggestion made from several `span → replacement`.
+///
+/// Note: in the JSON format (used by `compiletest_rs`), the help message will appear once per
+/// replacement. In human-readable format though, it only appears once before the whole suggestion.
+pub fn multispan_sugg(db: &mut DiagnosticBuilder, help_msg: String, sugg: &[(Span, &str)]) {
+ let sugg = rustc_errors::RenderSpan::Suggestion(rustc_errors::CodeSuggestion {
+ msp: MultiSpan::from_spans(sugg.iter().map(|&(span, _)| span).collect()),
+ substitutes: sugg.iter().map(|&(_, subs)| subs.to_owned()).collect(),
+ });
+
+ let sub = rustc_errors::SubDiagnostic {
+ level: rustc_errors::Level::Help,
+ message: help_msg,
+ span: MultiSpan::new(),
+ render_span: Some(sugg),
+ };
+ db.children.push(sub);
+}
+