First batch of review feedback changes from #102110
This commit is contained in:
parent
be4059dd3e
commit
965dbf6c28
@ -18,3 +18,12 @@ middle_limit_invalid =
|
||||
|
||||
middle_const_eval_non_int =
|
||||
constant evaluation of enum discriminant resulted in non-integer
|
||||
|
||||
middle_unknown_layout =
|
||||
the type `{$ty}` has an unknown layout
|
||||
|
||||
middle_values_too_big =
|
||||
values of the type `{$ty}` are too big for the current architecture
|
||||
|
||||
middle_cannot_be_normalized =
|
||||
unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized
|
||||
|
@ -526,7 +526,7 @@ passes_no_main_function =
|
||||
.main_must_be_defined_at_crate = the main function must be defined at the crate level{$has_filename ->
|
||||
[true] {" "}(in `{$filename}`)
|
||||
*[false] {""}
|
||||
}
|
||||
}
|
||||
.consider_adding_main_to_file = consider adding a `main` function to `{$filename}`
|
||||
.consider_adding_main_at_crate = consider adding a `main` function at the crate level
|
||||
.teach_note = If you don't know the basics of Rust, you can go look to the Rust Book to get started: https://doc.rust-lang.org/book/
|
||||
|
@ -191,10 +191,29 @@ pub enum LayoutError<'tcx> {
|
||||
|
||||
impl<'a> IntoDiagnostic<'a, !> for LayoutError<'a> {
|
||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, !> {
|
||||
handler.struct_fatal(self.to_string())
|
||||
let mut diag = handler.struct_fatal("");
|
||||
|
||||
match self {
|
||||
LayoutError::Unknown(ty) => {
|
||||
diag.set_arg("ty", ty);
|
||||
diag.set_primary_message(rustc_errors::fluent::middle::unknown_layout);
|
||||
}
|
||||
LayoutError::SizeOverflow(ty) => {
|
||||
diag.set_arg("ty", ty);
|
||||
diag.set_primary_message(rustc_errors::fluent::middle::values_too_big);
|
||||
}
|
||||
LayoutError::NormalizationFailure(ty, e) => {
|
||||
diag.set_arg("ty", ty);
|
||||
diag.set_arg("failure_ty", e.get_type_for_failure());
|
||||
diag.set_primary_message(rustc_errors::fluent::middle::cannot_be_normalized);
|
||||
}
|
||||
}
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Once the other errors that embed this error have been converted to translateable
|
||||
// diagnostics, this Display impl should be removed.
|
||||
impl<'tcx> fmt::Display for LayoutError<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
|
@ -14,7 +14,7 @@
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::symbol::{kw::Empty, sym, Symbol};
|
||||
|
||||
use crate::errors::{DuplicateDiagnosticItem, DuplicateDiagnosticItemInCrate};
|
||||
|
||||
@ -46,7 +46,7 @@ fn collect_item(tcx: TyCtxt<'_>, items: &mut DiagnosticItems, name: Symbol, item
|
||||
None => tcx.sess.emit_err(DuplicateDiagnosticItemInCrate {
|
||||
span: orig_span,
|
||||
// FIXME: We should not provide `name` to `orig_crate_name`. How do you create a blank/empty symbol?
|
||||
orig_crate_name: orig_crate_name.unwrap_or(name),
|
||||
orig_crate_name: orig_crate_name.unwrap_or(Empty),
|
||||
have_orig_crate_name: orig_crate_name.map(|_| ()),
|
||||
crate_name: tcx.crate_name(item_def_id.krate),
|
||||
name,
|
||||
|
@ -830,14 +830,6 @@ pub struct UnrecognizedField {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes::layout)]
|
||||
pub struct Layout {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub layout_error: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes::feature_stable_twice, code = "E0711")]
|
||||
pub struct FeatureStableTwice {
|
||||
@ -1259,7 +1251,7 @@ pub struct IncorrectTarget<'a> {
|
||||
pub span: Span,
|
||||
#[label]
|
||||
pub generics_span: Span,
|
||||
pub name: &'a str,
|
||||
pub name: &'a str, // cannot be symbol because it renders e.g. `r#fn` instead of `fn`
|
||||
pub kind: &'static str,
|
||||
pub num: usize,
|
||||
pub actual_num: usize,
|
||||
|
@ -20,7 +20,7 @@
|
||||
use rustc_hir::{HirId, LangItem, LanguageItems, Target};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::cstore::ExternCrate;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_span::{symbol::kw::Empty, Span};
|
||||
|
||||
use rustc_middle::ty::query::Providers;
|
||||
|
||||
@ -66,7 +66,7 @@ fn collect_item(&mut self, item_index: usize, item_def_id: DefId) {
|
||||
let local_span = self.tcx.hir().span_if_local(item_def_id);
|
||||
let lang_item_name = LangItem::from_u32(item_index as u32).unwrap().name();
|
||||
let crate_name = self.tcx.crate_name(item_def_id.krate);
|
||||
let mut dependency_of = Symbol::intern("");
|
||||
let mut dependency_of = Empty;
|
||||
let is_local = item_def_id.is_local();
|
||||
let path = if is_local {
|
||||
String::new()
|
||||
@ -80,8 +80,8 @@ fn collect_item(&mut self, item_index: usize, item_def_id: DefId) {
|
||||
.into()
|
||||
};
|
||||
let first_defined_span = self.tcx.hir().span_if_local(original_def_id);
|
||||
let mut orig_crate_name = Symbol::intern("");
|
||||
let mut orig_dependency_of = Symbol::intern("");
|
||||
let mut orig_crate_name = Empty;
|
||||
let mut orig_dependency_of = Empty;
|
||||
let orig_is_local = original_def_id.is_local();
|
||||
let orig_path = if orig_is_local {
|
||||
String::new()
|
||||
|
@ -3,11 +3,12 @@
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers, TyAndLayout};
|
||||
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{HasDataLayout, TargetDataLayout};
|
||||
|
||||
use crate::errors::{Abi, Align, HomogeneousAggregate, Layout, LayoutOf, Size, UnrecognizedField};
|
||||
use crate::errors::{Abi, Align, HomogeneousAggregate, LayoutOf, Size, UnrecognizedField};
|
||||
|
||||
pub fn test_layout(tcx: TyCtxt<'_>) {
|
||||
if tcx.features().rustc_attrs {
|
||||
@ -91,9 +92,9 @@ fn dump_layout_of<'tcx>(tcx: TyCtxt<'tcx>, item_def_id: LocalDefId, attr: &Attri
|
||||
}
|
||||
|
||||
Err(layout_error) => {
|
||||
tcx.sess.emit_err(Layout {
|
||||
tcx.sess.emit_fatal(Spanned {
|
||||
node: layout_error,
|
||||
span: tcx.def_span(item_def_id.to_def_id()),
|
||||
layout_error: format!("{:?}", layout_error),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@
|
||||
|
||||
#[rustc_layout(debug)]
|
||||
type Edges<'a, E> = Cow<'a, [E]>;
|
||||
//~^ ERROR layout error: NormalizationFailure
|
||||
//~^ 6:1: 6:18: unable to determine layout for `<[E] as ToOwned>::Owned` because `<[E] as ToOwned>::Owned` cannot be normalized
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: layout error: NormalizationFailure(<[E] as std::borrow::ToOwned>::Owned, Type(<[E] as std::borrow::ToOwned>::Owned))
|
||||
error: unable to determine layout for `<[E] as ToOwned>::Owned` because `<[E] as ToOwned>::Owned` cannot be normalized
|
||||
--> $DIR/issue-85103.rs:6:1
|
||||
|
|
||||
LL | type Edges<'a, E> = Cow<'a, [E]>;
|
||||
|
Loading…
Reference in New Issue
Block a user