Auto merge of #119751 - nnethercote:error-api-fixes, r=oli-obk
Diagnostic API fixes Some improvements to diagnostic APIs: improve some naming, use shortcuts in more places, and add a couple of missing methods. r? `@compiler-errors`
This commit is contained in:
commit
a2d9d73e60
135 changed files with 766 additions and 756 deletions
|
@ -23,7 +23,7 @@ macro_rules! gate {
|
||||||
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
|
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
|
||||||
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
||||||
feature_err(&$visitor.sess.parse_sess, sym::$feature, $span, $explain)
|
feature_err(&$visitor.sess.parse_sess, sym::$feature, $span, $explain)
|
||||||
.help_mv($help)
|
.with_help($help)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
|
|
|
@ -38,21 +38,21 @@ struct ShowSpanVisitor<'a> {
|
||||||
impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
|
impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
|
||||||
fn visit_expr(&mut self, e: &'a ast::Expr) {
|
fn visit_expr(&mut self, e: &'a ast::Expr) {
|
||||||
if let Mode::Expression = self.mode {
|
if let Mode::Expression = self.mode {
|
||||||
self.dcx.emit_warning(errors::ShowSpan { span: e.span, msg: "expression" });
|
self.dcx.emit_warn(errors::ShowSpan { span: e.span, msg: "expression" });
|
||||||
}
|
}
|
||||||
visit::walk_expr(self, e);
|
visit::walk_expr(self, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_pat(&mut self, p: &'a ast::Pat) {
|
fn visit_pat(&mut self, p: &'a ast::Pat) {
|
||||||
if let Mode::Pattern = self.mode {
|
if let Mode::Pattern = self.mode {
|
||||||
self.dcx.emit_warning(errors::ShowSpan { span: p.span, msg: "pattern" });
|
self.dcx.emit_warn(errors::ShowSpan { span: p.span, msg: "pattern" });
|
||||||
}
|
}
|
||||||
visit::walk_pat(self, p);
|
visit::walk_pat(self, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: &'a ast::Ty) {
|
fn visit_ty(&mut self, t: &'a ast::Ty) {
|
||||||
if let Mode::Type = self.mode {
|
if let Mode::Type = self.mode {
|
||||||
self.dcx.emit_warning(errors::ShowSpan { span: t.span, msg: "type" });
|
self.dcx.emit_warn(errors::ShowSpan { span: t.span, msg: "type" });
|
||||||
}
|
}
|
||||||
visit::walk_ty(self, t);
|
visit::walk_ty(self, t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -621,7 +621,7 @@ pub fn eval_condition(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let Some(min_version) = parse_version(*min_version) else {
|
let Some(min_version) = parse_version(*min_version) else {
|
||||||
dcx.emit_warning(session_diagnostics::UnknownVersionLiteral { span: *span });
|
dcx.emit_warn(session_diagnostics::UnknownVersionLiteral { span: *span });
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,11 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnknownMetaItem<'_> {
|
||||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
||||||
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::attr_unknown_meta_item)
|
DiagnosticBuilder::new(dcx, level, fluent::attr_unknown_meta_item)
|
||||||
.span_mv(self.span)
|
.with_span(self.span)
|
||||||
.code_mv(error_code!(E0541))
|
.with_code(error_code!(E0541))
|
||||||
.arg_mv("item", self.item)
|
.with_arg("item", self.item)
|
||||||
.arg_mv("expected", expected.join(", "))
|
.with_arg("expected", expected.join(", "))
|
||||||
.span_label_mv(self.span, fluent::attr_label)
|
.with_span_label(self.span, fluent::attr_label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use rustc_errors::{struct_span_err, DiagCtxt, DiagnosticBuilder};
|
use rustc_errors::{struct_span_code_err, DiagCtxt, DiagnosticBuilder};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
@ -31,15 +31,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
borrow_span: Span,
|
borrow_span: Span,
|
||||||
borrow_desc: &str,
|
borrow_desc: &str,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0503,
|
E0503,
|
||||||
"cannot use {} because it was mutably borrowed",
|
"cannot use {} because it was mutably borrowed",
|
||||||
desc,
|
desc,
|
||||||
)
|
)
|
||||||
.span_label_mv(borrow_span, format!("{borrow_desc} is borrowed here"))
|
.with_span_label(borrow_span, format!("{borrow_desc} is borrowed here"))
|
||||||
.span_label_mv(span, format!("use of borrowed {borrow_desc}"))
|
.with_span_label(span, format!("use of borrowed {borrow_desc}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_mutably_borrow_multiply(
|
pub(crate) fn cannot_mutably_borrow_multiply(
|
||||||
|
@ -52,7 +52,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
old_load_end_span: Option<Span>,
|
old_load_end_span: Option<Span>,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
|
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
new_loan_span,
|
new_loan_span,
|
||||||
E0499,
|
E0499,
|
||||||
|
@ -98,7 +98,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
old_loan_span: Span,
|
old_loan_span: Span,
|
||||||
old_load_end_span: Option<Span>,
|
old_load_end_span: Option<Span>,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
new_loan_span,
|
new_loan_span,
|
||||||
E0524,
|
E0524,
|
||||||
|
@ -131,7 +131,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
old_opt_via: &str,
|
old_opt_via: &str,
|
||||||
previous_end_span: Option<Span>,
|
previous_end_span: Option<Span>,
|
||||||
) -> DiagnosticBuilder<'cx> {
|
) -> DiagnosticBuilder<'cx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
new_loan_span,
|
new_loan_span,
|
||||||
E0500,
|
E0500,
|
||||||
|
@ -163,7 +163,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
previous_end_span: Option<Span>,
|
previous_end_span: Option<Span>,
|
||||||
second_borrow_desc: &str,
|
second_borrow_desc: &str,
|
||||||
) -> DiagnosticBuilder<'cx> {
|
) -> DiagnosticBuilder<'cx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
new_loan_span,
|
new_loan_span,
|
||||||
E0501,
|
E0501,
|
||||||
|
@ -196,7 +196,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
old_load_end_span: Option<Span>,
|
old_load_end_span: Option<Span>,
|
||||||
) -> DiagnosticBuilder<'cx> {
|
) -> DiagnosticBuilder<'cx> {
|
||||||
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
|
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0502,
|
E0502,
|
||||||
|
@ -236,15 +236,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
borrow_span: Span,
|
borrow_span: Span,
|
||||||
desc: &str,
|
desc: &str,
|
||||||
) -> DiagnosticBuilder<'cx> {
|
) -> DiagnosticBuilder<'cx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0506,
|
E0506,
|
||||||
"cannot assign to {} because it is borrowed",
|
"cannot assign to {} because it is borrowed",
|
||||||
desc,
|
desc,
|
||||||
)
|
)
|
||||||
.span_label_mv(borrow_span, format!("{desc} is borrowed here"))
|
.with_span_label(borrow_span, format!("{desc} is borrowed here"))
|
||||||
.span_label_mv(span, format!("{desc} is assigned to here but it was already borrowed"))
|
.with_span_label(span, format!("{desc} is assigned to here but it was already borrowed"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_reassign_immutable(
|
pub(crate) fn cannot_reassign_immutable(
|
||||||
|
@ -254,11 +254,11 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
is_arg: bool,
|
is_arg: bool,
|
||||||
) -> DiagnosticBuilder<'cx> {
|
) -> DiagnosticBuilder<'cx> {
|
||||||
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
|
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
|
||||||
struct_span_err!(self.dcx(), span, E0384, "cannot assign {} {}", msg, desc)
|
struct_span_code_err!(self.dcx(), span, E0384, "cannot assign {} {}", msg, desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'tcx> {
|
pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(self.dcx(), span, E0594, "cannot assign to {}", desc)
|
struct_span_code_err!(self.dcx(), span, E0594, "cannot assign to {}", desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_move_out_of(
|
pub(crate) fn cannot_move_out_of(
|
||||||
|
@ -266,7 +266,13 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
move_from_span: Span,
|
move_from_span: Span,
|
||||||
move_from_desc: &str,
|
move_from_desc: &str,
|
||||||
) -> DiagnosticBuilder<'cx> {
|
) -> DiagnosticBuilder<'cx> {
|
||||||
struct_span_err!(self.dcx(), move_from_span, E0507, "cannot move out of {}", move_from_desc)
|
struct_span_code_err!(
|
||||||
|
self.dcx(),
|
||||||
|
move_from_span,
|
||||||
|
E0507,
|
||||||
|
"cannot move out of {}",
|
||||||
|
move_from_desc
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Signal an error due to an attempt to move out of the interior
|
/// Signal an error due to an attempt to move out of the interior
|
||||||
|
@ -283,7 +289,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
(&ty::Slice(_), _) => "slice",
|
(&ty::Slice(_), _) => "slice",
|
||||||
_ => span_bug!(move_from_span, "this path should not cause illegal move"),
|
_ => span_bug!(move_from_span, "this path should not cause illegal move"),
|
||||||
};
|
};
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
move_from_span,
|
move_from_span,
|
||||||
E0508,
|
E0508,
|
||||||
|
@ -291,7 +297,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
ty,
|
ty,
|
||||||
type_name,
|
type_name,
|
||||||
)
|
)
|
||||||
.span_label_mv(move_from_span, "cannot move out of here")
|
.with_span_label(move_from_span, "cannot move out of here")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_move_out_of_interior_of_drop(
|
pub(crate) fn cannot_move_out_of_interior_of_drop(
|
||||||
|
@ -299,14 +305,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
move_from_span: Span,
|
move_from_span: Span,
|
||||||
container_ty: Ty<'_>,
|
container_ty: Ty<'_>,
|
||||||
) -> DiagnosticBuilder<'cx> {
|
) -> DiagnosticBuilder<'cx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
move_from_span,
|
move_from_span,
|
||||||
E0509,
|
E0509,
|
||||||
"cannot move out of type `{}`, which implements the `Drop` trait",
|
"cannot move out of type `{}`, which implements the `Drop` trait",
|
||||||
container_ty,
|
container_ty,
|
||||||
)
|
)
|
||||||
.span_label_mv(move_from_span, "cannot move out of here")
|
.with_span_label(move_from_span, "cannot move out of here")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_act_on_moved_value(
|
pub(crate) fn cannot_act_on_moved_value(
|
||||||
|
@ -318,7 +324,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let moved_path = moved_path.map(|mp| format!(": `{mp}`")).unwrap_or_default();
|
let moved_path = moved_path.map(|mp| format!(": `{mp}`")).unwrap_or_default();
|
||||||
|
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
use_span,
|
use_span,
|
||||||
E0382,
|
E0382,
|
||||||
|
@ -335,7 +341,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
path: &str,
|
path: &str,
|
||||||
reason: &str,
|
reason: &str,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(self.dcx(), span, E0596, "cannot borrow {} as mutable{}", path, reason)
|
struct_span_code_err!(
|
||||||
|
self.dcx(),
|
||||||
|
span,
|
||||||
|
E0596,
|
||||||
|
"cannot borrow {} as mutable{}",
|
||||||
|
path,
|
||||||
|
reason
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_mutate_in_immutable_section(
|
pub(crate) fn cannot_mutate_in_immutable_section(
|
||||||
|
@ -346,7 +359,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
immutable_section: &str,
|
immutable_section: &str,
|
||||||
action: &str,
|
action: &str,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
mutate_span,
|
mutate_span,
|
||||||
E0510,
|
E0510,
|
||||||
|
@ -355,8 +368,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
immutable_place,
|
immutable_place,
|
||||||
immutable_section,
|
immutable_section,
|
||||||
)
|
)
|
||||||
.span_label_mv(mutate_span, format!("cannot {action}"))
|
.with_span_label(mutate_span, format!("cannot {action}"))
|
||||||
.span_label_mv(immutable_span, format!("value is immutable in {immutable_section}"))
|
.with_span_label(immutable_span, format!("value is immutable in {immutable_section}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_borrow_across_coroutine_yield(
|
pub(crate) fn cannot_borrow_across_coroutine_yield(
|
||||||
|
@ -365,20 +378,20 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
yield_span: Span,
|
yield_span: Span,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let coroutine_kind = self.body.coroutine.as_ref().unwrap().coroutine_kind;
|
let coroutine_kind = self.body.coroutine.as_ref().unwrap().coroutine_kind;
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0626,
|
E0626,
|
||||||
"borrow may still be in use when {coroutine_kind:#} yields",
|
"borrow may still be in use when {coroutine_kind:#} yields",
|
||||||
)
|
)
|
||||||
.span_label_mv(yield_span, "possible yield occurs here")
|
.with_span_label(yield_span, "possible yield occurs here")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_borrow_across_destructor(
|
pub(crate) fn cannot_borrow_across_destructor(
|
||||||
&self,
|
&self,
|
||||||
borrow_span: Span,
|
borrow_span: Span,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
borrow_span,
|
borrow_span,
|
||||||
E0713,
|
E0713,
|
||||||
|
@ -391,7 +404,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
span: Span,
|
span: Span,
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(self.dcx(), span, E0597, "{} does not live long enough", path,)
|
struct_span_code_err!(self.dcx(), span, E0597, "{} does not live long enough", path,)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_return_reference_to_local(
|
pub(crate) fn cannot_return_reference_to_local(
|
||||||
|
@ -401,7 +414,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
reference_desc: &str,
|
reference_desc: &str,
|
||||||
path_desc: &str,
|
path_desc: &str,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0515,
|
E0515,
|
||||||
|
@ -410,7 +423,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
REFERENCE = reference_desc,
|
REFERENCE = reference_desc,
|
||||||
LOCAL = path_desc,
|
LOCAL = path_desc,
|
||||||
)
|
)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!("{return_kind}s a {reference_desc} data owned by the current function"),
|
format!("{return_kind}s a {reference_desc} data owned by the current function"),
|
||||||
)
|
)
|
||||||
|
@ -424,22 +437,22 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
capture_span: Span,
|
capture_span: Span,
|
||||||
scope: &str,
|
scope: &str,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
closure_span,
|
closure_span,
|
||||||
E0373,
|
E0373,
|
||||||
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
|
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
|
||||||
which is owned by the current {scope}",
|
which is owned by the current {scope}",
|
||||||
)
|
)
|
||||||
.span_label_mv(capture_span, format!("{borrowed_path} is borrowed here"))
|
.with_span_label(capture_span, format!("{borrowed_path} is borrowed here"))
|
||||||
.span_label_mv(closure_span, format!("may outlive borrowed value {borrowed_path}"))
|
.with_span_label(closure_span, format!("may outlive borrowed value {borrowed_path}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn thread_local_value_does_not_live_long_enough(
|
pub(crate) fn thread_local_value_does_not_live_long_enough(
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0712,
|
E0712,
|
||||||
|
@ -451,7 +464,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed",)
|
struct_span_code_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed",)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +473,7 @@ pub(crate) fn borrowed_data_escapes_closure<'tcx>(
|
||||||
escape_span: Span,
|
escape_span: Span,
|
||||||
escapes_from: &str,
|
escapes_from: &str,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
escape_span,
|
escape_span,
|
||||||
E0521,
|
E0521,
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
// ignore-tidy-filelength
|
||||||
|
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan};
|
use rustc_errors::{struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
|
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
|
||||||
|
@ -550,8 +552,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let used = desired_action.as_general_verb_in_past_tense();
|
let used = desired_action.as_general_verb_in_past_tense();
|
||||||
let mut err =
|
let mut err = struct_span_code_err!(
|
||||||
struct_span_err!(self.dcx(), span, E0381, "{used} binding {desc}{isnt_initialized}");
|
self.dcx(),
|
||||||
|
span,
|
||||||
|
E0381,
|
||||||
|
"{used} binding {desc}{isnt_initialized}"
|
||||||
|
);
|
||||||
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
||||||
|
|
||||||
if let InitializationRequiringAction::PartialAssignment
|
if let InitializationRequiringAction::PartialAssignment
|
||||||
|
@ -2219,11 +2225,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.thread_local_value_does_not_live_long_enough(borrow_span)
|
self.thread_local_value_does_not_live_long_enough(borrow_span)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
borrow_span,
|
borrow_span,
|
||||||
"thread-local variables cannot be borrowed beyond the end of the function",
|
"thread-local variables cannot be borrowed beyond the end of the function",
|
||||||
)
|
)
|
||||||
.span_label_mv(drop_span, "end of enclosing function is here")
|
.with_span_label(drop_span, "end of enclosing function is here")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
|
|
|
@ -334,7 +334,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
span,
|
span,
|
||||||
&format!("`{}` in pattern guard", self.local_names[local].unwrap()),
|
&format!("`{}` in pattern guard", self.local_names[local].unwrap()),
|
||||||
)
|
)
|
||||||
.note_mv(
|
.with_note(
|
||||||
"variables bound in patterns cannot be moved from \
|
"variables bound in patterns cannot be moved from \
|
||||||
until after the end of the pattern guard",
|
until after the end of the pattern guard",
|
||||||
);
|
);
|
||||||
|
@ -382,8 +382,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.cannot_move_out_of(span, &place_description)
|
self.cannot_move_out_of(span, &place_description)
|
||||||
.span_label_mv(upvar_span, "captured outer variable")
|
.with_span_label(upvar_span, "captured outer variable")
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
self.infcx.tcx.def_span(def_id),
|
self.infcx.tcx.def_span(def_id),
|
||||||
format!("captured by this `{closure_kind}` closure"),
|
format!("captured by this `{closure_kind}` closure"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,7 +27,7 @@ use rustc_middle::ty::TypeVisitor;
|
||||||
use rustc_middle::ty::{self, RegionVid, Ty};
|
use rustc_middle::ty::{self, RegionVid, Ty};
|
||||||
use rustc_middle::ty::{Region, TyCtxt};
|
use rustc_middle::ty::{Region, TyCtxt};
|
||||||
use rustc_span::symbol::{kw, Ident};
|
use rustc_span::symbol::{kw, Ident};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
|
|
||||||
use crate::borrowck_errors;
|
use crate::borrowck_errors;
|
||||||
use crate::session_diagnostics::{
|
use crate::session_diagnostics::{
|
||||||
|
@ -84,7 +84,7 @@ impl<'tcx> RegionErrors<'tcx> {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
||||||
let val = val.into();
|
let val = val.into();
|
||||||
self.1.sess.dcx().span_delayed_bug(DUMMY_SP, format!("{val:?}"));
|
self.1.sess.dcx().delayed_bug(format!("{val:?}"));
|
||||||
self.0.push(val);
|
self.0.push(val);
|
||||||
}
|
}
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
|
|
|
@ -421,7 +421,7 @@ fn check_opaque_type_parameter_valid(
|
||||||
return Err(tcx
|
return Err(tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(span, "non-defining opaque type use in defining scope")
|
.struct_span_err(span, "non-defining opaque type use in defining scope")
|
||||||
.span_note_mv(spans, format!("{descr} used multiple times"))
|
.with_span_note(spans, format!("{descr} used multiple times"))
|
||||||
.emit());
|
.emit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,8 +695,8 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
|
||||||
let (sp, msg) = unused_operands.into_iter().next().unwrap();
|
let (sp, msg) = unused_operands.into_iter().next().unwrap();
|
||||||
ecx.dcx()
|
ecx.dcx()
|
||||||
.struct_span_err(sp, msg)
|
.struct_span_err(sp, msg)
|
||||||
.span_label_mv(sp, msg)
|
.with_span_label(sp, msg)
|
||||||
.help_mv(format!(
|
.with_help(format!(
|
||||||
"if this argument is intentionally unused, \
|
"if this argument is intentionally unused, \
|
||||||
consider using it in an asm comment: `\"/*{help_str} */\"`"
|
consider using it in an asm comment: `\"/*{help_str} */\"`"
|
||||||
))
|
))
|
||||||
|
|
|
@ -817,9 +817,9 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
|
||||||
level,
|
level,
|
||||||
crate::fluent_generated::builtin_macros_asm_clobber_no_reg,
|
crate::fluent_generated::builtin_macros_asm_clobber_no_reg,
|
||||||
)
|
)
|
||||||
.span_mv(self.spans.clone())
|
.with_span(self.spans.clone())
|
||||||
.span_labels_mv(self.clobbers, &lbl1)
|
.with_span_labels(self.clobbers, &lbl1)
|
||||||
.span_labels_mv(self.spans, &lbl2)
|
.with_span_labels(self.spans, &lbl2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
||||||
|
|
||||||
self.dcx
|
self.dcx
|
||||||
.struct_span_err(attr.span, msg)
|
.struct_span_err(attr.span, msg)
|
||||||
.span_label_mv(prev_attr.span, "previous attribute here")
|
.with_span_label(prev_attr.span, "previous attribute here")
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -155,7 +155,7 @@ pub fn expand_include<'cx>(
|
||||||
if self.p.token != token::Eof {
|
if self.p.token != token::Eof {
|
||||||
let token = pprust::token_to_string(&self.p.token);
|
let token = pprust::token_to_string(&self.p.token);
|
||||||
let msg = format!("expected item, found `{token}`");
|
let msg = format!("expected item, found `{token}`");
|
||||||
self.p.dcx().struct_span_err(self.p.token.span, msg).emit();
|
self.p.dcx().span_err(self.p.token.span, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -409,8 +409,8 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
err.span_label_mv(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions")
|
err.with_span_label(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions")
|
||||||
.span_suggestion_mv(attr_sp,
|
.with_span_suggestion(attr_sp,
|
||||||
"replace with conditional compilation to make the item only exist when tests are being run",
|
"replace with conditional compilation to make the item only exist when tests are being run",
|
||||||
"#[cfg(test)]",
|
"#[cfg(test)]",
|
||||||
Applicability::MaybeIncorrect)
|
Applicability::MaybeIncorrect)
|
||||||
|
@ -480,7 +480,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
|
||||||
"argument must be of the form: \
|
"argument must be of the form: \
|
||||||
`expected = \"error message\"`",
|
`expected = \"error message\"`",
|
||||||
)
|
)
|
||||||
.note_mv(
|
.with_note(
|
||||||
"errors in this attribute were erroneously \
|
"errors in this attribute were erroneously \
|
||||||
allowed and will become a hard error in a \
|
allowed and will become a hard error in a \
|
||||||
future release",
|
future release",
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
|
||||||
Some(c @ ('+' | '-')) => c,
|
Some(c @ ('+' | '-')) => c,
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
if diagnostics {
|
if diagnostics {
|
||||||
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
|
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s });
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
|
||||||
else {
|
else {
|
||||||
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
|
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
|
||||||
};
|
};
|
||||||
sess.dcx().emit_warning(unknown_feature);
|
sess.dcx().emit_warn(unknown_feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
if diagnostics {
|
if diagnostics {
|
||||||
|
|
|
@ -191,7 +191,7 @@ impl CodegenBackend for GccCodegenBackend {
|
||||||
#[cfg(feature="master")]
|
#[cfg(feature="master")]
|
||||||
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
|
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
|
||||||
if sess.lto() == Lto::Thin {
|
if sess.lto() == Lto::Thin {
|
||||||
sess.dcx().emit_warning(LTONotSupported {});
|
sess.dcx().emit_warn(LTONotSupported {});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature="master"))]
|
#[cfg(not(feature="master"))]
|
||||||
|
|
|
@ -245,12 +245,12 @@ pub fn target_machine_factory(
|
||||||
match sess.opts.debuginfo_compression {
|
match sess.opts.debuginfo_compression {
|
||||||
rustc_session::config::DebugInfoCompression::Zlib => {
|
rustc_session::config::DebugInfoCompression::Zlib => {
|
||||||
if !unsafe { LLVMRustLLVMHasZlibCompressionForDebugSymbols() } {
|
if !unsafe { LLVMRustLLVMHasZlibCompressionForDebugSymbols() } {
|
||||||
sess.dcx().emit_warning(UnknownCompression { algorithm: "zlib" });
|
sess.dcx().emit_warn(UnknownCompression { algorithm: "zlib" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rustc_session::config::DebugInfoCompression::Zstd => {
|
rustc_session::config::DebugInfoCompression::Zstd => {
|
||||||
if !unsafe { LLVMRustLLVMHasZstdCompressionForDebugSymbols() } {
|
if !unsafe { LLVMRustLLVMHasZstdCompressionForDebugSymbols() } {
|
||||||
sess.dcx().emit_warning(UnknownCompression { algorithm: "zstd" });
|
sess.dcx().emit_warn(UnknownCompression { algorithm: "zstd" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rustc_session::config::DebugInfoCompression::None => {}
|
rustc_session::config::DebugInfoCompression::None => {}
|
||||||
|
@ -457,7 +457,7 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
|
||||||
llvm::LLVMRustWriteDiagnosticInfoToString(diagnostic_ref, s)
|
llvm::LLVMRustWriteDiagnosticInfoToString(diagnostic_ref, s)
|
||||||
})
|
})
|
||||||
.expect("non-UTF8 diagnostic");
|
.expect("non-UTF8 diagnostic");
|
||||||
dcx.emit_warning(FromLlvmDiag { message });
|
dcx.emit_warn(FromLlvmDiag { message });
|
||||||
}
|
}
|
||||||
llvm::diagnostic::Unsupported(diagnostic_ref) => {
|
llvm::diagnostic::Unsupported(diagnostic_ref) => {
|
||||||
let message = llvm::build_string(|s| {
|
let message = llvm::build_string(|s| {
|
||||||
|
|
|
@ -106,7 +106,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ParseTargetMachineConfig<'_
|
||||||
let message = dcx.eagerly_translate_to_string(message.clone(), diag.args());
|
let message = dcx.eagerly_translate_to_string(message.clone(), diag.args());
|
||||||
|
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config)
|
DiagnosticBuilder::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config)
|
||||||
.arg_mv("error", message)
|
.with_arg("error", message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +204,8 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
|
||||||
};
|
};
|
||||||
self.0
|
self.0
|
||||||
.into_diagnostic(dcx, level)
|
.into_diagnostic(dcx, level)
|
||||||
.primary_message_mv(msg_with_llvm_err)
|
.with_primary_message(msg_with_llvm_err)
|
||||||
.arg_mv("llvm_err", self.1)
|
.with_arg("llvm_err", self.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -529,7 +529,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
|
||||||
Some(c @ ('+' | '-')) => c,
|
Some(c @ ('+' | '-')) => c,
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
if diagnostics {
|
if diagnostics {
|
||||||
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
|
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s });
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -557,12 +557,12 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
|
||||||
} else {
|
} else {
|
||||||
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
|
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
|
||||||
};
|
};
|
||||||
sess.dcx().emit_warning(unknown_feature);
|
sess.dcx().emit_warn(unknown_feature);
|
||||||
} else if feature_state
|
} else if feature_state
|
||||||
.is_some_and(|(_name, feature_gate)| !feature_gate.is_stable())
|
.is_some_and(|(_name, feature_gate)| !feature_gate.is_stable())
|
||||||
{
|
{
|
||||||
// An unstable feature. Warn about using it.
|
// An unstable feature. Warn about using it.
|
||||||
sess.dcx().emit_warning(UnstableCTargetFeature { feature });
|
sess.dcx().emit_warn(UnstableCTargetFeature { feature });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1016,7 +1016,7 @@ fn link_natively<'a>(
|
||||||
if !prog.status.success() {
|
if !prog.status.success() {
|
||||||
let mut output = prog.stderr.clone();
|
let mut output = prog.stderr.clone();
|
||||||
output.extend_from_slice(&prog.stdout);
|
output.extend_from_slice(&prog.stdout);
|
||||||
sess.dcx().emit_warning(errors::ProcessingDymutilFailed {
|
sess.dcx().emit_warn(errors::ProcessingDymutilFailed {
|
||||||
status: prog.status,
|
status: prog.status,
|
||||||
output: escape_string(&output),
|
output: escape_string(&output),
|
||||||
});
|
});
|
||||||
|
@ -1091,7 +1091,7 @@ fn strip_symbols_with_external_utility<'a>(
|
||||||
if !prog.status.success() {
|
if !prog.status.success() {
|
||||||
let mut output = prog.stderr.clone();
|
let mut output = prog.stderr.clone();
|
||||||
output.extend_from_slice(&prog.stdout);
|
output.extend_from_slice(&prog.stdout);
|
||||||
sess.dcx().emit_warning(errors::StrippingDebugInfoFailed {
|
sess.dcx().emit_warn(errors::StrippingDebugInfoFailed {
|
||||||
util,
|
util,
|
||||||
status: prog.status,
|
status: prog.status,
|
||||||
output: escape_string(&output),
|
output: escape_string(&output),
|
||||||
|
@ -2406,7 +2406,7 @@ fn collect_natvis_visualizers(
|
||||||
visualizer_paths.push(visualizer_out_file);
|
visualizer_paths.push(visualizer_out_file);
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
sess.dcx().emit_warning(errors::UnableToWriteDebuggerVisualizer {
|
sess.dcx().emit_warn(errors::UnableToWriteDebuggerVisualizer {
|
||||||
path: visualizer_out_file,
|
path: visualizer_out_file,
|
||||||
error,
|
error,
|
||||||
});
|
});
|
||||||
|
|
|
@ -446,11 +446,11 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
// FIXME(81490): ld64 doesn't support these flags but macOS 11
|
// FIXME(81490): ld64 doesn't support these flags but macOS 11
|
||||||
// has -needed-l{} / -needed_library {}
|
// has -needed-l{} / -needed_library {}
|
||||||
// but we have no way to detect that here.
|
// but we have no way to detect that here.
|
||||||
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
|
self.sess.dcx().emit_warn(errors::Ld64UnimplementedModifier);
|
||||||
} else if self.is_gnu && !self.sess.target.is_like_windows {
|
} else if self.is_gnu && !self.sess.target.is_like_windows {
|
||||||
self.linker_arg("--no-as-needed");
|
self.linker_arg("--no-as-needed");
|
||||||
} else {
|
} else {
|
||||||
self.sess.dcx().emit_warning(errors::LinkerUnsupportedModifier);
|
self.sess.dcx().emit_warn(errors::LinkerUnsupportedModifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.hint_dynamic();
|
self.hint_dynamic();
|
||||||
|
@ -504,7 +504,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
|
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
|
||||||
// flag but we have no way to detect that here.
|
// flag but we have no way to detect that here.
|
||||||
// self.cmd.arg("-needed_framework").arg(framework);
|
// self.cmd.arg("-needed_framework").arg(framework);
|
||||||
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
|
self.sess.dcx().emit_warn(errors::Ld64UnimplementedModifier);
|
||||||
}
|
}
|
||||||
self.cmd.arg("-framework").arg(framework);
|
self.cmd.arg("-framework").arg(framework);
|
||||||
}
|
}
|
||||||
|
@ -950,7 +950,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
self.sess.dcx().emit_warning(errors::NoNatvisDirectory { error });
|
self.sess.dcx().emit_warn(errors::NoNatvisDirectory { error });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1501,7 +1501,7 @@ impl<'a> Linker for L4Bender<'a> {
|
||||||
|
|
||||||
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
|
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
|
||||||
// ToDo, not implemented, copy from GCC
|
// ToDo, not implemented, copy from GCC
|
||||||
self.sess.dcx().emit_warning(errors::L4BenderExportingSymbolsUnimplemented);
|
self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -573,11 +573,11 @@ fn produce_final_output_artifacts(
|
||||||
if crate_output.outputs.contains_key(&output_type) {
|
if crate_output.outputs.contains_key(&output_type) {
|
||||||
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
|
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
|
||||||
// no good solution for this case, so warn the user.
|
// no good solution for this case, so warn the user.
|
||||||
sess.dcx().emit_warning(errors::IgnoringEmitPath { extension });
|
sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });
|
||||||
} else if crate_output.single_output_file.is_some() {
|
} else if crate_output.single_output_file.is_some() {
|
||||||
// 3) Multiple codegen units, with `-o some_name`. We have
|
// 3) Multiple codegen units, with `-o some_name`. We have
|
||||||
// no good solution for this case, so warn the user.
|
// no good solution for this case, so warn the user.
|
||||||
sess.dcx().emit_warning(errors::IgnoringOutput { extension });
|
sess.dcx().emit_warn(errors::IgnoringOutput { extension });
|
||||||
} else {
|
} else {
|
||||||
// 4) Multiple codegen units, but no explicit name. We
|
// 4) Multiple codegen units, but no explicit name. We
|
||||||
// just leave the `foo.0.x` files in place.
|
// just leave the `foo.0.x` files in place.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use rustc_ast::{ast, attr, MetaItemKind, NestedMetaItem};
|
use rustc_ast::{ast, attr, MetaItemKind, NestedMetaItem};
|
||||||
use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr};
|
use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr};
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
|
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
|
||||||
|
@ -216,7 +216,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
if let Some(fn_sig) = fn_sig()
|
if let Some(fn_sig) = fn_sig()
|
||||||
&& !matches!(fn_sig.skip_binder().abi(), abi::Abi::C { .. })
|
&& !matches!(fn_sig.skip_binder().abi(), abi::Abi::C { .. })
|
||||||
{
|
{
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0776,
|
E0776,
|
||||||
|
@ -225,7 +225,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
if !tcx.sess.target.llvm_target.contains("thumbv8m") {
|
if !tcx.sess.target.llvm_target.contains("thumbv8m") {
|
||||||
struct_span_err!(tcx.dcx(), attr.span, E0775, "`#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension")
|
struct_span_code_err!(tcx.dcx(), attr.span, E0775, "`#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY
|
codegen_fn_attrs.flags |= CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY
|
||||||
|
@ -238,7 +238,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
&& let Some(fn_sig) = fn_sig()
|
&& let Some(fn_sig) = fn_sig()
|
||||||
&& fn_sig.skip_binder().abi() != abi::Abi::Rust
|
&& fn_sig.skip_binder().abi() != abi::Abi::Rust
|
||||||
{
|
{
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0737,
|
E0737,
|
||||||
|
@ -265,7 +265,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
if s.as_str().contains('\0') {
|
if s.as_str().contains('\0') {
|
||||||
// `#[export_name = ...]` will be converted to a null-terminated string,
|
// `#[export_name = ...]` will be converted to a null-terminated string,
|
||||||
// so it may not contain any null characters.
|
// so it may not contain any null characters.
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0648,
|
E0648,
|
||||||
|
@ -309,7 +309,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
attr.span,
|
attr.span,
|
||||||
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
|
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
|
||||||
)
|
)
|
||||||
.span_label_mv(tcx.def_span(did), "not an `unsafe` function")
|
.with_span_label(tcx.def_span(did), "not an `unsafe` function")
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
check_target_feature_trait_unsafe(tcx, did, attr.span);
|
check_target_feature_trait_unsafe(tcx, did, attr.span);
|
||||||
|
@ -385,7 +385,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
match segments.as_slice() {
|
match segments.as_slice() {
|
||||||
[sym::arm, sym::a32] | [sym::arm, sym::t32] => {
|
[sym::arm, sym::a32] | [sym::arm, sym::t32] => {
|
||||||
if !tcx.sess.target.has_thumb_interworking {
|
if !tcx.sess.target.has_thumb_interworking {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0779,
|
E0779,
|
||||||
|
@ -402,7 +402,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0779,
|
E0779,
|
||||||
|
@ -414,7 +414,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[] => {
|
[] => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0778,
|
E0778,
|
||||||
|
@ -424,7 +424,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0779,
|
E0779,
|
||||||
|
@ -442,7 +442,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
{
|
{
|
||||||
rustc_attr::parse_alignment(&literal.kind)
|
rustc_attr::parse_alignment(&literal.kind)
|
||||||
.map_err(|msg| {
|
.map_err(|msg| {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0589,
|
E0589,
|
||||||
|
@ -469,15 +469,16 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
Some(MetaItemKind::List(ref items)) => {
|
Some(MetaItemKind::List(ref items)) => {
|
||||||
inline_span = Some(attr.span);
|
inline_span = Some(attr.span);
|
||||||
if items.len() != 1 {
|
if items.len() != 1 {
|
||||||
struct_span_err!(tcx.dcx(), attr.span, E0534, "expected one argument").emit();
|
struct_span_code_err!(tcx.dcx(), attr.span, E0534, "expected one argument")
|
||||||
|
.emit();
|
||||||
InlineAttr::None
|
InlineAttr::None
|
||||||
} else if list_contains_name(items, sym::always) {
|
} else if list_contains_name(items, sym::always) {
|
||||||
InlineAttr::Always
|
InlineAttr::Always
|
||||||
} else if list_contains_name(items, sym::never) {
|
} else if list_contains_name(items, sym::never) {
|
||||||
InlineAttr::Never
|
InlineAttr::Never
|
||||||
} else {
|
} else {
|
||||||
struct_span_err!(tcx.dcx(), items[0].span(), E0535, "invalid argument")
|
struct_span_code_err!(tcx.dcx(), items[0].span(), E0535, "invalid argument")
|
||||||
.help_mv("valid inline arguments are `always` and `never`")
|
.with_help("valid inline arguments are `always` and `never`")
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
InlineAttr::None
|
InlineAttr::None
|
||||||
|
@ -492,7 +493,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
if !attr.has_name(sym::optimize) {
|
if !attr.has_name(sym::optimize) {
|
||||||
return ia;
|
return ia;
|
||||||
}
|
}
|
||||||
let err = |sp, s| struct_span_err!(tcx.dcx(), sp, E0722, "{}", s).emit();
|
let err = |sp, s| struct_span_code_err!(tcx.dcx(), sp, E0722, "{}", s).emit();
|
||||||
match attr.meta_kind() {
|
match attr.meta_kind() {
|
||||||
Some(MetaItemKind::Word) => {
|
Some(MetaItemKind::Word) => {
|
||||||
err(attr.span, "expected one argument");
|
err(attr.span, "expected one argument");
|
||||||
|
@ -662,7 +663,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
||||||
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
|
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(attr.span, msg)
|
.struct_span_err(attr.span, msg)
|
||||||
.note_mv("the value may not exceed `u16::MAX`")
|
.with_note("the value may not exceed `u16::MAX`")
|
||||||
.emit();
|
.emit();
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,25 +230,25 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
||||||
thorin::Error::DecompressData(_) => build(fluent::codegen_ssa_thorin_decompress_data),
|
thorin::Error::DecompressData(_) => build(fluent::codegen_ssa_thorin_decompress_data),
|
||||||
thorin::Error::NamelessSection(_, offset) => {
|
thorin::Error::NamelessSection(_, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_section_without_name)
|
build(fluent::codegen_ssa_thorin_section_without_name)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::RelocationWithInvalidSymbol(section, offset) => {
|
thorin::Error::RelocationWithInvalidSymbol(section, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_relocation_with_invalid_symbol)
|
build(fluent::codegen_ssa_thorin_relocation_with_invalid_symbol)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::MultipleRelocations(section, offset) => {
|
thorin::Error::MultipleRelocations(section, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_multiple_relocations)
|
build(fluent::codegen_ssa_thorin_multiple_relocations)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::UnsupportedRelocation(section, offset) => {
|
thorin::Error::UnsupportedRelocation(section, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_unsupported_relocation)
|
build(fluent::codegen_ssa_thorin_unsupported_relocation)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::MissingDwoName(id) => build(fluent::codegen_ssa_thorin_missing_dwo_name)
|
thorin::Error::MissingDwoName(id) => build(fluent::codegen_ssa_thorin_missing_dwo_name)
|
||||||
.arg_mv("id", format!("0x{id:08x}")),
|
.with_arg("id", format!("0x{id:08x}")),
|
||||||
thorin::Error::NoCompilationUnits => {
|
thorin::Error::NoCompilationUnits => {
|
||||||
build(fluent::codegen_ssa_thorin_no_compilation_units)
|
build(fluent::codegen_ssa_thorin_no_compilation_units)
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
||||||
}
|
}
|
||||||
thorin::Error::MissingRequiredSection(section) => {
|
thorin::Error::MissingRequiredSection(section) => {
|
||||||
build(fluent::codegen_ssa_thorin_missing_required_section)
|
build(fluent::codegen_ssa_thorin_missing_required_section)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
}
|
}
|
||||||
thorin::Error::ParseUnitAbbreviations(_) => {
|
thorin::Error::ParseUnitAbbreviations(_) => {
|
||||||
build(fluent::codegen_ssa_thorin_parse_unit_abbreviations)
|
build(fluent::codegen_ssa_thorin_parse_unit_abbreviations)
|
||||||
|
@ -272,31 +272,30 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
||||||
thorin::Error::ParseUnit(_) => build(fluent::codegen_ssa_thorin_parse_unit),
|
thorin::Error::ParseUnit(_) => build(fluent::codegen_ssa_thorin_parse_unit),
|
||||||
thorin::Error::IncompatibleIndexVersion(section, format, actual) => {
|
thorin::Error::IncompatibleIndexVersion(section, format, actual) => {
|
||||||
build(fluent::codegen_ssa_thorin_incompatible_index_version)
|
build(fluent::codegen_ssa_thorin_incompatible_index_version)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("actual", actual)
|
.with_arg("actual", actual)
|
||||||
.arg_mv("format", format)
|
.with_arg("format", format)
|
||||||
}
|
}
|
||||||
thorin::Error::OffsetAtIndex(_, index) => {
|
thorin::Error::OffsetAtIndex(_, index) => {
|
||||||
build(fluent::codegen_ssa_thorin_offset_at_index).arg_mv("index", index)
|
build(fluent::codegen_ssa_thorin_offset_at_index).with_arg("index", index)
|
||||||
}
|
}
|
||||||
thorin::Error::StrAtOffset(_, offset) => {
|
thorin::Error::StrAtOffset(_, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_str_at_offset)
|
build(fluent::codegen_ssa_thorin_str_at_offset)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::ParseIndex(_, section) => {
|
thorin::Error::ParseIndex(_, section) => {
|
||||||
build(fluent::codegen_ssa_thorin_parse_index).arg_mv("section", section)
|
build(fluent::codegen_ssa_thorin_parse_index).with_arg("section", section)
|
||||||
}
|
}
|
||||||
thorin::Error::UnitNotInIndex(unit) => {
|
thorin::Error::UnitNotInIndex(unit) => {
|
||||||
build(fluent::codegen_ssa_thorin_unit_not_in_index)
|
build(fluent::codegen_ssa_thorin_unit_not_in_index)
|
||||||
.arg_mv("unit", format!("0x{unit:08x}"))
|
.with_arg("unit", format!("0x{unit:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::RowNotInIndex(_, row) => {
|
thorin::Error::RowNotInIndex(_, row) => {
|
||||||
build(fluent::codegen_ssa_thorin_row_not_in_index).arg_mv("row", row)
|
build(fluent::codegen_ssa_thorin_row_not_in_index).with_arg("row", row)
|
||||||
}
|
}
|
||||||
thorin::Error::SectionNotInRow => build(fluent::codegen_ssa_thorin_section_not_in_row),
|
thorin::Error::SectionNotInRow => build(fluent::codegen_ssa_thorin_section_not_in_row),
|
||||||
thorin::Error::EmptyUnit(unit) => {
|
thorin::Error::EmptyUnit(unit) => build(fluent::codegen_ssa_thorin_empty_unit)
|
||||||
build(fluent::codegen_ssa_thorin_empty_unit).arg_mv("unit", format!("0x{unit:08x}"))
|
.with_arg("unit", format!("0x{unit:08x}")),
|
||||||
}
|
|
||||||
thorin::Error::MultipleDebugInfoSection => {
|
thorin::Error::MultipleDebugInfoSection => {
|
||||||
build(fluent::codegen_ssa_thorin_multiple_debug_info_section)
|
build(fluent::codegen_ssa_thorin_multiple_debug_info_section)
|
||||||
}
|
}
|
||||||
|
@ -305,10 +304,10 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
||||||
}
|
}
|
||||||
thorin::Error::NotSplitUnit => build(fluent::codegen_ssa_thorin_not_split_unit),
|
thorin::Error::NotSplitUnit => build(fluent::codegen_ssa_thorin_not_split_unit),
|
||||||
thorin::Error::DuplicateUnit(unit) => build(fluent::codegen_ssa_thorin_duplicate_unit)
|
thorin::Error::DuplicateUnit(unit) => build(fluent::codegen_ssa_thorin_duplicate_unit)
|
||||||
.arg_mv("unit", format!("0x{unit:08x}")),
|
.with_arg("unit", format!("0x{unit:08x}")),
|
||||||
thorin::Error::MissingReferencedUnit(unit) => {
|
thorin::Error::MissingReferencedUnit(unit) => {
|
||||||
build(fluent::codegen_ssa_thorin_missing_referenced_unit)
|
build(fluent::codegen_ssa_thorin_missing_referenced_unit)
|
||||||
.arg_mv("unit", format!("0x{unit:08x}"))
|
.with_arg("unit", format!("0x{unit:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::NoOutputObjectCreated => {
|
thorin::Error::NoOutputObjectCreated => {
|
||||||
build(fluent::codegen_ssa_thorin_not_output_object_created)
|
build(fluent::codegen_ssa_thorin_not_output_object_created)
|
||||||
|
@ -317,19 +316,19 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
||||||
build(fluent::codegen_ssa_thorin_mixed_input_encodings)
|
build(fluent::codegen_ssa_thorin_mixed_input_encodings)
|
||||||
}
|
}
|
||||||
thorin::Error::Io(e) => {
|
thorin::Error::Io(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_io).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_io).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::ObjectRead(e) => {
|
thorin::Error::ObjectRead(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_object_read).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_object_read).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::ObjectWrite(e) => {
|
thorin::Error::ObjectWrite(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_object_write).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_object_write).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::GimliRead(e) => {
|
thorin::Error::GimliRead(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_gimli_read).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_gimli_read).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::GimliWrite(e) => {
|
thorin::Error::GimliWrite(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_gimli_write).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_gimli_write).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
_ => unimplemented!("Untranslated thorin error"),
|
_ => unimplemented!("Untranslated thorin error"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn from_target_feature(
|
||||||
let code = "enable = \"..\"";
|
let code = "enable = \"..\"";
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.span_suggestion_mv(span, "must be of the form", code, Applicability::HasPlaceholders)
|
.with_span_suggestion(span, "must be of the form", code, Applicability::HasPlaceholders)
|
||||||
.emit();
|
.emit();
|
||||||
};
|
};
|
||||||
let rust_features = tcx.features();
|
let rust_features = tcx.features();
|
||||||
|
|
|
@ -391,10 +391,10 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
if ecx.tcx.is_ctfe_mir_available(def) {
|
if ecx.tcx.is_ctfe_mir_available(def) {
|
||||||
Ok(ecx.tcx.mir_for_ctfe(def))
|
Ok(ecx.tcx.mir_for_ctfe(def))
|
||||||
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst {
|
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst {
|
||||||
let guar = ecx.tcx.dcx().span_delayed_bug(
|
let guar = ecx
|
||||||
rustc_span::DUMMY_SP,
|
.tcx
|
||||||
"This is likely a const item that is missing from its impl",
|
.dcx()
|
||||||
);
|
.delayed_bug("This is likely a const item that is missing from its impl");
|
||||||
throw_inval!(AlreadyReported(guar.into()));
|
throw_inval!(AlreadyReported(guar.into()));
|
||||||
} else {
|
} else {
|
||||||
// `find_mir_or_eval_fn` checks that this is a const fn before even calling us,
|
// `find_mir_or_eval_fn` checks that this is a const fn before even calling us,
|
||||||
|
@ -630,7 +630,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
|
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
|
||||||
// way to implement exponential backoff.
|
// way to implement exponential backoff.
|
||||||
let span = ecx.cur_span();
|
let span = ecx.cur_span();
|
||||||
ecx.tcx.dcx().emit_warning(LongRunningWarn { span, item_span: ecx.tcx.span });
|
ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1429,7 +1429,7 @@ fn report_ice(
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// The path ICE couldn't be written to disk, provide feedback to the user as to why.
|
// The path ICE couldn't be written to disk, provide feedback to the user as to why.
|
||||||
dcx.emit_warning(session_diagnostics::IcePathError {
|
dcx.emit_warn(session_diagnostics::IcePathError {
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
error: err.to_string(),
|
error: err.to_string(),
|
||||||
env_var: std::env::var_os("RUSTC_ICE")
|
env_var: std::env::var_os("RUSTC_ICE")
|
||||||
|
|
|
@ -30,7 +30,7 @@ where
|
||||||
G: EmissionGuarantee,
|
G: EmissionGuarantee,
|
||||||
{
|
{
|
||||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
||||||
self.node.into_diagnostic(dcx, level).span_mv(self.span)
|
self.node.into_diagnostic(dcx, level).with_span(self.span)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,26 +173,26 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
||||||
/// `Diagnostic` method. It is mostly to modify existing diagnostics, either
|
/// `Diagnostic` method. It is mostly to modify existing diagnostics, either
|
||||||
/// in a standalone fashion, e.g. `err.code(code)`, or in a chained fashion
|
/// in a standalone fashion, e.g. `err.code(code)`, or in a chained fashion
|
||||||
/// to make multiple modifications, e.g. `err.code(code).span(span)`.
|
/// to make multiple modifications, e.g. `err.code(code).span(span)`.
|
||||||
/// - A `self -> Self` method, with `_mv` suffix added (short for "move").
|
/// - A `self -> Self` method, which has a `with_` prefix added.
|
||||||
/// It is mostly used in a chained fashion when producing a new diagnostic,
|
/// It is mostly used in a chained fashion when producing a new diagnostic,
|
||||||
/// e.g. `let err = struct_err(msg).code_mv(code)`, or when emitting a new
|
/// e.g. `let err = struct_err(msg).with_code(code)`, or when emitting a new
|
||||||
/// diagnostic , e.g. `struct_err(msg).code_mv(code).emit()`.
|
/// diagnostic , e.g. `struct_err(msg).with_code(code).emit()`.
|
||||||
///
|
///
|
||||||
/// Although the latter method can be used to modify an existing diagnostic,
|
/// Although the latter method can be used to modify an existing diagnostic,
|
||||||
/// e.g. `err = err.code_mv(code)`, this should be avoided because the former
|
/// e.g. `err = err.with_code(code)`, this should be avoided because the former
|
||||||
/// method give shorter code, e.g. `err.code(code)`.
|
/// method gives shorter code, e.g. `err.code(code)`.
|
||||||
macro_rules! forward {
|
macro_rules! forward {
|
||||||
(
|
(
|
||||||
($n:ident, $n_mv:ident)($($name:ident: $ty:ty),* $(,)?)
|
($f:ident, $with_f:ident)($($name:ident: $ty:ty),* $(,)?)
|
||||||
) => {
|
) => {
|
||||||
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
|
#[doc = concat!("See [`Diagnostic::", stringify!($f), "()`].")]
|
||||||
pub fn $n(&mut self, $($name: $ty),*) -> &mut Self {
|
pub fn $f(&mut self, $($name: $ty),*) -> &mut Self {
|
||||||
self.diag.as_mut().unwrap().$n($($name),*);
|
self.diag.as_mut().unwrap().$f($($name),*);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
|
#[doc = concat!("See [`Diagnostic::", stringify!($f), "()`].")]
|
||||||
pub fn $n_mv(mut self, $($name: $ty),*) -> Self {
|
pub fn $with_f(mut self, $($name: $ty),*) -> Self {
|
||||||
self.diag.as_mut().unwrap().$n($($name),*);
|
self.diag.as_mut().unwrap().$f($($name),*);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -265,7 +265,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
|
|
||||||
/// Converts the builder to a `Diagnostic` for later emission,
|
/// Converts the builder to a `Diagnostic` for later emission,
|
||||||
/// unless dcx has disabled such buffering.
|
/// unless dcx has disabled such buffering.
|
||||||
pub fn into_diagnostic(mut self) -> Option<(Diagnostic, &'a DiagCtxt)> {
|
fn into_diagnostic(mut self) -> Option<(Diagnostic, &'a DiagCtxt)> {
|
||||||
if self.dcx.inner.lock().flags.treat_err_as_bug.is_some() {
|
if self.dcx.inner.lock().flags.treat_err_as_bug.is_some() {
|
||||||
self.emit();
|
self.emit();
|
||||||
return None;
|
return None;
|
||||||
|
@ -302,21 +302,21 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
self.emit()
|
self.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
forward!((span_label, span_label_mv)(
|
forward!((span_label, with_span_label)(
|
||||||
span: Span,
|
span: Span,
|
||||||
label: impl Into<SubdiagnosticMessage>,
|
label: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_labels, span_labels_mv)(
|
forward!((span_labels, with_span_labels)(
|
||||||
spans: impl IntoIterator<Item = Span>,
|
spans: impl IntoIterator<Item = Span>,
|
||||||
label: &str,
|
label: &str,
|
||||||
));
|
));
|
||||||
forward!((note_expected_found, note_expected_found_mv)(
|
forward!((note_expected_found, with_note_expected_found)(
|
||||||
expected_label: &dyn fmt::Display,
|
expected_label: &dyn fmt::Display,
|
||||||
expected: DiagnosticStyledString,
|
expected: DiagnosticStyledString,
|
||||||
found_label: &dyn fmt::Display,
|
found_label: &dyn fmt::Display,
|
||||||
found: DiagnosticStyledString,
|
found: DiagnosticStyledString,
|
||||||
));
|
));
|
||||||
forward!((note_expected_found_extra, note_expected_found_extra_mv)(
|
forward!((note_expected_found_extra, with_note_expected_found_extra)(
|
||||||
expected_label: &dyn fmt::Display,
|
expected_label: &dyn fmt::Display,
|
||||||
expected: DiagnosticStyledString,
|
expected: DiagnosticStyledString,
|
||||||
found_label: &dyn fmt::Display,
|
found_label: &dyn fmt::Display,
|
||||||
|
@ -324,106 +324,110 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
expected_extra: &dyn fmt::Display,
|
expected_extra: &dyn fmt::Display,
|
||||||
found_extra: &dyn fmt::Display,
|
found_extra: &dyn fmt::Display,
|
||||||
));
|
));
|
||||||
forward!((note, note_mv)(
|
forward!((note, with_note)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((note_once, note_once_mv)(
|
forward!((note_once, with_note_once)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_note, span_note_mv)(
|
forward!((span_note, with_span_note)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_note_once, span_note_once_mv)(
|
forward!((span_note_once, with_span_note_once)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((warn, warn_mv)(
|
forward!((warn, with_warn)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_warn, span_warn_mv)(
|
forward!((span_warn, with_span_warn)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((help, help_mv)(
|
forward!((help, with_help)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((help_once, help_once_mv)(
|
forward!((help_once, with_help_once)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_help, span_help_once_mv)(
|
forward!((span_help, with_span_help_once)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((multipart_suggestion, multipart_suggestion_mv)(
|
forward!((multipart_suggestion, with_multipart_suggestion)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((multipart_suggestion_verbose, multipart_suggestion_verbose_mv)(
|
forward!((multipart_suggestion_verbose, with_multipart_suggestion_verbose)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((tool_only_multipart_suggestion, tool_only_multipart_suggestion_mv)(
|
forward!((tool_only_multipart_suggestion, with_tool_only_multipart_suggestion)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion, span_suggestion_mv)(
|
forward!((span_suggestion, with_span_suggestion)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestions, span_suggestions_mv)(
|
forward!((span_suggestions, with_span_suggestions)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestions: impl IntoIterator<Item = String>,
|
suggestions: impl IntoIterator<Item = String>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((multipart_suggestions, multipart_suggestions_mv)(
|
forward!((multipart_suggestions, with_multipart_suggestions)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestions: impl IntoIterator<Item = Vec<(Span, String)>>,
|
suggestions: impl IntoIterator<Item = Vec<(Span, String)>>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion_short, span_suggestion_short_mv)(
|
forward!((span_suggestion_short, with_span_suggestion_short)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion_verbose, span_suggestion_verbose_mv)(
|
forward!((span_suggestion_verbose, with_span_suggestion_verbose)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion_hidden, span_suggestion_hidden_mv)(
|
forward!((span_suggestion_hidden, with_span_suggestion_hidden)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((tool_only_span_suggestion, tool_only_span_suggestion_mv)(
|
forward!((tool_only_span_suggestion, with_tool_only_span_suggestion)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((primary_message, primary_message_mv)(
|
forward!((primary_message, with_primary_message)(
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span, span_mv)(
|
forward!((span, with_span)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
));
|
));
|
||||||
forward!((code, code_mv)(
|
forward!((code, with_code)(
|
||||||
s: DiagnosticId,
|
s: DiagnosticId,
|
||||||
));
|
));
|
||||||
forward!((arg, arg_mv)(
|
forward!((arg, with_arg)(
|
||||||
name: impl Into<Cow<'static, str>>, arg: impl IntoDiagnosticArg,
|
name: impl Into<Cow<'static, str>>, arg: impl IntoDiagnosticArg,
|
||||||
));
|
));
|
||||||
forward!((subdiagnostic, subdiagnostic_mv)(
|
forward!((subdiagnostic, with_subdiagnostic)(
|
||||||
|
subdiagnostic: impl crate::AddToDiagnostic,
|
||||||
|
));
|
||||||
|
forward!((eager_subdiagnostic, with_eager_subdiagnostic)(
|
||||||
|
dcx: &DiagCtxt,
|
||||||
subdiagnostic: impl crate::AddToDiagnostic,
|
subdiagnostic: impl crate::AddToDiagnostic,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -453,13 +457,13 @@ impl<G: EmissionGuarantee> Drop for DiagnosticBuilder<'_, G> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! struct_span_err {
|
macro_rules! struct_span_code_err {
|
||||||
($dcx:expr, $span:expr, $code:ident, $($message:tt)*) => ({
|
($dcx:expr, $span:expr, $code:ident, $($message:tt)*) => ({
|
||||||
$dcx.struct_span_err(
|
$dcx.struct_span_err(
|
||||||
$span,
|
$span,
|
||||||
format!($($message)*),
|
format!($($message)*),
|
||||||
)
|
)
|
||||||
.code_mv($crate::error_code!($code))
|
.with_code($crate::error_code!($code))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,40 +252,40 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetDataLayoutErrors<'_>
|
||||||
match self {
|
match self {
|
||||||
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_address_space)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_address_space)
|
||||||
.arg_mv("addr_space", addr_space)
|
.with_arg("addr_space", addr_space)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
.arg_mv("err", err)
|
.with_arg("err", err)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => {
|
TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits)
|
||||||
.arg_mv("kind", kind)
|
.with_arg("kind", kind)
|
||||||
.arg_mv("bit", bit)
|
.with_arg("bit", bit)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
.arg_mv("err", err)
|
.with_arg("err", err)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::MissingAlignment { cause } => {
|
TargetDataLayoutErrors::MissingAlignment { cause } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_missing_alignment)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_missing_alignment)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InvalidAlignment { cause, err } => {
|
TargetDataLayoutErrors::InvalidAlignment { cause, err } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_alignment)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_alignment)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
.arg_mv("err_kind", err.diag_ident())
|
.with_arg("err_kind", err.diag_ident())
|
||||||
.arg_mv("align", err.align())
|
.with_arg("align", err.align())
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => {
|
TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_architecture)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_architecture)
|
||||||
.arg_mv("dl", dl)
|
.with_arg("dl", dl)
|
||||||
.arg_mv("target", target)
|
.with_arg("target", target)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => {
|
TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_pointer_width)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_pointer_width)
|
||||||
.arg_mv("pointer_size", pointer_size)
|
.with_arg("pointer_size", pointer_size)
|
||||||
.arg_mv("target", target)
|
.with_arg("target", target)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InvalidBitsSize { err } => {
|
TargetDataLayoutErrors::InvalidBitsSize { err } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits_size)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits_size)
|
||||||
.arg_mv("err", err)
|
.with_arg("err", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -727,7 +727,7 @@ impl DiagCtxt {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, ()> {
|
) -> DiagnosticBuilder<'_, ()> {
|
||||||
self.struct_warn(msg).span_mv(span)
|
self.struct_warn(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a builder at the `Warning` level with the `msg`.
|
/// Construct a builder at the `Warning` level with the `msg`.
|
||||||
|
@ -767,7 +767,7 @@ impl DiagCtxt {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_> {
|
) -> DiagnosticBuilder<'_> {
|
||||||
self.struct_err(msg).span_mv(span)
|
self.struct_err(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a builder at the `Error` level with the `msg`.
|
/// Construct a builder at the `Error` level with the `msg`.
|
||||||
|
@ -786,7 +786,7 @@ impl DiagCtxt {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, FatalAbort> {
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
self.struct_fatal(msg).span_mv(span)
|
self.struct_fatal(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a builder at the `Fatal` level with the `msg`.
|
/// Construct a builder at the `Fatal` level with the `msg`.
|
||||||
|
@ -827,7 +827,7 @@ impl DiagCtxt {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, BugAbort> {
|
) -> DiagnosticBuilder<'_, BugAbort> {
|
||||||
self.struct_bug(msg).span_mv(span)
|
self.struct_bug(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
|
@ -865,10 +865,16 @@ impl DiagCtxt {
|
||||||
/// For example, it can be used to create an [`ErrorGuaranteed`]
|
/// For example, it can be used to create an [`ErrorGuaranteed`]
|
||||||
/// (but you should prefer threading through the [`ErrorGuaranteed`] from an error emission
|
/// (but you should prefer threading through the [`ErrorGuaranteed`] from an error emission
|
||||||
/// directly).
|
/// directly).
|
||||||
///
|
#[track_caller]
|
||||||
/// If no span is available, use [`DUMMY_SP`].
|
pub fn delayed_bug(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
|
||||||
///
|
let treat_next_err_as_bug = self.inner.borrow().treat_next_err_as_bug();
|
||||||
/// [`DUMMY_SP`]: rustc_span::DUMMY_SP
|
if treat_next_err_as_bug {
|
||||||
|
self.bug(msg);
|
||||||
|
}
|
||||||
|
DiagnosticBuilder::<ErrorGuaranteed>::new(self, DelayedBug, msg).emit()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Like `delayed_bug`, but takes an additional span.
|
||||||
///
|
///
|
||||||
/// Note: this function used to be called `delay_span_bug`. It was renamed
|
/// Note: this function used to be called `delay_span_bug`. It was renamed
|
||||||
/// to match similar functions like `span_err`, `span_warn`, etc.
|
/// to match similar functions like `span_err`, `span_warn`, etc.
|
||||||
|
@ -882,9 +888,7 @@ impl DiagCtxt {
|
||||||
if treat_next_err_as_bug {
|
if treat_next_err_as_bug {
|
||||||
self.span_bug(sp, msg);
|
self.span_bug(sp, msg);
|
||||||
}
|
}
|
||||||
let mut diagnostic = Diagnostic::new(DelayedBug, msg);
|
DiagnosticBuilder::<ErrorGuaranteed>::new(self, DelayedBug, msg).with_span(sp).emit()
|
||||||
diagnostic.span(sp);
|
|
||||||
self.emit_diagnostic(diagnostic).unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
|
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
|
||||||
|
@ -909,7 +913,7 @@ impl DiagCtxt {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, ()> {
|
) -> DiagnosticBuilder<'_, ()> {
|
||||||
DiagnosticBuilder::new(self, Note, msg).span_mv(span)
|
DiagnosticBuilder::new(self, Note, msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
|
@ -1086,7 +1090,7 @@ impl DiagCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn create_warning<'a>(
|
pub fn create_warn<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
warning: impl IntoDiagnostic<'a, ()>,
|
warning: impl IntoDiagnostic<'a, ()>,
|
||||||
) -> DiagnosticBuilder<'a, ()> {
|
) -> DiagnosticBuilder<'a, ()> {
|
||||||
|
@ -1094,8 +1098,8 @@ impl DiagCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
pub fn emit_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
||||||
self.create_warning(warning).emit()
|
self.create_warn(warning).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -1227,7 +1231,7 @@ impl DiagCtxt {
|
||||||
// Note: we prefer implementing operations on `DiagCtxt`, rather than
|
// Note: we prefer implementing operations on `DiagCtxt`, rather than
|
||||||
// `DiagCtxtInner`, whenever possible. This minimizes functions where
|
// `DiagCtxtInner`, whenever possible. This minimizes functions where
|
||||||
// `DiagCtxt::foo()` just borrows `inner` and forwards a call to
|
// `DiagCtxt::foo()` just borrows `inner` and forwards a call to
|
||||||
// `HanderInner::foo`.
|
// `DiagCtxtInner::foo`.
|
||||||
impl DiagCtxtInner {
|
impl DiagCtxtInner {
|
||||||
/// Emit all stashed diagnostics.
|
/// Emit all stashed diagnostics.
|
||||||
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
|
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
|
||||||
|
|
|
@ -180,7 +180,7 @@ impl<'a, 'cx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'a, 'cx,
|
||||||
}
|
}
|
||||||
Error(err_sp, msg) => {
|
Error(err_sp, msg) => {
|
||||||
let span = err_sp.substitute_dummy(self.root_span);
|
let span = err_sp.substitute_dummy(self.root_span);
|
||||||
self.cx.dcx().struct_span_err(span, msg.clone()).emit();
|
self.cx.dcx().span_err(span, msg.clone());
|
||||||
self.result = Some(DummyResult::any(span));
|
self.result = Some(DummyResult::any(span));
|
||||||
}
|
}
|
||||||
ErrorReported(_) => self.result = Some(DummyResult::any(self.root_span)),
|
ErrorReported(_) => self.result = Some(DummyResult::any(self.root_span)),
|
||||||
|
|
|
@ -680,7 +680,7 @@ impl TtParser {
|
||||||
// edition-specific matching behavior for non-terminals.
|
// edition-specific matching behavior for non-terminals.
|
||||||
let nt = match parser.to_mut().parse_nonterminal(kind) {
|
let nt = match parser.to_mut().parse_nonterminal(kind) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let guarantee = err.span_label_mv(
|
let guarantee = err.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"while parsing argument for this `{kind}` macro fragment"
|
"while parsing argument for this `{kind}` macro fragment"
|
||||||
|
|
|
@ -458,7 +458,7 @@ pub fn compile_declarative_macro(
|
||||||
return dummy_syn_ext();
|
return dummy_syn_ext();
|
||||||
}
|
}
|
||||||
Error(sp, msg) => {
|
Error(sp, msg) => {
|
||||||
sess.dcx().struct_span_err(sp.substitute_dummy(def.span), msg).emit();
|
sess.dcx().span_err(sp.substitute_dummy(def.span), msg);
|
||||||
return dummy_syn_ext();
|
return dummy_syn_ext();
|
||||||
}
|
}
|
||||||
ErrorReported(_) => {
|
ErrorReported(_) => {
|
||||||
|
|
|
@ -86,7 +86,7 @@ pub(super) fn parse(
|
||||||
);
|
);
|
||||||
sess.dcx
|
sess.dcx
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.help_mv(VALID_FRAGMENT_NAMES_MSG)
|
.with_help(VALID_FRAGMENT_NAMES_MSG)
|
||||||
.emit();
|
.emit();
|
||||||
token::NonterminalKind::Ident
|
token::NonterminalKind::Ident
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
|
@ -305,7 +305,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||||
binding.span,
|
binding.span,
|
||||||
format!("{} `{}` is private", assoc_item.kind, binding.item_name),
|
format!("{} `{}` is private", assoc_item.kind, binding.item_name),
|
||||||
)
|
)
|
||||||
.span_label_mv(binding.span, format!("private {}", assoc_item.kind))
|
.with_span_label(binding.span, format!("private {}", assoc_item.kind))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
tcx.check_stability(assoc_item.def_id, Some(hir_ref_id), binding.span, None);
|
tcx.check_stability(assoc_item.def_id, Some(hir_ref_id), binding.span, None);
|
||||||
|
@ -462,7 +462,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||||
late_bound_in_trait_ref,
|
late_bound_in_trait_ref,
|
||||||
late_bound_in_ty,
|
late_bound_in_ty,
|
||||||
|br_name| {
|
|br_name| {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
binding.span,
|
binding.span,
|
||||||
E0582,
|
E0582,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::fluent_generated as fluent;
|
||||||
use crate::traits::error_reporting::report_object_safety_error;
|
use crate::traits::error_reporting::report_object_safety_error;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
|
||||||
use rustc_data_structures::unord::UnordMap;
|
use rustc_data_structures::unord::UnordMap;
|
||||||
use rustc_errors::{pluralize, struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
|
use rustc_errors::{pluralize, struct_span_code_err, Applicability, Diagnostic, ErrorGuaranteed};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_infer::traits::FulfillmentError;
|
use rustc_infer::traits::FulfillmentError;
|
||||||
|
@ -346,7 +346,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
candidates: Vec<DefId>,
|
candidates: Vec<DefId>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.tcx().dcx(),
|
self.tcx().dcx(),
|
||||||
name.span,
|
name.span,
|
||||||
E0034,
|
E0034,
|
||||||
|
@ -445,7 +445,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
name.span,
|
name.span,
|
||||||
E0220,
|
E0220,
|
||||||
|
@ -697,7 +697,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let names = names.join(", ");
|
let names = names.join(", ");
|
||||||
|
|
||||||
trait_bound_spans.sort();
|
trait_bound_spans.sort();
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
trait_bound_spans,
|
trait_bound_spans,
|
||||||
E0191,
|
E0191,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::astconv::{
|
||||||
};
|
};
|
||||||
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
||||||
use rustc_ast::ast::ParamKindOrd;
|
use rustc_ast::ast::ParamKindOrd;
|
||||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
|
use rustc_errors::{struct_span_code_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -27,7 +27,7 @@ fn generic_arg_mismatch_err(
|
||||||
help: Option<String>,
|
help: Option<String>,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
let sess = tcx.sess;
|
let sess = tcx.sess;
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
arg.span(),
|
arg.span(),
|
||||||
E0747,
|
E0747,
|
||||||
|
@ -70,7 +70,7 @@ fn generic_arg_mismatch_err(
|
||||||
Res::Err => {
|
Res::Err => {
|
||||||
add_braces_suggestion(arg, &mut err);
|
add_braces_suggestion(arg, &mut err);
|
||||||
return err
|
return err
|
||||||
.primary_message_mv("unresolved item provided when a constant was expected")
|
.with_primary_message("unresolved item provided when a constant was expected")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
Res::Def(DefKind::TyParam, src_def_id) => {
|
Res::Def(DefKind::TyParam, src_def_id) => {
|
||||||
|
@ -650,8 +650,8 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
|
||||||
if position == GenericArgPosition::Value
|
if position == GenericArgPosition::Value
|
||||||
&& args.num_lifetime_params() != param_counts.lifetimes
|
&& args.num_lifetime_params() != param_counts.lifetimes
|
||||||
{
|
{
|
||||||
struct_span_err!(tcx.dcx(), span, E0794, "{}", msg)
|
struct_span_code_err!(tcx.dcx(), span, E0794, "{}", msg)
|
||||||
.span_note_mv(span_late, note)
|
.with_span_note(span_late, note)
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
let mut multispan = MultiSpan::from_span(span);
|
let mut multispan = MultiSpan::from_span(span);
|
||||||
|
|
|
@ -213,7 +213,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let msg = "trait objects must include the `dyn` keyword";
|
let msg = "trait objects must include the `dyn` keyword";
|
||||||
let label = "add `dyn` keyword before this trait";
|
let label = "add `dyn` keyword before this trait";
|
||||||
let mut diag =
|
let mut diag =
|
||||||
rustc_errors::struct_span_err!(tcx.dcx(), self_ty.span, E0782, "{}", msg);
|
rustc_errors::struct_span_code_err!(tcx.dcx(), self_ty.span, E0782, "{}", msg);
|
||||||
if self_ty.span.can_be_used_for_suggestions()
|
if self_ty.span.can_be_used_for_suggestions()
|
||||||
&& !self.maybe_lint_impl_trait(self_ty, &mut diag)
|
&& !self.maybe_lint_impl_trait(self_ty, &mut diag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,8 @@ use crate::require_c_abi_if_c_variadic;
|
||||||
use rustc_ast::TraitObjectSyntax;
|
use rustc_ast::TraitObjectSyntax;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
|
error_code, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder,
|
||||||
FatalError, MultiSpan,
|
ErrorGuaranteed, FatalError, MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
|
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
|
||||||
|
@ -866,7 +866,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
traits: &[String],
|
traits: &[String],
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
let mut err = struct_span_err!(self.tcx().dcx(), span, E0223, "ambiguous associated type");
|
let mut err =
|
||||||
|
struct_span_code_err!(self.tcx().dcx(), span, E0223, "ambiguous associated type");
|
||||||
if self
|
if self
|
||||||
.tcx()
|
.tcx()
|
||||||
.resolutions(())
|
.resolutions(())
|
||||||
|
@ -1313,7 +1314,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let msg = format!("expected type, found variant `{assoc_ident}`");
|
let msg = format!("expected type, found variant `{assoc_ident}`");
|
||||||
tcx.dcx().span_err(span, msg)
|
tcx.dcx().span_err(span, msg)
|
||||||
} else if qself_ty.is_enum() {
|
} else if qself_ty.is_enum() {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
assoc_ident.span,
|
assoc_ident.span,
|
||||||
E0599,
|
E0599,
|
||||||
|
@ -1354,7 +1355,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
reported
|
reported
|
||||||
} else if let ty::Alias(ty::Opaque, alias_ty) = qself_ty.kind() {
|
} else if let ty::Alias(ty::Opaque, alias_ty) = qself_ty.kind() {
|
||||||
// `<impl Trait as OtherTrait>::Assoc` makes no sense.
|
// `<impl Trait as OtherTrait>::Assoc` makes no sense.
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(alias_ty.def_id),
|
tcx.def_span(alias_ty.def_id),
|
||||||
E0667,
|
E0667,
|
||||||
|
@ -1617,9 +1618,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let def_span = tcx.def_span(item);
|
let def_span = tcx.def_span(item);
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.code_mv(rustc_errors::error_code!(E0624))
|
.with_code(rustc_errors::error_code!(E0624))
|
||||||
.span_label_mv(span, format!("private {kind}"))
|
.with_span_label(span, format!("private {kind}"))
|
||||||
.span_label_mv(def_span, format!("{kind} defined here"))
|
.with_span_label(def_span, format!("{kind} defined here"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
tcx.check_stability(item, Some(block), span, None);
|
tcx.check_stability(item, Some(block), span, None);
|
||||||
|
@ -1850,7 +1851,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
};
|
};
|
||||||
let last_span = *arg_spans.last().unwrap();
|
let last_span = *arg_spans.last().unwrap();
|
||||||
let span: MultiSpan = arg_spans.into();
|
let span: MultiSpan = arg_spans.into();
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.tcx().dcx(),
|
self.tcx().dcx(),
|
||||||
span,
|
span,
|
||||||
E0109,
|
E0109,
|
||||||
|
@ -2601,7 +2602,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(&output);
|
let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(&output);
|
||||||
|
|
||||||
self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| {
|
self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
decl.output.span(),
|
decl.output.span(),
|
||||||
E0581,
|
E0581,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::astconv::{GenericArgCountMismatch, GenericArgCountResult, OnlySelfBou
|
||||||
use crate::bounds::Bounds;
|
use crate::bounds::Bounds;
|
||||||
use crate::errors::TraitObjectDeclaredWithNoTraits;
|
use crate::errors::TraitObjectDeclaredWithNoTraits;
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -89,7 +89,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
if regular_traits.len() > 1 {
|
if regular_traits.len() > 1 {
|
||||||
let first_trait = ®ular_traits[0];
|
let first_trait = ®ular_traits[0];
|
||||||
let additional_trait = ®ular_traits[1];
|
let additional_trait = ®ular_traits[1];
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
additional_trait.bottom().1,
|
additional_trait.bottom().1,
|
||||||
E0225,
|
E0225,
|
||||||
|
@ -290,7 +290,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
|
|
||||||
if references_self {
|
if references_self {
|
||||||
let def_id = i.bottom().0.def_id();
|
let def_id = i.bottom().0.def_id();
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
i.bottom().1,
|
i.bottom().1,
|
||||||
E0038,
|
E0038,
|
||||||
|
@ -298,7 +298,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
tcx.def_descr(def_id),
|
tcx.def_descr(def_id),
|
||||||
tcx.item_name(def_id),
|
tcx.item_name(def_id),
|
||||||
)
|
)
|
||||||
.note_mv(
|
.with_note(
|
||||||
rustc_middle::traits::ObjectSafetyViolation::SupertraitSelf(smallvec![])
|
rustc_middle::traits::ObjectSafetyViolation::SupertraitSelf(smallvec![])
|
||||||
.error_msg(),
|
.error_msg(),
|
||||||
)
|
)
|
||||||
|
@ -375,7 +375,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
self.ast_region_to_region(lifetime, None)
|
self.ast_region_to_region(lifetime, None)
|
||||||
} else {
|
} else {
|
||||||
self.re_infer(None, span).unwrap_or_else(|| {
|
self.re_infer(None, span).unwrap_or_else(|| {
|
||||||
let err = struct_span_err!(
|
let err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0228,
|
E0228,
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
||||||
match tcx.sess.target.is_abi_supported(abi) {
|
match tcx.sess.target.is_abi_supported(abi) {
|
||||||
Some(true) => (),
|
Some(true) => (),
|
||||||
Some(false) => {
|
Some(false) => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0570,
|
E0570,
|
||||||
|
@ -58,7 +58,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
||||||
|
|
||||||
// This ABI is only allowed on function pointers
|
// This ABI is only allowed on function pointers
|
||||||
if abi == Abi::CCmseNonSecureCall {
|
if abi == Abi::CCmseNonSecureCall {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0781,
|
E0781,
|
||||||
|
@ -560,14 +560,14 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
(0, _) => ("const", "consts", None),
|
(0, _) => ("const", "consts", None),
|
||||||
_ => ("type or const", "types or consts", None),
|
_ => ("type or const", "types or consts", None),
|
||||||
};
|
};
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
item.span,
|
item.span,
|
||||||
E0044,
|
E0044,
|
||||||
"foreign items may not have {kinds} parameters",
|
"foreign items may not have {kinds} parameters",
|
||||||
)
|
)
|
||||||
.span_label_mv(item.span, format!("can't have {kinds} parameters"))
|
.with_span_label(item.span, format!("can't have {kinds} parameters"))
|
||||||
.help_mv(
|
.with_help(
|
||||||
// FIXME: once we start storing spans for type arguments, turn this
|
// FIXME: once we start storing spans for type arguments, turn this
|
||||||
// into a suggestion.
|
// into a suggestion.
|
||||||
format!(
|
format!(
|
||||||
|
@ -659,10 +659,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
||||||
if !tcx.is_impl_trait_in_trait(impl_item) {
|
if !tcx.is_impl_trait_in_trait(impl_item) {
|
||||||
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
||||||
} else {
|
} else {
|
||||||
tcx.dcx().span_delayed_bug(
|
tcx.dcx().delayed_bug(format!("parent item: {parent_impl:?} not marked as default"));
|
||||||
DUMMY_SP,
|
|
||||||
format!("parent item: {parent_impl:?} not marked as default"),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -687,7 +684,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||||
ty::ImplPolarity::Negative => {
|
ty::ImplPolarity::Negative => {
|
||||||
if let [first_item_ref, ..] = impl_item_refs {
|
if let [first_item_ref, ..] = impl_item_refs {
|
||||||
let first_item_span = tcx.def_span(first_item_ref);
|
let first_item_span = tcx.def_span(first_item_ref);
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
first_item_span,
|
first_item_span,
|
||||||
E0749,
|
E0749,
|
||||||
|
@ -804,10 +801,9 @@ fn check_impl_items_against_trait<'tcx>(
|
||||||
};
|
};
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(tcx.def_span(def_id), msg)
|
.struct_span_err(tcx.def_span(def_id), msg)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"specialization behaves in inconsistent and \
|
"specialization behaves in inconsistent and surprising ways with \
|
||||||
surprising ways with {feature}, \
|
{feature}, and for now is disallowed"
|
||||||
and for now is disallowed"
|
|
||||||
))
|
))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
@ -840,13 +836,13 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
||||||
{
|
{
|
||||||
let fields = &def.non_enum_variant().fields;
|
let fields = &def.non_enum_variant().fields;
|
||||||
if fields.is_empty() {
|
if fields.is_empty() {
|
||||||
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
struct_span_code_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
||||||
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
||||||
struct_span_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
struct_span_code_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
||||||
.span_label_mv(sp, "SIMD elements must have the same type")
|
.with_span_label(sp, "SIMD elements must have the same type")
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -858,10 +854,10 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
||||||
};
|
};
|
||||||
if let Some(len) = len {
|
if let Some(len) = len {
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
struct_span_code_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
||||||
return;
|
return;
|
||||||
} else if len > MAX_SIMD_LANES {
|
} else if len > MAX_SIMD_LANES {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
sp,
|
sp,
|
||||||
E0075,
|
E0075,
|
||||||
|
@ -884,7 +880,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
||||||
if matches!(t.kind(), ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_)) =>
|
if matches!(t.kind(), ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_)) =>
|
||||||
{ /* struct([f32; 4]) is ok */ }
|
{ /* struct([f32; 4]) is ok */ }
|
||||||
_ => {
|
_ => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
sp,
|
sp,
|
||||||
E0077,
|
E0077,
|
||||||
|
@ -907,7 +903,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||||
&& let Some(repr_pack) = repr.pack
|
&& let Some(repr_pack) = repr.pack
|
||||||
&& pack as u64 != repr_pack.bytes()
|
&& pack as u64 != repr_pack.bytes()
|
||||||
{
|
{
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
sp,
|
sp,
|
||||||
E0634,
|
E0634,
|
||||||
|
@ -918,7 +914,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if repr.align.is_some() {
|
if repr.align.is_some() {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
sp,
|
sp,
|
||||||
E0587,
|
E0587,
|
||||||
|
@ -927,7 +923,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
sp,
|
sp,
|
||||||
E0588,
|
E0588,
|
||||||
|
@ -1117,13 +1113,13 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
|
|
||||||
if def.variants().is_empty() {
|
if def.variants().is_empty() {
|
||||||
if let Some(attr) = tcx.get_attrs(def_id, sym::repr).next() {
|
if let Some(attr) = tcx.get_attrs(def_id, sym::repr).next() {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
attr.span,
|
attr.span,
|
||||||
E0084,
|
E0084,
|
||||||
"unsupported representation for zero-variant enum"
|
"unsupported representation for zero-variant enum"
|
||||||
)
|
)
|
||||||
.span_label_mv(tcx.def_span(def_id), "zero-variant enum")
|
.with_span_label(tcx.def_span(def_id), "zero-variant enum")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1152,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
let disr_non_unit = def.variants().iter().any(|var| !is_unit(var) && has_disr(var));
|
let disr_non_unit = def.variants().iter().any(|var| !is_unit(var) && has_disr(var));
|
||||||
|
|
||||||
if disr_non_unit || (disr_units && has_non_units) {
|
if disr_non_unit || (disr_units && has_non_units) {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
E0732,
|
E0732,
|
||||||
|
@ -1242,7 +1238,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
||||||
|
|
||||||
if discrs[i].1.val == discrs[o].1.val {
|
if discrs[i].1.val == discrs[o].1.val {
|
||||||
let err = error.get_or_insert_with(|| {
|
let err = error.get_or_insert_with(|| {
|
||||||
let mut ret = struct_span_err!(
|
let mut ret = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(adt.did()),
|
tcx.def_span(adt.did()),
|
||||||
E0081,
|
E0081,
|
||||||
|
@ -1309,8 +1305,14 @@ pub(super) fn check_type_params_are_used<'tcx>(
|
||||||
&& let ty::GenericParamDefKind::Type { .. } = param.kind
|
&& let ty::GenericParamDefKind::Type { .. } = param.kind
|
||||||
{
|
{
|
||||||
let span = tcx.def_span(param.def_id);
|
let span = tcx.def_span(param.def_id);
|
||||||
struct_span_err!(tcx.dcx(), span, E0091, "type parameter `{}` is unused", param.name,)
|
struct_span_code_err!(
|
||||||
.span_label_mv(span, "unused type parameter")
|
tcx.dcx(),
|
||||||
|
span,
|
||||||
|
E0091,
|
||||||
|
"type parameter `{}` is unused",
|
||||||
|
param.name,
|
||||||
|
)
|
||||||
|
.with_span_label(span, "unused type parameter")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1329,7 +1331,7 @@ fn opaque_type_cycle_error(
|
||||||
opaque_def_id: LocalDefId,
|
opaque_def_id: LocalDefId,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
let mut err = struct_span_err!(tcx.dcx(), span, E0720, "cannot resolve opaque type");
|
let mut err = struct_span_code_err!(tcx.dcx(), span, E0720, "cannot resolve opaque type");
|
||||||
|
|
||||||
let mut label = false;
|
let mut label = false;
|
||||||
if let Some((def_id, visitor)) = get_owner_return_paths(tcx, opaque_def_id) {
|
if let Some((def_id, visitor)) = get_owner_return_paths(tcx, opaque_def_id) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::potentially_plural_count;
|
||||||
use crate::errors::LifetimesOrBoundsMismatchOnTrait;
|
use crate::errors::LifetimesOrBoundsMismatchOnTrait;
|
||||||
use hir::def_id::{DefId, DefIdMap, LocalDefId};
|
use hir::def_id::{DefId, DefIdMap, LocalDefId};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, ErrorGuaranteed};
|
use rustc_errors::{pluralize, struct_span_code_err, Applicability, DiagnosticId, ErrorGuaranteed};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::intravisit;
|
use rustc_hir::intravisit;
|
||||||
|
@ -19,7 +19,7 @@ use rustc_middle::ty::{
|
||||||
self, GenericArgs, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
|
self, GenericArgs, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::{GenericParamDefKind, TyCtxt};
|
use rustc_middle::ty::{GenericParamDefKind, TyCtxt};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
||||||
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
|
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::{
|
use rustc_trait_selection::traits::{
|
||||||
|
@ -625,7 +625,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||||
match ocx.eq(&cause, param_env, trait_return_ty, impl_return_ty) {
|
match ocx.eq(&cause, param_env, trait_return_ty, impl_return_ty) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(terr) => {
|
Err(terr) => {
|
||||||
let mut diag = struct_span_err!(
|
let mut diag = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
cause.span(),
|
cause.span(),
|
||||||
E0053,
|
E0053,
|
||||||
|
@ -934,17 +934,15 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
||||||
return_span,
|
return_span,
|
||||||
"return type captures more lifetimes than trait definition",
|
"return type captures more lifetimes than trait definition",
|
||||||
)
|
)
|
||||||
.span_label_mv(self.tcx.def_span(def_id), "this lifetime was captured")
|
.with_span_label(self.tcx.def_span(def_id), "this lifetime was captured")
|
||||||
.span_note_mv(
|
.with_span_note(
|
||||||
self.tcx.def_span(self.def_id),
|
self.tcx.def_span(self.def_id),
|
||||||
"hidden type must only reference lifetimes captured by this impl trait",
|
"hidden type must only reference lifetimes captured by this impl trait",
|
||||||
)
|
)
|
||||||
.note_mv(format!("hidden type inferred to be `{}`", self.ty))
|
.with_note(format!("hidden type inferred to be `{}`", self.ty))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
_ => {
|
_ => self.tcx.dcx().delayed_bug("should've been able to remap region"),
|
||||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "should've been able to remap region")
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return Err(guar);
|
return Err(guar);
|
||||||
};
|
};
|
||||||
|
@ -972,7 +970,7 @@ fn report_trait_method_mismatch<'tcx>(
|
||||||
let (impl_err_span, trait_err_span) =
|
let (impl_err_span, trait_err_span) =
|
||||||
extract_spans_for_error_reporting(infcx, terr, &cause, impl_m, trait_m);
|
extract_spans_for_error_reporting(infcx, terr, &cause, impl_m, trait_m);
|
||||||
|
|
||||||
let mut diag = struct_span_err!(
|
let mut diag = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
impl_err_span,
|
impl_err_span,
|
||||||
E0053,
|
E0053,
|
||||||
|
@ -1217,7 +1215,7 @@ fn compare_self_type<'tcx>(
|
||||||
(false, true) => {
|
(false, true) => {
|
||||||
let self_descr = self_string(impl_m);
|
let self_descr = self_string(impl_m);
|
||||||
let impl_m_span = tcx.def_span(impl_m.def_id);
|
let impl_m_span = tcx.def_span(impl_m.def_id);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
impl_m_span,
|
impl_m_span,
|
||||||
E0185,
|
E0185,
|
||||||
|
@ -1237,7 +1235,7 @@ fn compare_self_type<'tcx>(
|
||||||
(true, false) => {
|
(true, false) => {
|
||||||
let self_descr = self_string(trait_m);
|
let self_descr = self_string(trait_m);
|
||||||
let impl_m_span = tcx.def_span(impl_m.def_id);
|
let impl_m_span = tcx.def_span(impl_m.def_id);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
impl_m_span,
|
impl_m_span,
|
||||||
E0186,
|
E0186,
|
||||||
|
@ -1303,8 +1301,7 @@ fn compare_number_of_generics<'tcx>(
|
||||||
// inheriting the generics from will also have mismatched arguments, and
|
// inheriting the generics from will also have mismatched arguments, and
|
||||||
// we'll report an error for that instead. Delay a bug for safety, though.
|
// we'll report an error for that instead. Delay a bug for safety, though.
|
||||||
if trait_.is_impl_trait_in_trait() {
|
if trait_.is_impl_trait_in_trait() {
|
||||||
return Err(tcx.dcx().span_delayed_bug(
|
return Err(tcx.dcx().delayed_bug(
|
||||||
rustc_span::DUMMY_SP,
|
|
||||||
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -1463,7 +1460,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| tcx.def_span(impl_m.def_id));
|
.unwrap_or_else(|| tcx.def_span(impl_m.def_id));
|
||||||
|
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
impl_span,
|
impl_span,
|
||||||
E0050,
|
E0050,
|
||||||
|
@ -1530,7 +1527,7 @@ fn compare_synthetic_generics<'tcx>(
|
||||||
let impl_def_id = impl_def_id.expect_local();
|
let impl_def_id = impl_def_id.expect_local();
|
||||||
let impl_span = tcx.def_span(impl_def_id);
|
let impl_span = tcx.def_span(impl_def_id);
|
||||||
let trait_span = tcx.def_span(trait_def_id);
|
let trait_span = tcx.def_span(trait_def_id);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
impl_span,
|
impl_span,
|
||||||
E0643,
|
E0643,
|
||||||
|
@ -1689,7 +1686,7 @@ fn compare_generic_param_kinds<'tcx>(
|
||||||
let param_impl_span = tcx.def_span(param_impl.def_id);
|
let param_impl_span = tcx.def_span(param_impl.def_id);
|
||||||
let param_trait_span = tcx.def_span(param_trait.def_id);
|
let param_trait_span = tcx.def_span(param_trait.def_id);
|
||||||
|
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
param_impl_span,
|
param_impl_span,
|
||||||
E0053,
|
E0053,
|
||||||
|
@ -1836,7 +1833,7 @@ fn compare_const_predicate_entailment<'tcx>(
|
||||||
let (ty, _) = tcx.hir().expect_impl_item(impl_ct_def_id).expect_const();
|
let (ty, _) = tcx.hir().expect_impl_item(impl_ct_def_id).expect_const();
|
||||||
cause.span = ty.span;
|
cause.span = ty.span;
|
||||||
|
|
||||||
let mut diag = struct_span_err!(
|
let mut diag = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
cause.span,
|
cause.span,
|
||||||
E0326,
|
E0326,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use rustc_middle::traits::{ObligationCause, Reveal};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
||||||
};
|
};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
use rustc_trait_selection::traits::{
|
use rustc_trait_selection::traits::{
|
||||||
elaborate, normalize_param_env_or_error, outlives_bounds::InferCtxtExt, ObligationCtxt,
|
elaborate, normalize_param_env_or_error, outlives_bounds::InferCtxtExt, ObligationCtxt,
|
||||||
};
|
};
|
||||||
|
@ -153,10 +153,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||||
trait_m_sig.inputs_and_output,
|
trait_m_sig.inputs_and_output,
|
||||||
));
|
));
|
||||||
if !ocx.select_all_or_error().is_empty() {
|
if !ocx.select_all_or_error().is_empty() {
|
||||||
tcx.dcx().span_delayed_bug(
|
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
|
||||||
DUMMY_SP,
|
|
||||||
"encountered errors when checking RPITIT refinement (selection)",
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let outlives_env = OutlivesEnvironment::with_bounds(
|
let outlives_env = OutlivesEnvironment::with_bounds(
|
||||||
|
@ -165,18 +162,12 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||||
);
|
);
|
||||||
let errors = infcx.resolve_regions(&outlives_env);
|
let errors = infcx.resolve_regions(&outlives_env);
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
tcx.dcx().span_delayed_bug(
|
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (regions)");
|
||||||
DUMMY_SP,
|
|
||||||
"encountered errors when checking RPITIT refinement (regions)",
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Resolve any lifetime variables that may have been introduced during normalization.
|
// Resolve any lifetime variables that may have been introduced during normalization.
|
||||||
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
||||||
tcx.dcx().span_delayed_bug(
|
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (resolution)");
|
||||||
DUMMY_SP,
|
|
||||||
"encountered errors when checking RPITIT refinement (resolution)",
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// We don't do any drop checking during hir typeck.
|
// We don't do any drop checking during hir typeck.
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::{struct_span_err, ErrorGuaranteed};
|
use rustc_errors::{struct_span_code_err, ErrorGuaranteed};
|
||||||
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
||||||
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
|
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
|
||||||
use rustc_middle::ty::util::CheckRegions;
|
use rustc_middle::ty::util::CheckRegions;
|
||||||
|
@ -88,8 +88,12 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
|
||||||
let drop_impl_span = tcx.def_span(drop_impl_did);
|
let drop_impl_span = tcx.def_span(drop_impl_did);
|
||||||
let item_span = tcx.def_span(self_type_did);
|
let item_span = tcx.def_span(self_type_did);
|
||||||
let self_descr = tcx.def_descr(self_type_did);
|
let self_descr = tcx.def_descr(self_type_did);
|
||||||
let mut err =
|
let mut err = struct_span_code_err!(
|
||||||
struct_span_err!(tcx.dcx(), drop_impl_span, E0366, "`Drop` impls cannot be specialized");
|
tcx.dcx(),
|
||||||
|
drop_impl_span,
|
||||||
|
E0366,
|
||||||
|
"`Drop` impls cannot be specialized"
|
||||||
|
);
|
||||||
match arg {
|
match arg {
|
||||||
ty::util::NotUniqueParam::DuplicateParam(arg) => {
|
ty::util::NotUniqueParam::DuplicateParam(arg) => {
|
||||||
err.note(format!("`{arg}` is mentioned multiple times"))
|
err.note(format!("`{arg}` is mentioned multiple times"))
|
||||||
|
@ -154,14 +158,14 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||||
let item_span = tcx.def_span(adt_def_id);
|
let item_span = tcx.def_span(adt_def_id);
|
||||||
let self_descr = tcx.def_descr(adt_def_id.to_def_id());
|
let self_descr = tcx.def_descr(adt_def_id.to_def_id());
|
||||||
guar = Some(
|
guar = Some(
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
error.root_obligation.cause.span,
|
error.root_obligation.cause.span,
|
||||||
E0367,
|
E0367,
|
||||||
"`Drop` impl requires `{root_predicate}` \
|
"`Drop` impl requires `{root_predicate}` \
|
||||||
but the {self_descr} it is implemented for does not",
|
but the {self_descr} it is implemented for does not",
|
||||||
)
|
)
|
||||||
.span_note_mv(item_span, "the implementor must specify the same requirement")
|
.with_span_note(item_span, "the implementor must specify the same requirement")
|
||||||
.emit(),
|
.emit(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -186,14 +190,14 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
guar = Some(
|
guar = Some(
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
error.origin().span(),
|
error.origin().span(),
|
||||||
E0367,
|
E0367,
|
||||||
"`Drop` impl requires `{outlives}` \
|
"`Drop` impl requires `{outlives}` \
|
||||||
but the {self_descr} it is implemented for does not",
|
but the {self_descr} it is implemented for does not",
|
||||||
)
|
)
|
||||||
.span_note_mv(item_span, "the implementor must specify the same requirement")
|
.with_span_note(item_span, "the implementor must specify the same requirement")
|
||||||
.emit(),
|
.emit(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::errors::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use hir::def_id::DefId;
|
use hir::def_id::DefId;
|
||||||
use rustc_errors::{struct_span_err, DiagnosticMessage};
|
use rustc_errors::{struct_span_code_err, DiagnosticMessage};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
|
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
|
@ -29,8 +29,8 @@ fn equate_intrinsic_type<'tcx>(
|
||||||
(own_counts, generics.span)
|
(own_counts, generics.span)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
struct_span_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
|
struct_span_code_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
|
||||||
.span_label_mv(it.span, "expected a function")
|
.with_span_label(it.span, "expected a function")
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -552,7 +552,7 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
|
||||||
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)),
|
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)),
|
||||||
_ => {
|
_ => {
|
||||||
let msg = format!("unrecognized platform-specific intrinsic function: `{name}`");
|
let msg = format!("unrecognized platform-specific intrinsic function: `{name}`");
|
||||||
tcx.dcx().struct_span_err(it.span, msg).emit();
|
tcx.dcx().span_err(it.span, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustc_hir as hir;
|
||||||
use rustc_middle::ty::{self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy};
|
use rustc_middle::ty::{self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy};
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::{Symbol, DUMMY_SP};
|
use rustc_span::Symbol;
|
||||||
use rustc_target::abi::FieldIdx;
|
use rustc_target::abi::FieldIdx;
|
||||||
use rustc_target::asm::{InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType};
|
use rustc_target::asm::{InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType};
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(expr.span, msg)
|
.struct_span_err(expr.span, msg)
|
||||||
.note_mv(
|
.with_note(
|
||||||
"only integers, floats, SIMD vectors, pointers and function pointers \
|
"only integers, floats, SIMD vectors, pointers and function pointers \
|
||||||
can be used as arguments for inline assembly",
|
can be used as arguments for inline assembly",
|
||||||
)
|
)
|
||||||
|
@ -171,7 +171,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(expr.span, msg)
|
.struct_span_err(expr.span, msg)
|
||||||
.note_mv(format!("`{ty}` does not implement the Copy trait"))
|
.with_note(format!("`{ty}` does not implement the Copy trait"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,9 +191,9 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(vec![in_expr.span, expr.span], msg)
|
.struct_span_err(vec![in_expr.span, expr.span], msg)
|
||||||
.span_label_mv(in_expr.span, format!("type `{in_expr_ty}`"))
|
.with_span_label(in_expr.span, format!("type `{in_expr_ty}`"))
|
||||||
.span_label_mv(expr.span, format!("type `{ty}`"))
|
.with_span_label(expr.span, format!("type `{ty}`"))
|
||||||
.note_mv(
|
.with_note(
|
||||||
"asm inout arguments must have the same type, \
|
"asm inout arguments must have the same type, \
|
||||||
unless they are both pointers or integers of the same size",
|
unless they are both pointers or integers of the same size",
|
||||||
)
|
)
|
||||||
|
@ -242,7 +242,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(expr.span, msg)
|
.struct_span_err(expr.span, msg)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"this is required to use type `{}` with register class `{}`",
|
"this is required to use type `{}` with register class `{}`",
|
||||||
ty,
|
ty,
|
||||||
reg_class.name(),
|
reg_class.name(),
|
||||||
|
@ -294,7 +294,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
pub fn check_asm(&self, asm: &hir::InlineAsm<'tcx>, enclosing_id: LocalDefId) {
|
pub fn check_asm(&self, asm: &hir::InlineAsm<'tcx>, enclosing_id: LocalDefId) {
|
||||||
let target_features = self.tcx.asm_target_features(enclosing_id.to_def_id());
|
let target_features = self.tcx.asm_target_features(enclosing_id.to_def_id());
|
||||||
let Some(asm_arch) = self.tcx.sess.asm_arch else {
|
let Some(asm_arch) = self.tcx.sess.asm_arch else {
|
||||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "target architecture does not support asm");
|
self.tcx.dcx().delayed_bug("target architecture does not support asm");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
|
for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
|
||||||
|
@ -325,7 +325,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
op.is_clobber(),
|
op.is_clobber(),
|
||||||
) {
|
) {
|
||||||
let msg = format!("cannot use register `{}`: {}", reg.name(), msg);
|
let msg = format!("cannot use register `{}`: {}", reg.name(), msg);
|
||||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
self.tcx.dcx().span_err(*op_sp, msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
reg_class.name(),
|
reg_class.name(),
|
||||||
feature
|
feature
|
||||||
);
|
);
|
||||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
self.tcx.dcx().span_err(*op_sp, msg);
|
||||||
// register isn't enabled, don't do more checks
|
// register isn't enabled, don't do more checks
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
.intersperse(", ")
|
.intersperse(", ")
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
);
|
);
|
||||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
self.tcx.dcx().span_err(*op_sp, msg);
|
||||||
// register isn't enabled, don't do more checks
|
// register isn't enabled, don't do more checks
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -459,11 +459,11 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(*op_sp, "invalid `sym` operand")
|
.struct_span_err(*op_sp, "invalid `sym` operand")
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
self.tcx.def_span(anon_const.def_id),
|
self.tcx.def_span(anon_const.def_id),
|
||||||
format!("is {} `{}`", ty.kind().article(), ty),
|
format!("is {} `{}`", ty.kind().article(), ty),
|
||||||
)
|
)
|
||||||
.help_mv(
|
.with_help(
|
||||||
"`sym` operands must refer to either a function or a static",
|
"`sym` operands must refer to either a function or a static",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
|
|
@ -78,7 +78,7 @@ use std::num::NonZeroU32;
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
use rustc_errors::{pluralize, struct_span_err, Diagnostic, DiagnosticBuilder};
|
use rustc_errors::{pluralize, struct_span_code_err, Diagnostic, DiagnosticBuilder};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_index::bit_set::BitSet;
|
use rustc_index::bit_set::BitSet;
|
||||||
|
|
|
@ -3,7 +3,9 @@ use crate::constrained_generic_params::{identify_constrained_generic_params, Par
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
|
use rustc_errors::{
|
||||||
|
pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
|
||||||
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
|
||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
|
@ -200,8 +202,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
||||||
res = Err(tcx
|
res = Err(tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(sp, "impls of auto traits cannot be default")
|
.struct_span_err(sp, "impls of auto traits cannot be default")
|
||||||
.span_labels_mv(impl_.defaultness_span, "default because of this")
|
.with_span_labels(impl_.defaultness_span, "default because of this")
|
||||||
.span_label_mv(sp, "auto trait")
|
.with_span_label(sp, "auto trait")
|
||||||
.emit());
|
.emit());
|
||||||
}
|
}
|
||||||
// We match on both `ty::ImplPolarity` and `ast::ImplPolarity` just to get the `!` span.
|
// We match on both `ty::ImplPolarity` and `ast::ImplPolarity` just to get the `!` span.
|
||||||
|
@ -217,7 +219,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
||||||
if let hir::Defaultness::Default { .. } = impl_.defaultness {
|
if let hir::Defaultness::Default { .. } = impl_.defaultness {
|
||||||
let mut spans = vec![span];
|
let mut spans = vec![span];
|
||||||
spans.extend(impl_.defaultness_span);
|
spans.extend(impl_.defaultness_span);
|
||||||
res = Err(struct_span_err!(
|
res = Err(struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
spans,
|
spans,
|
||||||
E0750,
|
E0750,
|
||||||
|
@ -502,19 +504,18 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
|
||||||
gat_item_hir.span,
|
gat_item_hir.span,
|
||||||
format!("missing required bound{} on `{}`", plural, gat_item_hir.ident),
|
format!("missing required bound{} on `{}`", plural, gat_item_hir.ident),
|
||||||
)
|
)
|
||||||
.span_suggestion_mv(
|
.with_span_suggestion(
|
||||||
gat_item_hir.generics.tail_span_for_predicate_suggestion(),
|
gat_item_hir.generics.tail_span_for_predicate_suggestion(),
|
||||||
format!("add the required where clause{plural}"),
|
format!("add the required where clause{plural}"),
|
||||||
suggestion,
|
suggestion,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"{bound} currently required to ensure that impls have maximum flexibility"
|
"{bound} currently required to ensure that impls have maximum flexibility"
|
||||||
))
|
))
|
||||||
.note_mv(
|
.with_note(
|
||||||
"we are soliciting feedback, see issue #87479 \
|
"we are soliciting feedback, see issue #87479 \
|
||||||
<https://github.com/rust-lang/rust/issues/87479> \
|
<https://github.com/rust-lang/rust/issues/87479> for more information",
|
||||||
for more information",
|
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
@ -837,8 +838,8 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
|
||||||
trait_should_be_self,
|
trait_should_be_self,
|
||||||
"associated item referring to unboxed trait object for its own trait",
|
"associated item referring to unboxed trait object for its own trait",
|
||||||
)
|
)
|
||||||
.span_label_mv(trait_name.span, "in this trait")
|
.with_span_label(trait_name.span, "in this trait")
|
||||||
.multipart_suggestion_mv(
|
.with_multipart_suggestion(
|
||||||
"you might have meant to use `Self` to refer to the implementing type",
|
"you might have meant to use `Self` to refer to the implementing type",
|
||||||
sugg,
|
sugg,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
|
@ -1116,7 +1117,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
|
||||||
|| matches!(trait_def.specialization_kind, TraitSpecializationKind::Marker)
|
|| matches!(trait_def.specialization_kind, TraitSpecializationKind::Marker)
|
||||||
{
|
{
|
||||||
for associated_def_id in &*tcx.associated_item_def_ids(def_id) {
|
for associated_def_id in &*tcx.associated_item_def_ids(def_id) {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(*associated_def_id),
|
tcx.def_span(*associated_def_id),
|
||||||
E0714,
|
E0714,
|
||||||
|
@ -1598,7 +1599,7 @@ fn check_method_receiver<'tcx>(
|
||||||
the `arbitrary_self_types` feature",
|
the `arbitrary_self_types` feature",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.help_mv(HELP_FOR_SELF_TYPE)
|
.with_help(HELP_FOR_SELF_TYPE)
|
||||||
.emit()
|
.emit()
|
||||||
} else {
|
} else {
|
||||||
// Report error; would not have worked with `arbitrary_self_types`.
|
// Report error; would not have worked with `arbitrary_self_types`.
|
||||||
|
@ -1610,9 +1611,9 @@ fn check_method_receiver<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn e0307(tcx: TyCtxt<'_>, span: Span, receiver_ty: Ty<'_>) -> ErrorGuaranteed {
|
fn e0307(tcx: TyCtxt<'_>, span: Span, receiver_ty: Ty<'_>) -> ErrorGuaranteed {
|
||||||
struct_span_err!(tcx.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
|
struct_span_code_err!(tcx.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
|
||||||
.note_mv("type of `self` must be `Self` or a type that dereferences to it")
|
.with_note("type of `self` must be `Self` or a type that dereferences to it")
|
||||||
.help_mv(HELP_FOR_SELF_TYPE)
|
.with_help(HELP_FOR_SELF_TYPE)
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1920,8 +1921,8 @@ fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), Error
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> {
|
fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> {
|
||||||
struct_span_err!(tcx.dcx(), span, E0392, "parameter `{param_name}` is never used")
|
struct_span_code_err!(tcx.dcx(), span, E0392, "parameter `{param_name}` is never used")
|
||||||
.span_label_mv(span, "unused parameter")
|
.with_span_label(span, "unused parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -70,15 +70,15 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
|
||||||
match seen_items.entry(norm_ident) {
|
match seen_items.entry(norm_ident) {
|
||||||
Entry::Occupied(entry) => {
|
Entry::Occupied(entry) => {
|
||||||
let former = entry.get();
|
let former = entry.get();
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.tcx.dcx(),
|
self.tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0592,
|
E0592,
|
||||||
"duplicate definitions with name `{}`",
|
"duplicate definitions with name `{}`",
|
||||||
ident,
|
ident,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("duplicate definitions for `{ident}`"))
|
.with_span_label(span, format!("duplicate definitions for `{ident}`"))
|
||||||
.span_label_mv(*former, format!("other definition for `{ident}`"))
|
.with_span_label(*former, format!("other definition for `{ident}`"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
|
@ -104,7 +104,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
|
||||||
|
|
||||||
if let Some(item2) = collision {
|
if let Some(item2) = collision {
|
||||||
let name = item1.ident(self.tcx).normalize_to_macros_2_0();
|
let name = item1.ident(self.tcx).normalize_to_macros_2_0();
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.tcx.dcx(),
|
self.tcx.dcx(),
|
||||||
self.tcx.def_span(item1.def_id),
|
self.tcx.def_span(item1.def_id),
|
||||||
E0592,
|
E0592,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// mappings. That mapping code resides here.
|
// mappings. That mapping code resides here.
|
||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use rustc_errors::{error_code, struct_span_err};
|
use rustc_errors::{error_code, struct_span_code_err};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
|
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
|
||||||
|
@ -45,7 +45,7 @@ fn enforce_trait_manually_implementable(
|
||||||
// Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
|
// Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
|
||||||
if tcx.trait_def(trait_def_id).deny_explicit_impl {
|
if tcx.trait_def(trait_def_id).deny_explicit_impl {
|
||||||
let trait_name = tcx.item_name(trait_def_id);
|
let trait_name = tcx.item_name(trait_def_id);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
impl_header_span,
|
impl_header_span,
|
||||||
E0322,
|
E0322,
|
||||||
|
@ -88,7 +88,7 @@ fn enforce_empty_impls_for_marker_traits(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(impl_def_id),
|
tcx.def_span(impl_def_id),
|
||||||
E0715,
|
E0715,
|
||||||
|
@ -173,7 +173,7 @@ fn check_object_overlap<'tcx>(
|
||||||
let mut supertrait_def_ids = traits::supertrait_def_ids(tcx, component_def_id);
|
let mut supertrait_def_ids = traits::supertrait_def_ids(tcx, component_def_id);
|
||||||
if supertrait_def_ids.any(|d| d == trait_def_id) {
|
if supertrait_def_ids.any(|d| d == trait_def_id) {
|
||||||
let span = tcx.def_span(impl_def_id);
|
let span = tcx.def_span(impl_def_id);
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0371,
|
E0371,
|
||||||
|
@ -181,7 +181,7 @@ fn check_object_overlap<'tcx>(
|
||||||
trait_ref.self_ty(),
|
trait_ref.self_ty(),
|
||||||
tcx.def_path_str(trait_def_id)
|
tcx.def_path_str(trait_def_id)
|
||||||
)
|
)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"`{}` automatically implements trait `{}`",
|
"`{}` automatically implements trait `{}`",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Unsafety checker: every impl either implements a trait defined in this
|
//! Unsafety checker: every impl either implements a trait defined in this
|
||||||
//! crate or pertains to a type defined in this crate.
|
//! crate or pertains to a type defined in this crate.
|
||||||
|
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::Unsafety;
|
use rustc_hir::Unsafety;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
@ -18,14 +18,14 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
impl_.generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle");
|
impl_.generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle");
|
||||||
match (trait_def.unsafety, unsafe_attr, impl_.unsafety, impl_.polarity) {
|
match (trait_def.unsafety, unsafe_attr, impl_.unsafety, impl_.polarity) {
|
||||||
(Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => {
|
(Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
E0199,
|
E0199,
|
||||||
"implementing the trait `{}` is not unsafe",
|
"implementing the trait `{}` is not unsafe",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
)
|
)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
item.span.with_hi(item.span.lo() + rustc_span::BytePos(7)),
|
item.span.with_hi(item.span.lo() + rustc_span::BytePos(7)),
|
||||||
"remove `unsafe` from this trait implementation",
|
"remove `unsafe` from this trait implementation",
|
||||||
"",
|
"",
|
||||||
|
@ -35,20 +35,20 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
(Unsafety::Unsafe, _, Unsafety::Normal, hir::ImplPolarity::Positive) => {
|
(Unsafety::Unsafe, _, Unsafety::Normal, hir::ImplPolarity::Positive) => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
E0200,
|
E0200,
|
||||||
"the trait `{}` requires an `unsafe impl` declaration",
|
"the trait `{}` requires an `unsafe impl` declaration",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
)
|
)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"the trait `{}` enforces invariants that the compiler can't check. \
|
"the trait `{}` enforces invariants that the compiler can't check. \
|
||||||
Review the trait documentation and make sure this implementation \
|
Review the trait documentation and make sure this implementation \
|
||||||
upholds those invariants before adding the `unsafe` keyword",
|
upholds those invariants before adding the `unsafe` keyword",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
))
|
))
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
item.span.shrink_to_lo(),
|
item.span.shrink_to_lo(),
|
||||||
"add `unsafe` to this trait implementation",
|
"add `unsafe` to this trait implementation",
|
||||||
"unsafe ",
|
"unsafe ",
|
||||||
|
@ -58,20 +58,20 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
(Unsafety::Normal, Some(attr_name), Unsafety::Normal, hir::ImplPolarity::Positive) => {
|
(Unsafety::Normal, Some(attr_name), Unsafety::Normal, hir::ImplPolarity::Positive) => {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
E0569,
|
E0569,
|
||||||
"requires an `unsafe impl` declaration due to `#[{}]` attribute",
|
"requires an `unsafe impl` declaration due to `#[{}]` attribute",
|
||||||
attr_name
|
attr_name
|
||||||
)
|
)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"the trait `{}` enforces invariants that the compiler can't check. \
|
"the trait `{}` enforces invariants that the compiler can't check. \
|
||||||
Review the trait documentation and make sure this implementation \
|
Review the trait documentation and make sure this implementation \
|
||||||
upholds those invariants before adding the `unsafe` keyword",
|
upholds those invariants before adding the `unsafe` keyword",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
))
|
))
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
item.span.shrink_to_lo(),
|
item.span.shrink_to_lo(),
|
||||||
"add `unsafe` to this trait implementation",
|
"add `unsafe` to this trait implementation",
|
||||||
"unsafe ",
|
"unsafe ",
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
use rustc_ast::walk_list;
|
use rustc_ast::walk_list;
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
|
@ -22,7 +22,7 @@ use rustc_middle::ty::{self, TyCtxt, TypeSuperVisitable, TypeVisitor};
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
use rustc_span::symbol::{sym, Ident};
|
use rustc_span::symbol::{sym, Ident};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
|
@ -335,13 +335,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||||
// though this may happen when we call `poly_trait_ref_binder_info` with
|
// though this may happen when we call `poly_trait_ref_binder_info` with
|
||||||
// an (erroneous, #113423) associated return type bound in an impl header.
|
// an (erroneous, #113423) associated return type bound in an impl header.
|
||||||
if !supertrait_bound_vars.is_empty() {
|
if !supertrait_bound_vars.is_empty() {
|
||||||
self.tcx.dcx().span_delayed_bug(
|
self.tcx.dcx().delayed_bug(format!(
|
||||||
DUMMY_SP,
|
|
||||||
format!(
|
|
||||||
"found supertrait lifetimes without a binder to append \
|
"found supertrait lifetimes without a binder to append \
|
||||||
them to: {supertrait_bound_vars:?}"
|
them to: {supertrait_bound_vars:?}"
|
||||||
),
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break (vec![], BinderScopeType::Normal);
|
break (vec![], BinderScopeType::Normal);
|
||||||
}
|
}
|
||||||
|
@ -737,7 +734,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
// Ensure that the parent of the def is an item, not HRTB
|
// Ensure that the parent of the def is an item, not HRTB
|
||||||
let parent_id = self.tcx.hir().parent_id(hir_id);
|
let parent_id = self.tcx.hir().parent_id(hir_id);
|
||||||
if !parent_id.is_owner() {
|
if !parent_id.is_owner() {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.tcx.dcx(),
|
self.tcx.dcx(),
|
||||||
lifetime.ident.span,
|
lifetime.ident.span,
|
||||||
E0657,
|
E0657,
|
||||||
|
@ -754,7 +751,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
lifetime.ident.span,
|
lifetime.ident.span,
|
||||||
"higher kinded lifetime bounds on nested opaque types are not supported yet",
|
"higher kinded lifetime bounds on nested opaque types are not supported yet",
|
||||||
)
|
)
|
||||||
.span_note_mv(self.tcx.def_span(def_id), "lifetime declared here")
|
.with_span_note(self.tcx.def_span(def_id), "lifetime declared here")
|
||||||
.emit();
|
.emit();
|
||||||
self.uninsert_lifetime_on_error(lifetime, def.unwrap());
|
self.uninsert_lifetime_on_error(lifetime, def.unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::constrained_generic_params as cgp;
|
||||||
use min_specialization::check_min_specialization;
|
use min_specialization::check_min_specialization;
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
|
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
|
@ -170,7 +170,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol) {
|
fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol) {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0207,
|
E0207,
|
||||||
|
|
|
@ -523,7 +523,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
||||||
fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> {
|
fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> {
|
||||||
let span = self.path_segment.ident.span;
|
let span = self.path_segment.ident.span;
|
||||||
let msg = self.create_error_message();
|
let msg = self.create_error_message();
|
||||||
self.tcx.dcx().struct_span_err(span, msg).code_mv(self.code())
|
self.tcx.dcx().struct_span_err(span, msg).with_code(self.code())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds the `expected 1 type argument / supplied 2 type arguments` message.
|
/// Builds the `expected 1 type argument / supplied 2 type arguments` message.
|
||||||
|
|
|
@ -402,7 +402,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
callee_expr.span,
|
callee_expr.span,
|
||||||
format!("evaluate({predicate:?}) = {result:?}"),
|
format!("evaluate({predicate:?}) = {result:?}"),
|
||||||
)
|
)
|
||||||
.span_label_mv(predicate_span, "predicate")
|
.with_span_label(predicate_span, "predicate")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||||
}
|
}
|
||||||
CastError::NeedViaInt => {
|
CastError::NeedViaInt => {
|
||||||
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
||||||
.help_mv("cast through an integer first")
|
.with_help("cast through an integer first")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
CastError::IllegalCast => {
|
CastError::IllegalCast => {
|
||||||
|
@ -277,7 +277,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||||
}
|
}
|
||||||
CastError::DifferingKinds => {
|
CastError::DifferingKinds => {
|
||||||
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
||||||
.note_mv("vtable kinds may not match")
|
.with_note("vtable kinds may not match")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
CastError::CastToBool => {
|
CastError::CastToBool => {
|
||||||
|
@ -512,7 +512,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||||
self.cast_ty,
|
self.cast_ty,
|
||||||
fcx,
|
fcx,
|
||||||
)
|
)
|
||||||
.note_mv("cannot cast an enum with a non-exhaustive variant when it's defined in another crate")
|
.with_note("cannot cast an enum with a non-exhaustive variant when it's defined in another crate")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use crate::FnCtxt;
|
use crate::FnCtxt;
|
||||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan};
|
use rustc_errors::{struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
|
@ -1571,7 +1571,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
let mut visitor = CollectRetsVisitor { ret_exprs: vec![] };
|
let mut visitor = CollectRetsVisitor { ret_exprs: vec![] };
|
||||||
match *cause.code() {
|
match *cause.code() {
|
||||||
ObligationCauseCode::ReturnNoExpression => {
|
ObligationCauseCode::ReturnNoExpression => {
|
||||||
err = struct_span_err!(
|
err = struct_span_code_err!(
|
||||||
fcx.dcx(),
|
fcx.dcx(),
|
||||||
cause.span,
|
cause.span,
|
||||||
E0069,
|
E0069,
|
||||||
|
|
|
@ -25,7 +25,7 @@ use rustc_ast as ast;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
pluralize, struct_span_err, AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder,
|
pluralize, struct_span_code_err, AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder,
|
||||||
DiagnosticId, ErrorGuaranteed, StashKey,
|
DiagnosticId, ErrorGuaranteed, StashKey,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -1760,7 +1760,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Make sure the programmer specified correct number of fields.
|
// Make sure the programmer specified correct number of fields.
|
||||||
if adt_kind == AdtKind::Union {
|
if adt_kind == AdtKind::Union {
|
||||||
if ast_fields.len() != 1 {
|
if ast_fields.len() != 1 {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0784,
|
E0784,
|
||||||
|
@ -1967,7 +1967,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0063,
|
E0063,
|
||||||
|
@ -2194,7 +2194,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut err = self.err_ctxt().type_error_struct_with_diag(
|
let mut err = self.err_ctxt().type_error_struct_with_diag(
|
||||||
field.ident.span,
|
field.ident.span,
|
||||||
|actual| match ty.kind() {
|
|actual| match ty.kind() {
|
||||||
ty::Adt(adt, ..) if adt.is_enum() => struct_span_err!(
|
ty::Adt(adt, ..) if adt.is_enum() => struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
field.ident.span,
|
field.ident.span,
|
||||||
E0559,
|
E0559,
|
||||||
|
@ -2204,7 +2204,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
variant.name,
|
variant.name,
|
||||||
field.ident
|
field.ident
|
||||||
),
|
),
|
||||||
_ => struct_span_err!(
|
_ => struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
field.ident.span,
|
field.ident.span,
|
||||||
E0560,
|
E0560,
|
||||||
|
@ -2832,13 +2832,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
fn private_field_err(&self, field: Ident, base_did: DefId) -> DiagnosticBuilder<'_> {
|
fn private_field_err(&self, field: Ident, base_did: DefId) -> DiagnosticBuilder<'_> {
|
||||||
let struct_path = self.tcx().def_path_str(base_did);
|
let struct_path = self.tcx().def_path_str(base_did);
|
||||||
let kind_name = self.tcx().def_descr(base_did);
|
let kind_name = self.tcx().def_descr(base_did);
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
field.span,
|
field.span,
|
||||||
E0616,
|
E0616,
|
||||||
"field `{field}` of {kind_name} `{struct_path}` is private",
|
"field `{field}` of {kind_name} `{struct_path}` is private",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "private field")
|
.with_span_label(field.span, "private field")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_field_candidates_considering_privacy(
|
pub(crate) fn get_field_candidates_considering_privacy(
|
||||||
|
@ -3181,7 +3181,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if !is_input && !expr.is_syntactic_place_expr() {
|
if !is_input && !expr.is_syntactic_place_expr() {
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_err(expr.span, "invalid asm output")
|
.struct_span_err(expr.span, "invalid asm output")
|
||||||
.span_label_mv(expr.span, "cannot assign to this expression")
|
.with_span_label(expr.span, "cannot assign to this expression")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3282,7 +3282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
E0599,
|
E0599,
|
||||||
"no variant named `{ident}` found for enum `{container}`",
|
"no variant named `{ident}` found for enum `{container}`",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "variant not found")
|
.with_span_label(field.span, "variant not found")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
@ -3294,7 +3294,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
E0795,
|
E0795,
|
||||||
"`{ident}` is an enum variant; expected field at end of `offset_of`",
|
"`{ident}` is an enum variant; expected field at end of `offset_of`",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "enum variant")
|
.with_span_label(field.span, "enum variant")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
@ -3313,8 +3313,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
E0609,
|
E0609,
|
||||||
"no field named `{subfield}` on enum variant `{container}::{ident}`",
|
"no field named `{subfield}` on enum variant `{container}::{ident}`",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "this enum variant...")
|
.with_span_label(field.span, "this enum variant...")
|
||||||
.span_label_mv(subident.span, "...does not have this field")
|
.with_span_label(subident.span, "...does not have this field")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,8 @@ use crate::method::MethodCallee;
|
||||||
use crate::TupleArgumentsFlag::*;
|
use crate::TupleArgumentsFlag::*;
|
||||||
use crate::{errors, Expectation::*};
|
use crate::{errors, Expectation::*};
|
||||||
use crate::{
|
use crate::{
|
||||||
struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, Needs, RawTy, TupleArgumentsFlag,
|
struct_span_code_err, BreakableCtxt, Diverges, Expectation, FnCtxt, Needs, RawTy,
|
||||||
|
TupleArgumentsFlag,
|
||||||
};
|
};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
|
@ -204,7 +205,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
_ => {
|
_ => {
|
||||||
// Otherwise, there's a mismatch, so clear out what we're expecting, and set
|
// Otherwise, there's a mismatch, so clear out what we're expecting, and set
|
||||||
// our input types to err_args so we don't blow up the error messages
|
// our input types to err_args so we don't blow up the error messages
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
call_span,
|
call_span,
|
||||||
E0059,
|
E0059,
|
||||||
|
@ -807,7 +808,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut err = if formal_and_expected_inputs.len() == provided_args.len() {
|
let mut err = if formal_and_expected_inputs.len() == provided_args.len() {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
full_call_span,
|
full_call_span,
|
||||||
E0308,
|
E0308,
|
||||||
|
@ -827,7 +828,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pluralize!("was", provided_args.len())
|
pluralize!("was", provided_args.len())
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.code_mv(DiagnosticId::Error(err_code.to_owned()))
|
.with_code(DiagnosticId::Error(err_code.to_owned()))
|
||||||
};
|
};
|
||||||
|
|
||||||
// As we encounter issues, keep track of what we want to provide for the suggestion
|
// As we encounter issues, keep track of what we want to provide for the suggestion
|
||||||
|
@ -1378,14 +1379,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// (issue #88844).
|
// (issue #88844).
|
||||||
guar
|
guar
|
||||||
}
|
}
|
||||||
_ => struct_span_err!(
|
_ => struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
path_span,
|
path_span,
|
||||||
E0071,
|
E0071,
|
||||||
"expected struct, variant or union type, found {}",
|
"expected struct, variant or union type, found {}",
|
||||||
ty.normalized.sort_string(self.tcx)
|
ty.normalized.sort_string(self.tcx)
|
||||||
)
|
)
|
||||||
.span_label_mv(path_span, "not a struct")
|
.with_span_label(path_span, "not a struct")
|
||||||
.emit(),
|
.emit(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use hir::HirId;
|
use hir::HirId;
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_index::Idx;
|
use rustc_index::Idx;
|
||||||
use rustc_middle::ty::layout::{LayoutError, SizeSkeleton};
|
use rustc_middle::ty::layout::{LayoutError, SizeSkeleton};
|
||||||
|
@ -73,10 +73,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to)
|
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to)
|
||||||
&& size_to == Pointer(dl.instruction_address_space).size(&tcx)
|
&& size_to == Pointer(dl.instruction_address_space).size(&tcx)
|
||||||
{
|
{
|
||||||
struct_span_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type")
|
struct_span_code_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type")
|
||||||
.note_mv(format!("source type: {from}"))
|
.with_note(format!("source type: {from}"))
|
||||||
.note_mv(format!("target type: {to}"))
|
.with_note(format!("target type: {to}"))
|
||||||
.help_mv("cast with `as` to a pointer instead")
|
.with_help("cast with `as` to a pointer instead")
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
Err(err) => err.to_string(),
|
Err(err) => err.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0512,
|
E0512,
|
||||||
|
|
|
@ -52,7 +52,7 @@ use crate::expectation::Expectation;
|
||||||
use crate::fn_ctxt::RawTy;
|
use crate::fn_ctxt::RawTy;
|
||||||
use crate::gather_locals::GatherLocalsVisitor;
|
use crate::gather_locals::GatherLocalsVisitor;
|
||||||
use rustc_data_structures::unord::UnordSet;
|
use rustc_data_structures::unord::UnordSet;
|
||||||
use rustc_errors::{struct_span_err, DiagnosticId, ErrorGuaranteed};
|
use rustc_errors::{struct_span_code_err, DiagnosticId, ErrorGuaranteed};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
|
@ -72,7 +72,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! type_error_struct {
|
macro_rules! type_error_struct {
|
||||||
($dcx:expr, $span:expr, $typ:expr, $code:ident, $($message:tt)*) => ({
|
($dcx:expr, $span:expr, $typ:expr, $code:ident, $($message:tt)*) => ({
|
||||||
let mut err = rustc_errors::struct_span_err!($dcx, $span, $code, $($message)*);
|
let mut err = rustc_errors::struct_span_code_err!($dcx, $span, $code, $($message)*);
|
||||||
|
|
||||||
if $typ.references_error() {
|
if $typ.references_error() {
|
||||||
err.downgrade_to_delayed_bug();
|
err.downgrade_to_delayed_bug();
|
||||||
|
@ -369,14 +369,14 @@ fn report_unexpected_variant_res(
|
||||||
let err = tcx
|
let err = tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(span, format!("expected {expected}, found {res_descr} `{path_str}`"))
|
.struct_span_err(span, format!("expected {expected}, found {res_descr} `{path_str}`"))
|
||||||
.code_mv(DiagnosticId::Error(err_code.into()));
|
.with_code(DiagnosticId::Error(err_code.into()));
|
||||||
match res {
|
match res {
|
||||||
Res::Def(DefKind::Fn | DefKind::AssocFn, _) if err_code == "E0164" => {
|
Res::Def(DefKind::Fn | DefKind::AssocFn, _) if err_code == "E0164" => {
|
||||||
let patterns_url = "https://doc.rust-lang.org/book/ch18-00-patterns.html";
|
let patterns_url = "https://doc.rust-lang.org/book/ch18-00-patterns.html";
|
||||||
err.span_label_mv(span, "`fn` calls are not allowed in patterns")
|
err.with_span_label(span, "`fn` calls are not allowed in patterns")
|
||||||
.help_mv(format!("for more information, visit {patterns_url}"))
|
.with_help(format!("for more information, visit {patterns_url}"))
|
||||||
}
|
}
|
||||||
_ => err.span_label_mv(span, format!("not a {expected}")),
|
_ => err.with_span_label(span, format!("not a {expected}")),
|
||||||
}
|
}
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
use rustc_data_structures::unord::UnordSet;
|
use rustc_data_structures::unord::UnordSet;
|
||||||
use rustc_errors::StashKey;
|
use rustc_errors::StashKey;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan,
|
pluralize, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
|
@ -148,7 +148,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodError::Ambiguity(mut sources) => {
|
MethodError::Ambiguity(mut sources) => {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
item_name.span,
|
item_name.span,
|
||||||
E0034,
|
E0034,
|
||||||
|
@ -171,7 +171,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
MethodError::PrivateMatch(kind, def_id, out_of_scope_traits) => {
|
MethodError::PrivateMatch(kind, def_id, out_of_scope_traits) => {
|
||||||
let kind = self.tcx.def_kind_descr(kind, def_id);
|
let kind = self.tcx.def_kind_descr(kind, def_id);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
item_name.span,
|
item_name.span,
|
||||||
E0624,
|
E0624,
|
||||||
|
@ -263,8 +263,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) -> DiagnosticBuilder<'_> {
|
) -> DiagnosticBuilder<'_> {
|
||||||
let mut file = None;
|
let mut file = None;
|
||||||
let ty_str = self.tcx.short_ty_string(rcvr_ty, &mut file);
|
let ty_str = self.tcx.short_ty_string(rcvr_ty, &mut file);
|
||||||
let mut err =
|
let mut err = struct_span_code_err!(
|
||||||
struct_span_err!(self.dcx(), rcvr_expr.span, E0599, "cannot write into `{}`", ty_str);
|
self.dcx(),
|
||||||
|
rcvr_expr.span,
|
||||||
|
E0599,
|
||||||
|
"cannot write into `{}`",
|
||||||
|
ty_str
|
||||||
|
);
|
||||||
err.span_note(
|
err.span_note(
|
||||||
rcvr_expr.span,
|
rcvr_expr.span,
|
||||||
"must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method",
|
"must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method",
|
||||||
|
@ -1836,7 +1841,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
&& !actual.has_concrete_skeleton()
|
&& !actual.has_concrete_skeleton()
|
||||||
&& let SelfSource::MethodCall(expr) = source
|
&& let SelfSource::MethodCall(expr) = source
|
||||||
{
|
{
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0689,
|
E0689,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use super::method::MethodCallee;
|
||||||
use super::{has_expected_num_generic_args, FnCtxt};
|
use super::{has_expected_num_generic_args, FnCtxt};
|
||||||
use crate::Expectation;
|
use crate::Expectation;
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
|
use rustc_errors::{struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||||
use rustc_infer::traits::ObligationCauseCode;
|
use rustc_infer::traits::ObligationCauseCode;
|
||||||
|
@ -306,7 +306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.map(|def_id| with_no_trimmed_paths!(self.tcx.def_path_str(def_id)));
|
.map(|def_id| with_no_trimmed_paths!(self.tcx.def_path_str(def_id)));
|
||||||
let (mut err, output_def_id) = match is_assign {
|
let (mut err, output_def_id) = match is_assign {
|
||||||
IsAssign::Yes => {
|
IsAssign::Yes => {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
expr.span,
|
expr.span,
|
||||||
E0368,
|
E0368,
|
||||||
|
@ -370,7 +370,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
})
|
})
|
||||||
.cloned()
|
.cloned()
|
||||||
});
|
});
|
||||||
let mut err = struct_span_err!(self.dcx(), op.span, E0369, "{message}");
|
let mut err =
|
||||||
|
struct_span_code_err!(self.dcx(), op.span, E0369, "{message}");
|
||||||
if !lhs_expr.span.eq(&rhs_expr.span) {
|
if !lhs_expr.span.eq(&rhs_expr.span) {
|
||||||
err.span_label(lhs_expr.span, lhs_ty.to_string());
|
err.span_label(lhs_expr.span, lhs_ty.to_string());
|
||||||
err.span_label(rhs_expr.span, rhs_ty.to_string());
|
err.span_label(rhs_expr.span, rhs_ty.to_string());
|
||||||
|
@ -788,7 +789,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
Err(errors) => {
|
Err(errors) => {
|
||||||
let actual = self.resolve_vars_if_possible(operand_ty);
|
let actual = self.resolve_vars_if_possible(operand_ty);
|
||||||
let guar = actual.error_reported().err().unwrap_or_else(|| {
|
let guar = actual.error_reported().err().unwrap_or_else(|| {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
ex.span,
|
ex.span,
|
||||||
E0600,
|
E0600,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::{errors, FnCtxt, RawTy};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
|
pluralize, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
|
||||||
MultiSpan,
|
MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -546,7 +546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
(_, Some((true, _, sp))) => sp,
|
(_, Some((true, _, sp))) => sp,
|
||||||
_ => span_bug!(span, "emit_err_pat_range: no side failed or exists but still error?"),
|
_ => span_bug!(span, "emit_err_pat_range: no side failed or exists but still error?"),
|
||||||
};
|
};
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0029,
|
E0029,
|
||||||
|
@ -837,7 +837,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// This is "x = SomeTrait" being reduced from
|
// This is "x = SomeTrait" being reduced from
|
||||||
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
|
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
|
||||||
let type_str = self.ty_to_string(expected);
|
let type_str = self.ty_to_string(expected);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0033,
|
E0033,
|
||||||
|
@ -1171,7 +1171,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
let last_field_def_span = *field_def_spans.last().unwrap();
|
let last_field_def_span = *field_def_spans.last().unwrap();
|
||||||
|
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
MultiSpan::from_spans(subpat_spans),
|
MultiSpan::from_spans(subpat_spans),
|
||||||
E0023,
|
E0023,
|
||||||
|
@ -1516,7 +1516,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let has_shorthand_field_name = field_patterns.iter().any(|field| field.is_shorthand);
|
let has_shorthand_field_name = field_patterns.iter().any(|field| field.is_shorthand);
|
||||||
if has_shorthand_field_name {
|
if has_shorthand_field_name {
|
||||||
let path = rustc_hir_pretty::qpath_to_string(qpath);
|
let path = rustc_hir_pretty::qpath_to_string(qpath);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
pat.span,
|
pat.span,
|
||||||
E0769,
|
E0769,
|
||||||
|
@ -1541,13 +1541,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let sp_comma = sm.end_point(pat.span.with_hi(sp_brace.hi()));
|
let sp_comma = sm.end_point(pat.span.with_hi(sp_brace.hi()));
|
||||||
let sugg = if no_fields || sp_brace != sp_comma { ".. }" } else { ", .. }" };
|
let sugg = if no_fields || sp_brace != sp_comma { ".. }" } else { ", .. }" };
|
||||||
|
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
pat.span,
|
pat.span,
|
||||||
E0638,
|
E0638,
|
||||||
"`..` required with {descr} marked as non-exhaustive",
|
"`..` required with {descr} marked as non-exhaustive",
|
||||||
)
|
)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
sp_comma,
|
sp_comma,
|
||||||
"add `..` at the end of the field list to ignore all other fields",
|
"add `..` at the end of the field list to ignore all other fields",
|
||||||
sugg,
|
sugg,
|
||||||
|
@ -1562,15 +1562,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
other_field: Span,
|
other_field: Span,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0025,
|
E0025,
|
||||||
"field `{}` bound multiple times in the pattern",
|
"field `{}` bound multiple times in the pattern",
|
||||||
ident
|
ident
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("multiple uses of `{ident}` in pattern"))
|
.with_span_label(span, format!("multiple uses of `{ident}` in pattern"))
|
||||||
.span_label_mv(other_field, format!("first use of `{ident}`"))
|
.with_span_label(other_field, format!("first use of `{ident}`"))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1601,7 +1601,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let spans = inexistent_fields.iter().map(|field| field.ident.span).collect::<Vec<_>>();
|
let spans = inexistent_fields.iter().map(|field| field.ident.span).collect::<Vec<_>>();
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
spans,
|
spans,
|
||||||
E0026,
|
E0026,
|
||||||
|
@ -1698,7 +1698,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = rustc_hir_pretty::qpath_to_string(qpath);
|
let path = rustc_hir_pretty::qpath_to_string(qpath);
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
pat.span,
|
pat.span,
|
||||||
E0769,
|
E0769,
|
||||||
|
@ -1876,7 +1876,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.join(", ");
|
.join(", ");
|
||||||
format!("fields {fields}{inaccessible}")
|
format!("fields {fields}{inaccessible}")
|
||||||
};
|
};
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
pat.span,
|
pat.span,
|
||||||
E0027,
|
E0027,
|
||||||
|
@ -2226,7 +2226,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
min_len: u64,
|
min_len: u64,
|
||||||
size: u64,
|
size: u64,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0527,
|
E0527,
|
||||||
|
@ -2235,7 +2235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pluralize!(min_len),
|
pluralize!(min_len),
|
||||||
size,
|
size,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("expected {} element{}", size, pluralize!(size)))
|
.with_span_label(span, format!("expected {} element{}", size, pluralize!(size)))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2245,7 +2245,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
min_len: u64,
|
min_len: u64,
|
||||||
size: u64,
|
size: u64,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0528,
|
E0528,
|
||||||
|
@ -2254,7 +2254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pluralize!(min_len),
|
pluralize!(min_len),
|
||||||
size,
|
size,
|
||||||
)
|
)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!("pattern cannot match array of {} element{}", size, pluralize!(size),),
|
format!("pattern cannot match array of {} element{}", size, pluralize!(size),),
|
||||||
)
|
)
|
||||||
|
@ -2262,7 +2262,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error_scrutinee_unfixed_length(&self, span: Span) -> ErrorGuaranteed {
|
fn error_scrutinee_unfixed_length(&self, span: Span) -> ErrorGuaranteed {
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0730,
|
E0730,
|
||||||
|
@ -2277,7 +2277,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
expected_ty: Ty<'tcx>,
|
expected_ty: Ty<'tcx>,
|
||||||
ti: TopInfo<'tcx>,
|
ti: TopInfo<'tcx>,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
span,
|
span,
|
||||||
E0529,
|
E0529,
|
||||||
|
|
|
@ -336,10 +336,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
expr.span,
|
expr.span,
|
||||||
"not automatically applying `DerefMut` on `ManuallyDrop` union field",
|
"not automatically applying `DerefMut` on `ManuallyDrop` union field",
|
||||||
)
|
)
|
||||||
.help_mv(
|
.with_help(
|
||||||
"writing to this reference calls the destructor for the old value",
|
"writing to this reference calls the destructor for the old value",
|
||||||
)
|
)
|
||||||
.help_mv("add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor")
|
.with_help("add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ pub(crate) fn prepare_session_directory(
|
||||||
debug!("successfully copied data from: {}", source_directory.display());
|
debug!("successfully copied data from: {}", source_directory.display());
|
||||||
|
|
||||||
if !allows_links {
|
if !allows_links {
|
||||||
sess.dcx().emit_warning(errors::HardLinkFailed { path: &session_dir });
|
sess.dcx().emit_warn(errors::HardLinkFailed { path: &session_dir });
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.init_incr_comp_session(session_dir, directory_lock);
|
sess.init_incr_comp_session(session_dir, directory_lock);
|
||||||
|
@ -288,7 +288,7 @@ pub(crate) fn prepare_session_directory(
|
||||||
// Try to remove the session directory we just allocated. We don't
|
// Try to remove the session directory we just allocated. We don't
|
||||||
// know if there's any garbage in it from the failed copy action.
|
// know if there's any garbage in it from the failed copy action.
|
||||||
if let Err(err) = safe_remove_dir_all(&session_dir) {
|
if let Err(err) = safe_remove_dir_all(&session_dir) {
|
||||||
sess.dcx().emit_warning(errors::DeletePartial { path: &session_dir, err });
|
sess.dcx().emit_warn(errors::DeletePartial { path: &session_dir, err });
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_session_dir_lock_file(sess, &lock_file_path);
|
delete_session_dir_lock_file(sess, &lock_file_path);
|
||||||
|
@ -322,7 +322,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(err) = safe_remove_dir_all(&*incr_comp_session_dir) {
|
if let Err(err) = safe_remove_dir_all(&*incr_comp_session_dir) {
|
||||||
sess.dcx().emit_warning(errors::DeleteFull { path: &incr_comp_session_dir, err });
|
sess.dcx().emit_warn(errors::DeleteFull { path: &incr_comp_session_dir, err });
|
||||||
}
|
}
|
||||||
|
|
||||||
let lock_file_path = lock_file_path(&*incr_comp_session_dir);
|
let lock_file_path = lock_file_path(&*incr_comp_session_dir);
|
||||||
|
@ -365,7 +365,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Warn about the error. However, no need to abort compilation now.
|
// Warn about the error. However, no need to abort compilation now.
|
||||||
sess.dcx().emit_warning(errors::Finalize { path: &incr_comp_session_dir, err: e });
|
sess.dcx().emit_warn(errors::Finalize { path: &incr_comp_session_dir, err: e });
|
||||||
|
|
||||||
debug!("finalize_session_directory() - error, marking as invalid");
|
debug!("finalize_session_directory() - error, marking as invalid");
|
||||||
// Drop the file lock, so we can garage collect
|
// Drop the file lock, so we can garage collect
|
||||||
|
@ -500,7 +500,7 @@ fn lock_directory(
|
||||||
|
|
||||||
fn delete_session_dir_lock_file(sess: &Session, lock_file_path: &Path) {
|
fn delete_session_dir_lock_file(sess: &Session, lock_file_path: &Path) {
|
||||||
if let Err(err) = safe_remove_file(lock_file_path) {
|
if let Err(err) = safe_remove_file(lock_file_path) {
|
||||||
sess.dcx().emit_warning(errors::DeleteLock { path: lock_file_path, err });
|
sess.dcx().emit_warn(errors::DeleteLock { path: lock_file_path, err });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,7 +724,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
|
||||||
if !lock_file_to_session_dir.items().any(|(_, dir)| *dir == directory_name) {
|
if !lock_file_to_session_dir.items().any(|(_, dir)| *dir == directory_name) {
|
||||||
let path = crate_directory.join(directory_name);
|
let path = crate_directory.join(directory_name);
|
||||||
if let Err(err) = safe_remove_dir_all(&path) {
|
if let Err(err) = safe_remove_dir_all(&path) {
|
||||||
sess.dcx().emit_warning(errors::InvalidGcFailed { path: &path, err });
|
sess.dcx().emit_warn(errors::InvalidGcFailed { path: &path, err });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
|
||||||
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
|
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
|
||||||
|
|
||||||
if let Err(err) = safe_remove_dir_all(&path) {
|
if let Err(err) = safe_remove_dir_all(&path) {
|
||||||
sess.dcx().emit_warning(errors::FinalizedGcFailed { path: &path, err });
|
sess.dcx().emit_warn(errors::FinalizedGcFailed { path: &path, err });
|
||||||
} else {
|
} else {
|
||||||
delete_session_dir_lock_file(sess, &lock_file_path(&path));
|
delete_session_dir_lock_file(sess, &lock_file_path(&path));
|
||||||
}
|
}
|
||||||
|
@ -848,7 +848,7 @@ fn delete_old(sess: &Session, path: &Path) {
|
||||||
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
|
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
|
||||||
|
|
||||||
if let Err(err) = safe_remove_dir_all(path) {
|
if let Err(err) = safe_remove_dir_all(path) {
|
||||||
sess.dcx().emit_warning(errors::SessionGcFailed { path: path, err });
|
sess.dcx().emit_warn(errors::SessionGcFailed { path: path, err });
|
||||||
} else {
|
} else {
|
||||||
delete_session_dir_lock_file(sess, &lock_file_path(path));
|
delete_session_dir_lock_file(sess, &lock_file_path(path));
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl<T: Default> LoadResult<T> {
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
LoadResult::LoadDepGraph(path, err) => {
|
LoadResult::LoadDepGraph(path, err) => {
|
||||||
sess.dcx().emit_warning(errors::LoadDepGraph { path, err });
|
sess.dcx().emit_warn(errors::LoadDepGraph { path, err });
|
||||||
Default::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
LoadResult::DataOutOfDate => {
|
LoadResult::DataOutOfDate => {
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
||||||
let _ = saved_files.insert(ext.to_string(), file_name);
|
let _ = saved_files.insert(ext.to_string(), file_name);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
sess.dcx().emit_warning(errors::CopyWorkProductToCache {
|
sess.dcx().emit_warn(errors::CopyWorkProductToCache {
|
||||||
from: path,
|
from: path,
|
||||||
to: &path_in_incr_dir,
|
to: &path_in_incr_dir,
|
||||||
err,
|
err,
|
||||||
|
@ -50,7 +50,7 @@ pub(crate) fn delete_workproduct_files(sess: &Session, work_product: &WorkProduc
|
||||||
for (_, path) in work_product.saved_files.items().into_sorted_stable_ord() {
|
for (_, path) in work_product.saved_files.items().into_sorted_stable_ord() {
|
||||||
let path = in_incr_comp_dir_sess(sess, path);
|
let path = in_incr_comp_dir_sess(sess, path);
|
||||||
if let Err(err) = std_fs::remove_file(&path) {
|
if let Err(err) = std_fs::remove_file(&path) {
|
||||||
sess.dcx().emit_warning(errors::DeleteWorkProduct { path: &path, err });
|
sess.dcx().emit_warn(errors::DeleteWorkProduct { path: &path, err });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,10 +192,10 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
|
||||||
// rust-lang/rust#57464: `impl Trait` can leak local
|
// rust-lang/rust#57464: `impl Trait` can leak local
|
||||||
// scopes (in manner violating typeck). Therefore, use
|
// scopes (in manner violating typeck). Therefore, use
|
||||||
// `span_delayed_bug` to allow type error over an ICE.
|
// `span_delayed_bug` to allow type error over an ICE.
|
||||||
canonicalizer.tcx.dcx().span_delayed_bug(
|
canonicalizer
|
||||||
rustc_span::DUMMY_SP,
|
.tcx
|
||||||
format!("unexpected region in query response: `{r:?}`"),
|
.dcx()
|
||||||
);
|
.delayed_bug(format!("unexpected region in query response: `{r:?}`"));
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ use crate::traits::{
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, pluralize, struct_span_err, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder,
|
error_code, pluralize, struct_span_code_err, Applicability, DiagCtxt, Diagnostic,
|
||||||
DiagnosticStyledString, ErrorGuaranteed, IntoDiagnosticArg,
|
DiagnosticBuilder, DiagnosticStyledString, ErrorGuaranteed, IntoDiagnosticArg,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
|
@ -2780,7 +2780,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
infer::Nll(..) => bug!("NLL variable found in lexical phase"),
|
infer::Nll(..) => bug!("NLL variable found in lexical phase"),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.tcx.dcx(),
|
self.tcx.dcx(),
|
||||||
var_origin.span(),
|
var_origin.span(),
|
||||||
E0495,
|
E0495,
|
||||||
|
|
|
@ -368,7 +368,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
{
|
{
|
||||||
let span = *span;
|
let span = *span;
|
||||||
self.report_concrete_failure(placeholder_origin, sub, sup)
|
self.report_concrete_failure(placeholder_origin, sub, sup)
|
||||||
.span_note_mv(span, "the lifetime requirement is introduced here")
|
.with_span_note(span, "the lifetime requirement is introduced here")
|
||||||
} else {
|
} else {
|
||||||
unreachable!(
|
unreachable!(
|
||||||
"control flow ensures we have a `BindingObligation` or `ExprBindingObligation` here..."
|
"control flow ensures we have a `BindingObligation` or `ExprBindingObligation` here..."
|
||||||
|
|
|
@ -38,7 +38,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtx
|
||||||
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
|
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
|
||||||
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
|
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -1434,10 +1434,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
bug!("`{value:?}` is not fully resolved");
|
bug!("`{value:?}` is not fully resolved");
|
||||||
}
|
}
|
||||||
if value.has_infer_regions() {
|
if value.has_infer_regions() {
|
||||||
let guar = self
|
let guar =
|
||||||
.tcx
|
self.tcx.dcx().delayed_bug(format!("`{value:?}` is not fully resolved"));
|
||||||
.dcx()
|
|
||||||
.span_delayed_bug(DUMMY_SP, format!("`{value:?}` is not fully resolved"));
|
|
||||||
Ok(self.tcx.fold_regions(value, |re, _| {
|
Ok(self.tcx.fold_regions(value, |re, _| {
|
||||||
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
|
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use rustc_data_structures::undo_log::UndoLogs;
|
use rustc_data_structures::undo_log::UndoLogs;
|
||||||
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};
|
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};
|
||||||
use rustc_span::DUMMY_SP;
|
|
||||||
|
|
||||||
use crate::infer::{InferCtxtUndoLogs, UndoLog};
|
use crate::infer::{InferCtxtUndoLogs, UndoLog};
|
||||||
|
|
||||||
|
@ -40,9 +39,7 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
|
||||||
impl<'tcx> Drop for OpaqueTypeStorage<'tcx> {
|
impl<'tcx> Drop for OpaqueTypeStorage<'tcx> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if !self.opaque_types.is_empty() {
|
if !self.opaque_types.is_empty() {
|
||||||
ty::tls::with(|tcx| {
|
ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{:?}", self.opaque_types)));
|
||||||
tcx.dcx().span_delayed_bug(DUMMY_SP, format!("{:?}", self.opaque_types))
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,10 +175,9 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
||||||
// ignore this, we presume it will yield an error
|
// ignore this, we presume it will yield an error
|
||||||
// later, since if a type variable is not resolved by
|
// later, since if a type variable is not resolved by
|
||||||
// this point it never will be
|
// this point it never will be
|
||||||
self.tcx.dcx().span_delayed_bug(
|
self.tcx
|
||||||
rustc_span::DUMMY_SP,
|
.dcx()
|
||||||
format!("unresolved inference variable in outlives: {v:?}"),
|
.delayed_bug(format!("unresolved inference variable in outlives: {v:?}"));
|
||||||
);
|
|
||||||
// add a bound that never holds
|
// add a bound that never holds
|
||||||
VerifyBound::AnyBound(vec![])
|
VerifyBound::AnyBound(vec![])
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,10 +180,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
&mut OriginalQueryValues::default(),
|
&mut OriginalQueryValues::default(),
|
||||||
);
|
);
|
||||||
self.tcx.check_tys_might_be_eq(canonical).map_err(|_| {
|
self.tcx.check_tys_might_be_eq(canonical).map_err(|_| {
|
||||||
self.tcx.dcx().span_delayed_bug(
|
self.tcx.dcx().delayed_bug(format!(
|
||||||
DUMMY_SP,
|
"cannot relate consts of different types (a={a:?}, b={b:?})",
|
||||||
format!("cannot relate consts of different types (a={a:?}, b={b:?})",),
|
))
|
||||||
)
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::ObjectSafetyViolation;
|
||||||
|
|
||||||
use crate::infer::InferCtxt;
|
use crate::infer::InferCtxt;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, MultiSpan};
|
use rustc_errors::{struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_hir::intravisit::Map;
|
use rustc_hir::intravisit::Map;
|
||||||
|
@ -20,7 +20,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
trait_item_def_id: DefId,
|
trait_item_def_id: DefId,
|
||||||
requirement: &dyn fmt::Display,
|
requirement: &dyn fmt::Display,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
self.tcx.dcx(),
|
self.tcx.dcx(),
|
||||||
error_span,
|
error_span,
|
||||||
E0276,
|
E0276,
|
||||||
|
@ -52,7 +52,7 @@ pub fn report_object_safety_error<'tcx>(
|
||||||
hir::Node::Item(item) => Some(item.ident.span),
|
hir::Node::Item(item) => Some(item.ident.span),
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
span,
|
span,
|
||||||
E0038,
|
E0038,
|
||||||
|
|
|
@ -254,7 +254,7 @@ fn configure_and_expand(
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_proc_macro_crate && sess.panic_strategy() == PanicStrategy::Abort {
|
if is_proc_macro_crate && sess.panic_strategy() == PanicStrategy::Abort {
|
||||||
sess.dcx().emit_warning(errors::ProcMacroCratePanicAbort);
|
sess.dcx().emit_warn(errors::ProcMacroCratePanicAbort);
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.time("maybe_create_a_macro_crate", || {
|
sess.time("maybe_create_a_macro_crate", || {
|
||||||
|
|
|
@ -213,9 +213,8 @@ impl<'tcx> Queries<'tcx> {
|
||||||
|
|
||||||
// Some other attribute.
|
// Some other attribute.
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
tcx.dcx().emit_warning(RustcErrorUnexpectedAnnotation {
|
tcx.dcx()
|
||||||
span: tcx.def_span(def_id),
|
.emit_warn(RustcErrorUnexpectedAnnotation { span: tcx.def_span(def_id) });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,7 +431,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<C
|
||||||
|
|
||||||
base.retain(|crate_type| {
|
base.retain(|crate_type| {
|
||||||
if output::invalid_output_for_target(session, *crate_type) {
|
if output::invalid_output_for_target(session, *crate_type) {
|
||||||
session.dcx().emit_warning(errors::UnsupportedCrateTypeForTarget {
|
session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget {
|
||||||
crate_type: *crate_type,
|
crate_type: *crate_type,
|
||||||
target_triple: &session.opts.target_triple,
|
target_triple: &session.opts.target_triple,
|
||||||
});
|
});
|
||||||
|
@ -507,16 +507,16 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
|
||||||
let unnamed_output_types =
|
let unnamed_output_types =
|
||||||
sess.opts.output_types.values().filter(|a| a.is_none()).count();
|
sess.opts.output_types.values().filter(|a| a.is_none()).count();
|
||||||
let ofile = if unnamed_output_types > 1 {
|
let ofile = if unnamed_output_types > 1 {
|
||||||
sess.dcx().emit_warning(errors::MultipleOutputTypesAdaption);
|
sess.dcx().emit_warn(errors::MultipleOutputTypesAdaption);
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
if !sess.opts.cg.extra_filename.is_empty() {
|
if !sess.opts.cg.extra_filename.is_empty() {
|
||||||
sess.dcx().emit_warning(errors::IgnoringExtraFilename);
|
sess.dcx().emit_warn(errors::IgnoringExtraFilename);
|
||||||
}
|
}
|
||||||
Some(out_file.clone())
|
Some(out_file.clone())
|
||||||
};
|
};
|
||||||
if sess.io.output_dir != None {
|
if sess.io.output_dir != None {
|
||||||
sess.dcx().emit_warning(errors::IgnoringOutDir);
|
sess.dcx().emit_warn(errors::IgnoringOutDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
let out_filestem =
|
let out_filestem =
|
||||||
|
|
|
@ -14,7 +14,6 @@ use either::{Left, Right};
|
||||||
|
|
||||||
use rustc_ast::Mutability;
|
use rustc_ast::Mutability;
|
||||||
use rustc_data_structures::intern::Interned;
|
use rustc_data_structures::intern::Interned;
|
||||||
use rustc_span::DUMMY_SP;
|
|
||||||
use rustc_target::abi::{Align, HasDataLayout, Size};
|
use rustc_target::abi::{Align, HasDataLayout, Size};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -314,9 +313,7 @@ impl<Prov: Provenance, Bytes: AllocBytes> Allocation<Prov, (), Bytes> {
|
||||||
/// available to the compiler to do so.
|
/// available to the compiler to do so.
|
||||||
pub fn try_uninit<'tcx>(size: Size, align: Align) -> InterpResult<'tcx, Self> {
|
pub fn try_uninit<'tcx>(size: Size, align: Align) -> InterpResult<'tcx, Self> {
|
||||||
Self::uninit_inner(size, align, || {
|
Self::uninit_inner(size, align, || {
|
||||||
ty::tls::with(|tcx| {
|
ty::tls::with(|tcx| tcx.dcx().delayed_bug("exhausted memory during interpretation"));
|
||||||
tcx.dcx().span_delayed_bug(DUMMY_SP, "exhausted memory during interpretation")
|
|
||||||
});
|
|
||||||
InterpError::ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted).into()
|
InterpError::ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted).into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,7 +551,7 @@ macro_rules! define_feedable {
|
||||||
// We have an inconsistency. This can happen if one of the two
|
// We have an inconsistency. This can happen if one of the two
|
||||||
// results is tainted by errors. In this case, delay a bug to
|
// results is tainted by errors. In this case, delay a bug to
|
||||||
// ensure compilation is doomed, and keep the `old` value.
|
// ensure compilation is doomed, and keep the `old` value.
|
||||||
tcx.dcx().span_delayed_bug(DUMMY_SP, format!(
|
tcx.dcx().delayed_bug(format!(
|
||||||
"Trying to feed an already recorded value for query {} key={key:?}:\n\
|
"Trying to feed an already recorded value for query {} key={key:?}:\n\
|
||||||
old value: {old:?}\nnew value: {value:?}",
|
old value: {old:?}\nnew value: {value:?}",
|
||||||
stringify!($name),
|
stringify!($name),
|
||||||
|
|
|
@ -284,7 +284,7 @@ impl<'tcx> LayoutCalculator for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||||
type TargetDataLayoutRef = &'tcx TargetDataLayout;
|
type TargetDataLayoutRef = &'tcx TargetDataLayout;
|
||||||
|
|
||||||
fn delayed_bug(&self, txt: String) {
|
fn delayed_bug(&self, txt: String) {
|
||||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, txt);
|
self.tcx.dcx().delayed_bug(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_data_layout(&self) -> Self::TargetDataLayoutRef {
|
fn current_data_layout(&self) -> Self::TargetDataLayoutRef {
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
||||||
.tcx
|
.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(self.span, "non-defining opaque type use in defining scope")
|
.struct_span_err(self.span, "non-defining opaque type use in defining scope")
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
self.span,
|
self.span,
|
||||||
format!(
|
format!(
|
||||||
"lifetime `{r}` is part of concrete type but not used in \
|
"lifetime `{r}` is part of concrete type but not used in \
|
||||||
|
|
|
@ -369,7 +369,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if let Some((old_item_id, _)) = dtor_candidate {
|
if let Some((old_item_id, _)) = dtor_candidate {
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_err(self.def_span(item_id), "multiple drop impls found")
|
.struct_span_err(self.def_span(item_id), "multiple drop impls found")
|
||||||
.span_note_mv(self.def_span(old_item_id), "other impl here")
|
.with_span_note(self.def_span(old_item_id), "other impl here")
|
||||||
.delay_as_bug();
|
.delay_as_bug();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::dep_graph::dep_kinds;
|
use crate::dep_graph::dep_kinds;
|
||||||
use crate::query::plumbing::CyclePlaceholder;
|
use crate::query::plumbing::CyclePlaceholder;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
|
use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_middle::ty::Representability;
|
use rustc_middle::ty::Representability;
|
||||||
|
@ -175,7 +175,7 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
|
||||||
} else {
|
} else {
|
||||||
tcx.def_span(def_id)
|
tcx.def_span(def_id)
|
||||||
};
|
};
|
||||||
let mut diag = struct_span_err!(
|
let mut diag = struct_span_code_err!(
|
||||||
tcx.sess.dcx(),
|
tcx.sess.dcx(),
|
||||||
span,
|
span,
|
||||||
E0733,
|
E0733,
|
||||||
|
@ -309,7 +309,7 @@ pub fn recursive_type_error(
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
};
|
};
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
tcx.dcx(),
|
tcx.dcx(),
|
||||||
err_span,
|
err_span,
|
||||||
E0072,
|
E0072,
|
||||||
|
@ -318,7 +318,7 @@ pub fn recursive_type_error(
|
||||||
items_list,
|
items_list,
|
||||||
pluralize!("has", cycle_len),
|
pluralize!("has", cycle_len),
|
||||||
)
|
)
|
||||||
.multipart_suggestion_mv(
|
.with_multipart_suggestion(
|
||||||
"insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle",
|
"insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle",
|
||||||
suggestion,
|
suggestion,
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
|
|
|
@ -9,7 +9,6 @@ use rustc_middle::thir::*;
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, CanonicalUserType, CanonicalUserTypeAnnotation, TyCtxt, UserTypeAnnotationIndex,
|
self, CanonicalUserType, CanonicalUserTypeAnnotation, TyCtxt, UserTypeAnnotationIndex,
|
||||||
};
|
};
|
||||||
use rustc_span::DUMMY_SP;
|
|
||||||
use rustc_target::abi::Size;
|
use rustc_target::abi::Size;
|
||||||
|
|
||||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
|
@ -111,13 +110,13 @@ fn lit_to_mir_constant<'tcx>(
|
||||||
let LitToConstInput { lit, ty, neg } = lit_input;
|
let LitToConstInput { lit, ty, neg } = lit_input;
|
||||||
let trunc = |n| {
|
let trunc = |n| {
|
||||||
let param_ty = ty::ParamEnv::reveal_all().and(ty);
|
let param_ty = ty::ParamEnv::reveal_all().and(ty);
|
||||||
let width = tcx
|
let width =
|
||||||
.layout_of(param_ty)
|
tcx.layout_of(param_ty)
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||||
DUMMY_SP,
|
"couldn't compute width of literal: {:?}",
|
||||||
format!("couldn't compute width of literal: {:?}", lit_input.lit),
|
lit_input.lit
|
||||||
))
|
)))
|
||||||
})?
|
})?
|
||||||
.size;
|
.size;
|
||||||
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
||||||
|
@ -158,16 +157,16 @@ fn lit_to_mir_constant<'tcx>(
|
||||||
}
|
}
|
||||||
(ast::LitKind::Float(n, _), ty::Float(fty)) => parse_float_into_constval(*n, *fty, neg)
|
(ast::LitKind::Float(n, _), ty::Float(fty)) => parse_float_into_constval(*n, *fty, neg)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
LitToConstError::Reported(
|
||||||
DUMMY_SP,
|
tcx.dcx()
|
||||||
format!("couldn't parse float literal: {:?}", lit_input.lit),
|
.delayed_bug(format!("couldn't parse float literal: {:?}", lit_input.lit)),
|
||||||
))
|
)
|
||||||
})?,
|
})?,
|
||||||
(ast::LitKind::Bool(b), ty::Bool) => ConstValue::Scalar(Scalar::from_bool(*b)),
|
(ast::LitKind::Bool(b), ty::Bool) => ConstValue::Scalar(Scalar::from_bool(*b)),
|
||||||
(ast::LitKind::Char(c), ty::Char) => ConstValue::Scalar(Scalar::from_char(*c)),
|
(ast::LitKind::Char(c), ty::Char) => ConstValue::Scalar(Scalar::from_char(*c)),
|
||||||
(ast::LitKind::Err, _) => {
|
(ast::LitKind::Err, _) => {
|
||||||
return Err(LitToConstError::Reported(
|
return Err(LitToConstError::Reported(
|
||||||
tcx.dcx().span_delayed_bug(DUMMY_SP, "encountered LitKind::Err during mir build"),
|
tcx.dcx().delayed_bug("encountered LitKind::Err during mir build"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
_ => return Err(LitToConstError::TypeError),
|
_ => return Err(LitToConstError::TypeError),
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
|
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
|
||||||
use rustc_middle::ty::{self, ParamEnv, ScalarInt, TyCtxt};
|
use rustc_middle::ty::{self, ParamEnv, ScalarInt, TyCtxt};
|
||||||
use rustc_span::DUMMY_SP;
|
|
||||||
|
|
||||||
use crate::build::parse_float_into_scalar;
|
use crate::build::parse_float_into_scalar;
|
||||||
|
|
||||||
|
@ -13,13 +12,13 @@ pub(crate) fn lit_to_const<'tcx>(
|
||||||
|
|
||||||
let trunc = |n| {
|
let trunc = |n| {
|
||||||
let param_ty = ParamEnv::reveal_all().and(ty);
|
let param_ty = ParamEnv::reveal_all().and(ty);
|
||||||
let width = tcx
|
let width =
|
||||||
.layout_of(param_ty)
|
tcx.layout_of(param_ty)
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||||
DUMMY_SP,
|
"couldn't compute width of literal: {:?}",
|
||||||
format!("couldn't compute width of literal: {:?}", lit_input.lit),
|
lit_input.lit
|
||||||
))
|
)))
|
||||||
})?
|
})?
|
||||||
.size;
|
.size;
|
||||||
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
||||||
|
@ -60,12 +59,13 @@ pub(crate) fn lit_to_const<'tcx>(
|
||||||
}
|
}
|
||||||
(ast::LitKind::Bool(b), ty::Bool) => ty::ValTree::from_scalar_int((*b).into()),
|
(ast::LitKind::Bool(b), ty::Bool) => ty::ValTree::from_scalar_int((*b).into()),
|
||||||
(ast::LitKind::Float(n, _), ty::Float(fty)) => {
|
(ast::LitKind::Float(n, _), ty::Float(fty)) => {
|
||||||
let bits = parse_float_into_scalar(*n, *fty, neg)
|
let bits =
|
||||||
|
parse_float_into_scalar(*n, *fty, neg)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||||
DUMMY_SP,
|
"couldn't parse float literal: {:?}",
|
||||||
format!("couldn't parse float literal: {:?}", lit_input.lit),
|
lit_input.lit
|
||||||
))
|
)))
|
||||||
})?
|
})?
|
||||||
.assert_int();
|
.assert_int();
|
||||||
ty::ValTree::from_scalar_int(bits)
|
ty::ValTree::from_scalar_int(bits)
|
||||||
|
@ -73,7 +73,7 @@ pub(crate) fn lit_to_const<'tcx>(
|
||||||
(ast::LitKind::Char(c), ty::Char) => ty::ValTree::from_scalar_int((*c).into()),
|
(ast::LitKind::Char(c), ty::Char) => ty::ValTree::from_scalar_int((*c).into()),
|
||||||
(ast::LitKind::Err, _) => {
|
(ast::LitKind::Err, _) => {
|
||||||
return Err(LitToConstError::Reported(
|
return Err(LitToConstError::Reported(
|
||||||
tcx.dcx().span_delayed_bug(DUMMY_SP, "encountered LitKind::Err during mir build"),
|
tcx.dcx().delayed_bug("encountered LitKind::Err during mir build"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
_ => return Err(LitToConstError::TypeError),
|
_ => return Err(LitToConstError::TypeError),
|
||||||
|
|
|
@ -11,7 +11,9 @@ use rustc_arena::{DroplessArena, TypedArena};
|
||||||
use rustc_ast::Mutability;
|
use rustc_ast::Mutability;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
|
use rustc_errors::{
|
||||||
|
struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan,
|
||||||
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::*;
|
use rustc_hir::def::*;
|
||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
|
@ -55,7 +57,7 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBuilder<'_> {
|
fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBuilder<'_> {
|
||||||
struct_span_err!(sess.dcx(), sp, E0004, "{}", &error_message)
|
struct_span_code_err!(sess.dcx(), sp, E0004, "{}", &error_message)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
|
||||||
MonoItemCollectionMode::Eager
|
MonoItemCollectionMode::Eager
|
||||||
} else {
|
} else {
|
||||||
if mode != "lazy" {
|
if mode != "lazy" {
|
||||||
tcx.dcx().emit_warning(UnknownCguCollectionMode { mode });
|
tcx.dcx().emit_warn(UnknownCguCollectionMode { mode });
|
||||||
}
|
}
|
||||||
|
|
||||||
MonoItemCollectionMode::Lazy
|
MonoItemCollectionMode::Lazy
|
||||||
|
|
|
@ -250,7 +250,7 @@ impl<'a> StringReader<'a> {
|
||||||
if starts_with_number {
|
if starts_with_number {
|
||||||
let span = self.mk_sp(start, self.pos);
|
let span = self.mk_sp(start, self.pos);
|
||||||
self.dcx().struct_err("lifetimes cannot start with a number")
|
self.dcx().struct_err("lifetimes cannot start with a number")
|
||||||
.span_mv(span)
|
.with_span(span)
|
||||||
.stash(span, StashKey::LifetimeIsChar);
|
.stash(span, StashKey::LifetimeIsChar);
|
||||||
}
|
}
|
||||||
let ident = Symbol::intern(lifetime_name);
|
let ident = Symbol::intern(lifetime_name);
|
||||||
|
@ -397,7 +397,7 @@ impl<'a> StringReader<'a> {
|
||||||
if !terminated {
|
if !terminated {
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_fatal(self.mk_sp(start, end), "unterminated character literal")
|
.struct_span_fatal(self.mk_sp(start, end), "unterminated character literal")
|
||||||
.code_mv(error_code!(E0762))
|
.with_code(error_code!(E0762))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::Char, Mode::Char, start, end, 1, 1) // ' '
|
self.cook_quoted(token::Char, Mode::Char, start, end, 1, 1) // ' '
|
||||||
|
@ -409,7 +409,7 @@ impl<'a> StringReader<'a> {
|
||||||
self.mk_sp(start + BytePos(1), end),
|
self.mk_sp(start + BytePos(1), end),
|
||||||
"unterminated byte constant",
|
"unterminated byte constant",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0763))
|
.with_code(error_code!(E0763))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::Byte, Mode::Byte, start, end, 2, 1) // b' '
|
self.cook_quoted(token::Byte, Mode::Byte, start, end, 2, 1) // b' '
|
||||||
|
@ -421,7 +421,7 @@ impl<'a> StringReader<'a> {
|
||||||
self.mk_sp(start, end),
|
self.mk_sp(start, end),
|
||||||
"unterminated double quote string",
|
"unterminated double quote string",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0765))
|
.with_code(error_code!(E0765))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::Str, Mode::Str, start, end, 1, 1) // " "
|
self.cook_quoted(token::Str, Mode::Str, start, end, 1, 1) // " "
|
||||||
|
@ -433,7 +433,7 @@ impl<'a> StringReader<'a> {
|
||||||
self.mk_sp(start + BytePos(1), end),
|
self.mk_sp(start + BytePos(1), end),
|
||||||
"unterminated double quote byte string",
|
"unterminated double quote byte string",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0766))
|
.with_code(error_code!(E0766))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
|
self.cook_quoted(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
|
||||||
|
@ -445,7 +445,7 @@ impl<'a> StringReader<'a> {
|
||||||
self.mk_sp(start + BytePos(1), end),
|
self.mk_sp(start + BytePos(1), end),
|
||||||
"unterminated C string",
|
"unterminated C string",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0767))
|
.with_code(error_code!(E0767))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_c_string(token::CStr, Mode::CStr, start, end, 2, 1) // c" "
|
self.cook_c_string(token::CStr, Mode::CStr, start, end, 2, 1) // c" "
|
||||||
|
|
|
@ -264,14 +264,14 @@ pub(crate) fn emit_unescape_error(
|
||||||
}
|
}
|
||||||
EscapeError::UnskippedWhitespaceWarning => {
|
EscapeError::UnskippedWhitespaceWarning => {
|
||||||
let (c, char_span) = last_char();
|
let (c, char_span) = last_char();
|
||||||
dcx.emit_warning(UnescapeError::UnskippedWhitespace {
|
dcx.emit_warn(UnescapeError::UnskippedWhitespace {
|
||||||
span: err_span,
|
span: err_span,
|
||||||
ch: escaped_char(c),
|
ch: escaped_char(c),
|
||||||
char_span,
|
char_span,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
EscapeError::MultipleSkippedLinesWarning => {
|
EscapeError::MultipleSkippedLinesWarning => {
|
||||||
dcx.emit_warning(UnescapeError::MultipleSkippedLinesWarning(err_span));
|
dcx.emit_warn(UnescapeError::MultipleSkippedLinesWarning(err_span));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,8 +246,8 @@ pub fn parse_cfg_attr(
|
||||||
match parse_in(parse_sess, tokens.clone(), "`cfg_attr` input", |p| p.parse_cfg_attr()) {
|
match parse_in(parse_sess, tokens.clone(), "`cfg_attr` input", |p| p.parse_cfg_attr()) {
|
||||||
Ok(r) => return Some(r),
|
Ok(r) => return Some(r),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
e.help_mv(format!("the valid syntax is `{CFG_ATTR_GRAMMAR_HELP}`"))
|
e.with_help(format!("the valid syntax is `{CFG_ATTR_GRAMMAR_HELP}`"))
|
||||||
.note_mv(CFG_ATTR_NOTE_REF)
|
.with_note(CFG_ATTR_NOTE_REF)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,8 +204,11 @@ impl<'a> Parser<'a> {
|
||||||
attr_sp,
|
attr_sp,
|
||||||
fluent::parse_inner_attr_not_permitted_after_outer_doc_comment,
|
fluent::parse_inner_attr_not_permitted_after_outer_doc_comment,
|
||||||
)
|
)
|
||||||
.span_label_mv(attr_sp, fluent::parse_label_attr)
|
.with_span_label(attr_sp, fluent::parse_label_attr)
|
||||||
.span_label_mv(prev_doc_comment_span, fluent::parse_label_prev_doc_comment)
|
.with_span_label(
|
||||||
|
prev_doc_comment_span,
|
||||||
|
fluent::parse_label_prev_doc_comment,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Some(InnerAttrForbiddenReason::AfterOuterAttribute { prev_outer_attr_sp }) => self
|
Some(InnerAttrForbiddenReason::AfterOuterAttribute { prev_outer_attr_sp }) => self
|
||||||
.dcx()
|
.dcx()
|
||||||
|
@ -213,8 +216,8 @@ impl<'a> Parser<'a> {
|
||||||
attr_sp,
|
attr_sp,
|
||||||
fluent::parse_inner_attr_not_permitted_after_outer_attr,
|
fluent::parse_inner_attr_not_permitted_after_outer_attr,
|
||||||
)
|
)
|
||||||
.span_label_mv(attr_sp, fluent::parse_label_attr)
|
.with_span_label(attr_sp, fluent::parse_label_attr)
|
||||||
.span_label_mv(prev_outer_attr_sp, fluent::parse_label_prev_attr),
|
.with_span_label(prev_outer_attr_sp, fluent::parse_label_prev_attr),
|
||||||
Some(InnerAttrForbiddenReason::InCodeBlock) | None => {
|
Some(InnerAttrForbiddenReason::InCodeBlock) | None => {
|
||||||
self.dcx().struct_span_err(attr_sp, fluent::parse_inner_attr_not_permitted)
|
self.dcx().struct_span_err(attr_sp, fluent::parse_inner_attr_not_permitted)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2847,8 +2847,8 @@ impl<'a> Parser<'a> {
|
||||||
let span = label.ident.span.to(self.prev_token.span);
|
let span = label.ident.span.to(self.prev_token.span);
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_err(span, "block label not supported here")
|
.struct_span_err(span, "block label not supported here")
|
||||||
.span_label_mv(span, "not supported here")
|
.with_span_label(span, "not supported here")
|
||||||
.tool_only_span_suggestion_mv(
|
.with_tool_only_span_suggestion(
|
||||||
label.ident.span.until(self.token.span),
|
label.ident.span.until(self.token.span),
|
||||||
"remove this block label",
|
"remove this block label",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -1753,7 +1753,7 @@ impl<'a> Parser<'a> {
|
||||||
err: impl FnOnce(&Self) -> DiagnosticBuilder<'a>,
|
err: impl FnOnce(&Self) -> DiagnosticBuilder<'a>,
|
||||||
) -> L {
|
) -> L {
|
||||||
if let Some(diag) = self.dcx().steal_diagnostic(lifetime.span, StashKey::LifetimeIsChar) {
|
if let Some(diag) = self.dcx().steal_diagnostic(lifetime.span, StashKey::LifetimeIsChar) {
|
||||||
diag.span_suggestion_verbose_mv(
|
diag.with_span_suggestion_verbose(
|
||||||
lifetime.span.shrink_to_hi(),
|
lifetime.span.shrink_to_hi(),
|
||||||
"add `'` to close the char literal",
|
"add `'` to close the char literal",
|
||||||
"'",
|
"'",
|
||||||
|
@ -1762,7 +1762,7 @@ impl<'a> Parser<'a> {
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
err(self)
|
err(self)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
lifetime.span.shrink_to_hi(),
|
lifetime.span.shrink_to_hi(),
|
||||||
"add `'` to close the char literal",
|
"add `'` to close the char literal",
|
||||||
"'",
|
"'",
|
||||||
|
@ -2150,7 +2150,7 @@ impl<'a> Parser<'a> {
|
||||||
if [sym::i32, sym::u32, sym::isize, sym::usize].contains(&suffix) {
|
if [sym::i32, sym::u32, sym::isize, sym::usize].contains(&suffix) {
|
||||||
// #59553: warn instead of reject out of hand to allow the fix to percolate
|
// #59553: warn instead of reject out of hand to allow the fix to percolate
|
||||||
// through the ecosystem when people fix their macros
|
// through the ecosystem when people fix their macros
|
||||||
self.dcx().emit_warning(errors::InvalidLiteralSuffixOnTupleIndex {
|
self.dcx().emit_warn(errors::InvalidLiteralSuffixOnTupleIndex {
|
||||||
span,
|
span,
|
||||||
suffix,
|
suffix,
|
||||||
exception: Some(()),
|
exception: Some(()),
|
||||||
|
|
|
@ -145,7 +145,7 @@ impl<'a> Parser<'a> {
|
||||||
mistyped_const_ident.span,
|
mistyped_const_ident.span,
|
||||||
format!("`const` keyword was mistyped as `{}`", mistyped_const_ident.as_str()),
|
format!("`const` keyword was mistyped as `{}`", mistyped_const_ident.as_str()),
|
||||||
)
|
)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
mistyped_const_ident.span,
|
mistyped_const_ident.span,
|
||||||
"use the `const` keyword",
|
"use the `const` keyword",
|
||||||
kw::Const.as_str(),
|
kw::Const.as_str(),
|
||||||
|
|
|
@ -10,7 +10,7 @@ use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
|
||||||
use rustc_ast::util::case::Case;
|
use rustc_ast::util::case::Case;
|
||||||
use rustc_ast::{self as ast};
|
use rustc_ast::{self as ast};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_errors::{struct_span_err, Applicability, PResult, StashKey};
|
use rustc_errors::{struct_span_code_err, Applicability, PResult, StashKey};
|
||||||
use rustc_span::edit_distance::edit_distance;
|
use rustc_span::edit_distance::edit_distance;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::source_map;
|
use rustc_span::source_map;
|
||||||
|
@ -741,11 +741,11 @@ impl<'a> Parser<'a> {
|
||||||
Ok(Some(item)) => items.extend(item),
|
Ok(Some(item)) => items.extend(item),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.consume_block(Delimiter::Brace, ConsumeClosingDelim::Yes);
|
self.consume_block(Delimiter::Brace, ConsumeClosingDelim::Yes);
|
||||||
err.span_label_mv(
|
err.with_span_label(
|
||||||
open_brace_span,
|
open_brace_span,
|
||||||
"while parsing this item list starting here",
|
"while parsing this item list starting here",
|
||||||
)
|
)
|
||||||
.span_label_mv(self.prev_token.span, "the item list ends here")
|
.with_span_label(self.prev_token.span, "the item list ends here")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -759,14 +759,14 @@ impl<'a> Parser<'a> {
|
||||||
if let token::DocComment(..) = self.token.kind {
|
if let token::DocComment(..) = self.token.kind {
|
||||||
if self.look_ahead(1, |tok| tok == &token::CloseDelim(Delimiter::Brace)) {
|
if self.look_ahead(1, |tok| tok == &token::CloseDelim(Delimiter::Brace)) {
|
||||||
// FIXME: merge with `DocCommentDoesNotDocumentAnything` (E0585)
|
// FIXME: merge with `DocCommentDoesNotDocumentAnything` (E0585)
|
||||||
struct_span_err!(
|
struct_span_code_err!(
|
||||||
self.dcx(),
|
self.dcx(),
|
||||||
self.token.span,
|
self.token.span,
|
||||||
E0584,
|
E0584,
|
||||||
"found a documentation comment that doesn't document anything",
|
"found a documentation comment that doesn't document anything",
|
||||||
)
|
)
|
||||||
.span_label_mv(self.token.span, "this doc comment doesn't document anything")
|
.with_span_label(self.token.span, "this doc comment doesn't document anything")
|
||||||
.help_mv(
|
.with_help(
|
||||||
"doc comments must come before what they document, if a comment was \
|
"doc comments must come before what they document, if a comment was \
|
||||||
intended use `//`",
|
intended use `//`",
|
||||||
)
|
)
|
||||||
|
@ -1218,7 +1218,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
let before_trait = trai.path.span.shrink_to_lo();
|
let before_trait = trai.path.span.shrink_to_lo();
|
||||||
let const_up_to_impl = const_span.with_hi(impl_span.lo());
|
let const_up_to_impl = const_span.with_hi(impl_span.lo());
|
||||||
err.multipart_suggestion_mv(
|
err.with_multipart_suggestion(
|
||||||
"you might have meant to write a const trait impl",
|
"you might have meant to write a const trait impl",
|
||||||
vec![(const_up_to_impl, "".to_owned()), (before_trait, "const ".to_owned())],
|
vec![(const_up_to_impl, "".to_owned()), (before_trait, "const ".to_owned())],
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
|
@ -1457,7 +1457,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
if this.token == token::Not {
|
if this.token == token::Not {
|
||||||
if let Err(err) = this.unexpected::<()>() {
|
if let Err(err) = this.unexpected::<()>() {
|
||||||
err.note_mv(fluent::parse_macro_expands_to_enum_variant).emit();
|
err.with_note(fluent::parse_macro_expands_to_enum_variant).emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bump();
|
this.bump();
|
||||||
|
@ -1855,7 +1855,7 @@ impl<'a> Parser<'a> {
|
||||||
if eq_typo || semi_typo {
|
if eq_typo || semi_typo {
|
||||||
self.bump();
|
self.bump();
|
||||||
// Gracefully handle small typos.
|
// Gracefully handle small typos.
|
||||||
err.span_suggestion_short_mv(
|
err.with_span_suggestion_short(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"field names and their types are separated with `:`",
|
"field names and their types are separated with `:`",
|
||||||
":",
|
":",
|
||||||
|
@ -1935,10 +1935,10 @@ impl<'a> Parser<'a> {
|
||||||
lo.to(self.prev_token.span),
|
lo.to(self.prev_token.span),
|
||||||
format!("functions are not allowed in {adt_ty} definitions"),
|
format!("functions are not allowed in {adt_ty} definitions"),
|
||||||
)
|
)
|
||||||
.help_mv(
|
.with_help(
|
||||||
"unlike in C++, Java, and C#, functions are declared in `impl` blocks",
|
"unlike in C++, Java, and C#, functions are declared in `impl` blocks",
|
||||||
)
|
)
|
||||||
.help_mv("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information")
|
.with_help("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information")
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.cancel();
|
err.cancel();
|
||||||
|
@ -1954,7 +1954,9 @@ impl<'a> Parser<'a> {
|
||||||
lo.with_hi(ident.span.hi()),
|
lo.with_hi(ident.span.hi()),
|
||||||
format!("structs are not allowed in {adt_ty} definitions"),
|
format!("structs are not allowed in {adt_ty} definitions"),
|
||||||
)
|
)
|
||||||
.help_mv("consider creating a new `struct` definition instead of nesting"),
|
.with_help(
|
||||||
|
"consider creating a new `struct` definition instead of nesting",
|
||||||
|
),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.cancel();
|
err.cancel();
|
||||||
self.restore_snapshot(snapshot);
|
self.restore_snapshot(snapshot);
|
||||||
|
|
|
@ -847,7 +847,7 @@ impl<'a> Parser<'a> {
|
||||||
pprust::token_to_string(&self.prev_token)
|
pprust::token_to_string(&self.prev_token)
|
||||||
);
|
);
|
||||||
expect_err
|
expect_err
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
self.prev_token.span.shrink_to_hi().until(self.token.span),
|
self.prev_token.span.shrink_to_hi().until(self.token.span),
|
||||||
msg,
|
msg,
|
||||||
" @ ",
|
" @ ",
|
||||||
|
@ -863,7 +863,7 @@ impl<'a> Parser<'a> {
|
||||||
// Parsed successfully, therefore most probably the code only
|
// Parsed successfully, therefore most probably the code only
|
||||||
// misses a separator.
|
// misses a separator.
|
||||||
expect_err
|
expect_err
|
||||||
.span_suggestion_short_mv(
|
.with_span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
format!("missing `{token_str}`"),
|
format!("missing `{token_str}`"),
|
||||||
token_str,
|
token_str,
|
||||||
|
|
|
@ -464,7 +464,7 @@ impl<'a> Parser<'a> {
|
||||||
self_
|
self_
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(self_.token.span, msg)
|
.struct_span_err(self_.token.span, msg)
|
||||||
.span_label_mv(self_.token.span, format!("expected {expected}"))
|
.with_span_label(self_.token.span, format!("expected {expected}"))
|
||||||
});
|
});
|
||||||
PatKind::Lit(self.mk_expr(lo, ExprKind::Lit(lit)))
|
PatKind::Lit(self.mk_expr(lo, ExprKind::Lit(lit)))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -128,7 +128,7 @@ impl<'a> Parser<'a> {
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"found single colon before projection in qualified path",
|
"found single colon before projection in qualified path",
|
||||||
)
|
)
|
||||||
.span_suggestion_mv(
|
.with_span_suggestion(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"use double colon",
|
"use double colon",
|
||||||
"::",
|
"::",
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue