Skip to content

Commit 3e834a7

Browse files
committed
Migrate DropCheckOverflow
1 parent 4f9898a commit 3e834a7

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
middle_drop_check_overflow =
2+
overflow while adding drop-check rules for {$ty}
3+
.note = {$note}

compiler/rustc_error_messages/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ fluent_messages! {
4545
interface => "../locales/en-US/interface.ftl",
4646
infer => "../locales/en-US/infer.ftl",
4747
lint => "../locales/en-US/lint.ftl",
48+
middle => "../locales/en-US/middle.ftl",
4849
monomorphize => "../locales/en-US/monomorphize.ftl",
4950
parser => "../locales/en-US/parser.ftl",
5051
passes => "../locales/en-US/passes.ftl",

compiler/rustc_middle/src/error.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use rustc_macros::SessionDiagnostic;
2+
use rustc_span::Span;
3+
4+
use crate::ty::Ty;
5+
6+
#[derive(SessionDiagnostic)]
7+
#[diag(middle::drop_check_overflow, code = "E0320")]
8+
#[note]
9+
pub struct DropCheckOverflow<'tcx> {
10+
#[primary_span]
11+
pub span: Span,
12+
pub ty: Ty<'tcx>,
13+
pub note: String,
14+
}

compiler/rustc_middle/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub mod query;
8686
pub mod arena;
8787
#[macro_use]
8888
pub mod dep_graph;
89+
pub(crate) mod error;
8990
pub mod hir;
9091
pub mod infer;
9192
pub mod lint;

compiler/rustc_middle/src/traits/query.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
//! The providers for the queries defined here can be found in
66
//! `rustc_traits`.
77
8+
use crate::error::DropCheckOverflow;
89
use crate::infer::canonical::{Canonical, QueryResponse};
910
use crate::ty::error::TypeError;
1011
use crate::ty::subst::GenericArg;
1112
use crate::ty::{self, Ty, TyCtxt};
12-
use rustc_errors::struct_span_err;
1313
use rustc_span::source_map::Span;
1414
use std::iter::FromIterator;
1515

@@ -117,15 +117,8 @@ pub struct DropckOutlivesResult<'tcx> {
117117
impl<'tcx> DropckOutlivesResult<'tcx> {
118118
pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
119119
if let Some(overflow_ty) = self.overflows.get(0) {
120-
let mut err = struct_span_err!(
121-
tcx.sess,
122-
span,
123-
E0320,
124-
"overflow while adding drop-check rules for {}",
125-
ty,
126-
);
127-
err.note(&format!("overflowed on {}", overflow_ty));
128-
err.emit();
120+
let note = format!("overflowed on {}", overflow_ty);
121+
tcx.sess.emit_err(DropCheckOverflow { span, ty, note });
129122
}
130123
}
131124

0 commit comments

Comments
 (0)