Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 78a891d

Browse files
committedSep 6, 2022
Auto merge of #101485 - GuillaumeGomez:rollup-68p9di4, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #101357 (Include enum path in variant suggestion) - #101434 (Update `SessionDiagnostic::into_diagnostic` to take `Handler` instead of `ParseSess`) - #101445 (Suggest introducing an explicit lifetime if it does not exist) - #101457 (Recover from using `;` as separator between fields) - #101462 (Rustdoc-Json: Store Variant Fields as their own item.) - #101471 (Report number of delayed bugs properly with `-Ztreat-err-as-bug`) - #101473 (Add more size assertions for MIR types.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 380addd + f21b612 commit 78a891d

File tree

89 files changed

+707
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+707
-384
lines changed
 

‎compiler/rustc_attr/src/builtin.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
6363
sess.emit_err(session_diagnostics::MultipleStabilityLevels { span });
6464
}
6565
AttrError::UnsupportedLiteral(reason, is_bytestr) => {
66-
sess.emit_err(session_diagnostics::UnsupportedLiteral { span, reason, is_bytestr });
66+
sess.emit_err(session_diagnostics::UnsupportedLiteral {
67+
span,
68+
reason,
69+
is_bytestr,
70+
start_point_span: sess.source_map().start_point(span),
71+
});
6772
}
6873
}
6974
}

‎compiler/rustc_attr/src/session_diagnostics.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use std::num::IntErrorKind;
22

33
use rustc_ast as ast;
4-
use rustc_errors::{error_code, fluent, Applicability, DiagnosticBuilder, ErrorGuaranteed};
4+
use rustc_errors::{
5+
error_code, fluent, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler,
6+
};
57
use rustc_macros::SessionDiagnostic;
6-
use rustc_session::{parse::ParseSess, SessionDiagnostic};
8+
use rustc_session::SessionDiagnostic;
79
use rustc_span::{Span, Symbol};
810

911
use crate::UnsupportedLiteralReason;
@@ -49,9 +51,9 @@ pub(crate) struct UnknownMetaItem<'a> {
4951

5052
// Manual implementation to be able to format `expected` items correctly.
5153
impl<'a> SessionDiagnostic<'a> for UnknownMetaItem<'_> {
52-
fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
54+
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
5355
let expected = self.expected.iter().map(|name| format!("`{}`", name)).collect::<Vec<_>>();
54-
let mut diag = sess.span_diagnostic.struct_span_err_with_code(
56+
let mut diag = handler.struct_span_err_with_code(
5557
self.span,
5658
fluent::attr::unknown_meta_item,
5759
error_code!(E0541),
@@ -204,11 +206,12 @@ pub(crate) struct UnsupportedLiteral {
204206
pub span: Span,
205207
pub reason: UnsupportedLiteralReason,
206208
pub is_bytestr: bool,
209+
pub start_point_span: Span,
207210
}
208211

209212
impl<'a> SessionDiagnostic<'a> for UnsupportedLiteral {
210-
fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
211-
let mut diag = sess.span_diagnostic.struct_span_err_with_code(
213+
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
214+
let mut diag = handler.struct_span_err_with_code(
212215
self.span,
213216
match self.reason {
214217
UnsupportedLiteralReason::Generic => fluent::attr::unsupported_literal_generic,
@@ -224,7 +227,7 @@ impl<'a> SessionDiagnostic<'a> for UnsupportedLiteral {
224227
);
225228
if self.is_bytestr {
226229
diag.span_suggestion(
227-
sess.source_map().start_point(self.span),
230+
self.start_point_span,
228231
fluent::attr::unsupported_literal_suggestion,
229232
"",
230233
Applicability::MaybeIncorrect,

0 commit comments

Comments
 (0)
Please sign in to comment.