Migrate DropCheckOverflow
This commit is contained in:
parent
4f9898a794
commit
3e834a7a62
5 changed files with 22 additions and 10 deletions
3
compiler/rustc_error_messages/locales/en-US/middle.ftl
Normal file
3
compiler/rustc_error_messages/locales/en-US/middle.ftl
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
middle_drop_check_overflow =
|
||||||
|
overflow while adding drop-check rules for {$ty}
|
||||||
|
.note = {$note}
|
|
@ -45,6 +45,7 @@ fluent_messages! {
|
||||||
interface => "../locales/en-US/interface.ftl",
|
interface => "../locales/en-US/interface.ftl",
|
||||||
infer => "../locales/en-US/infer.ftl",
|
infer => "../locales/en-US/infer.ftl",
|
||||||
lint => "../locales/en-US/lint.ftl",
|
lint => "../locales/en-US/lint.ftl",
|
||||||
|
middle => "../locales/en-US/middle.ftl",
|
||||||
monomorphize => "../locales/en-US/monomorphize.ftl",
|
monomorphize => "../locales/en-US/monomorphize.ftl",
|
||||||
parser => "../locales/en-US/parser.ftl",
|
parser => "../locales/en-US/parser.ftl",
|
||||||
passes => "../locales/en-US/passes.ftl",
|
passes => "../locales/en-US/passes.ftl",
|
||||||
|
|
14
compiler/rustc_middle/src/error.rs
Normal file
14
compiler/rustc_middle/src/error.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
use rustc_macros::SessionDiagnostic;
|
||||||
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
use crate::ty::Ty;
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[diag(middle::drop_check_overflow, code = "E0320")]
|
||||||
|
#[note]
|
||||||
|
pub struct DropCheckOverflow<'tcx> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub ty: Ty<'tcx>,
|
||||||
|
pub note: String,
|
||||||
|
}
|
|
@ -86,6 +86,7 @@ pub mod query;
|
||||||
pub mod arena;
|
pub mod arena;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod dep_graph;
|
pub mod dep_graph;
|
||||||
|
pub(crate) mod error;
|
||||||
pub mod hir;
|
pub mod hir;
|
||||||
pub mod infer;
|
pub mod infer;
|
||||||
pub mod lint;
|
pub mod lint;
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
//! The providers for the queries defined here can be found in
|
//! The providers for the queries defined here can be found in
|
||||||
//! `rustc_traits`.
|
//! `rustc_traits`.
|
||||||
|
|
||||||
|
use crate::error::DropCheckOverflow;
|
||||||
use crate::infer::canonical::{Canonical, QueryResponse};
|
use crate::infer::canonical::{Canonical, QueryResponse};
|
||||||
use crate::ty::error::TypeError;
|
use crate::ty::error::TypeError;
|
||||||
use crate::ty::subst::GenericArg;
|
use crate::ty::subst::GenericArg;
|
||||||
use crate::ty::{self, Ty, TyCtxt};
|
use crate::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_errors::struct_span_err;
|
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
|
||||||
|
@ -117,15 +117,8 @@ pub struct DropckOutlivesResult<'tcx> {
|
||||||
impl<'tcx> DropckOutlivesResult<'tcx> {
|
impl<'tcx> DropckOutlivesResult<'tcx> {
|
||||||
pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
|
pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
|
||||||
if let Some(overflow_ty) = self.overflows.get(0) {
|
if let Some(overflow_ty) = self.overflows.get(0) {
|
||||||
let mut err = struct_span_err!(
|
let note = format!("overflowed on {}", overflow_ty);
|
||||||
tcx.sess,
|
tcx.sess.emit_err(DropCheckOverflow { span, ty, note });
|
||||||
span,
|
|
||||||
E0320,
|
|
||||||
"overflow while adding drop-check rules for {}",
|
|
||||||
ty,
|
|
||||||
);
|
|
||||||
err.note(&format!("overflowed on {}", overflow_ty));
|
|
||||||
err.emit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue