mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Auto merge of #115821 - obeis:hir-analysis-migrate-diagnostics-5, r=compiler-errors
Migrate `rustc_hir_analysis` to session diagnostic [Part 5] Finishing `coherence/builtin.rs` file
This commit is contained in:
commit
958c2b87d8
@ -38,6 +38,17 @@ hir_analysis_cast_thin_pointer_to_fat_pointer = cannot cast thin pointer `{$expr
|
|||||||
hir_analysis_closure_implicit_hrtb = implicit types in closure signatures are forbidden when `for<...>` is present
|
hir_analysis_closure_implicit_hrtb = implicit types in closure signatures are forbidden when `for<...>` is present
|
||||||
.label = `for<...>` is here
|
.label = `for<...>` is here
|
||||||
|
|
||||||
|
hir_analysis_coerce_unsized_may = the trait `{$trait_name}` may only be implemented for a coercion between structures
|
||||||
|
|
||||||
|
hir_analysis_coerce_unsized_multi = implementing the trait `CoerceUnsized` requires multiple coercions
|
||||||
|
.note = `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced
|
||||||
|
.coercions_note = currently, {$number} fields need coercions: {$coercions}
|
||||||
|
.label = requires multiple coercions
|
||||||
|
|
||||||
|
hir_analysis_coercion_between_struct_same_note = expected coercion between the same definition; expected `{$source_path}`, found `{$target_path}`
|
||||||
|
|
||||||
|
hir_analysis_coercion_between_struct_single_note = expected a single field to be coerced, none found
|
||||||
|
|
||||||
hir_analysis_const_bound_for_non_const_trait =
|
hir_analysis_const_bound_for_non_const_trait =
|
||||||
~const can only be applied to `#[const_trait]` traits
|
~const can only be applied to `#[const_trait]` traits
|
||||||
|
|
||||||
@ -61,6 +72,15 @@ hir_analysis_copy_impl_on_type_with_dtor =
|
|||||||
the trait `Copy` cannot be implemented for this type; the type has a destructor
|
the trait `Copy` cannot be implemented for this type; the type has a destructor
|
||||||
.label = `Copy` not allowed on types with destructors
|
.label = `Copy` not allowed on types with destructors
|
||||||
|
|
||||||
|
hir_analysis_dispatch_from_dyn_multi = implementing the `DispatchFromDyn` trait requires multiple coercions
|
||||||
|
.note = the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced
|
||||||
|
.coercions_note = currently, {$number} fields need coercions: {$coercions}
|
||||||
|
|
||||||
|
hir_analysis_dispatch_from_dyn_repr = structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`
|
||||||
|
|
||||||
|
hir_analysis_dispatch_from_dyn_zst = the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment, and nothing else
|
||||||
|
.note = extra field `{$name}` of type `{$ty}` is not allowed
|
||||||
|
|
||||||
hir_analysis_drop_impl_negative = negative `Drop` impls are not supported
|
hir_analysis_drop_impl_negative = negative `Drop` impls are not supported
|
||||||
|
|
||||||
hir_analysis_drop_impl_on_wrong_item =
|
hir_analysis_drop_impl_on_wrong_item =
|
||||||
@ -232,6 +252,8 @@ hir_analysis_pass_to_variadic_function = can't pass `{$ty}` to variadic function
|
|||||||
hir_analysis_placeholder_not_allowed_item_signatures = the placeholder `_` is not allowed within types on item signatures for {$kind}
|
hir_analysis_placeholder_not_allowed_item_signatures = the placeholder `_` is not allowed within types on item signatures for {$kind}
|
||||||
.label = not allowed in type signatures
|
.label = not allowed in type signatures
|
||||||
|
|
||||||
|
hir_analysis_requires_note = the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`
|
||||||
|
|
||||||
hir_analysis_return_type_notation_conflicting_bound =
|
hir_analysis_return_type_notation_conflicting_bound =
|
||||||
ambiguous associated function `{$assoc_name}` for `{$ty_name}`
|
ambiguous associated function `{$assoc_name}` for `{$ty_name}`
|
||||||
.note = `{$assoc_name}` is declared in two supertraits: `{$first_bound}` and `{$second_bound}`
|
.note = `{$assoc_name}` is declared in two supertraits: `{$first_bound}` and `{$second_bound}`
|
||||||
@ -299,6 +321,9 @@ hir_analysis_too_large_static = extern static is too large for the current archi
|
|||||||
hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
|
hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
|
||||||
.suggestion = remove this annotation
|
.suggestion = remove this annotation
|
||||||
|
|
||||||
|
hir_analysis_trait_cannot_impl_for_ty = the trait `{$trait_name}` cannot be implemented for this type
|
||||||
|
.label = this field does not implement `{$trait_name}`
|
||||||
|
|
||||||
hir_analysis_trait_object_declared_with_no_traits =
|
hir_analysis_trait_object_declared_with_no_traits =
|
||||||
at least one trait is required for an object type
|
at least one trait is required for an object type
|
||||||
.alias_span = this alias does not contain a trait
|
.alias_span = this alias does not contain a trait
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
//! Check properties that are required by built-in traits and set
|
//! Check properties that are required by built-in traits and set
|
||||||
//! up data structures required by type-checking/codegen.
|
//! up data structures required by type-checking/codegen.
|
||||||
|
|
||||||
use crate::errors::{
|
use crate::errors;
|
||||||
ConstParamTyImplOnNonAdt, CopyImplOnNonAdt, CopyImplOnTypeWithDtor, DropImplOnWrongItem,
|
|
||||||
};
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::{struct_span_err, ErrorGuaranteed, MultiSpan};
|
use rustc_errors::{ErrorGuaranteed, 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::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
@ -65,7 +64,7 @@ fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
|||||||
|
|
||||||
let impl_ = tcx.hir().expect_item(impl_did).expect_impl();
|
let impl_ = tcx.hir().expect_item(impl_did).expect_impl();
|
||||||
|
|
||||||
tcx.sess.emit_err(DropImplOnWrongItem { span: impl_.self_ty.span });
|
tcx.sess.emit_err(errors::DropImplOnWrongItem { span: impl_.self_ty.span });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
||||||
@ -91,10 +90,10 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
|||||||
infringing_fields_error(tcx, fields, LangItem::Copy, impl_did, span);
|
infringing_fields_error(tcx, fields, LangItem::Copy, impl_did, span);
|
||||||
}
|
}
|
||||||
Err(CopyImplementationError::NotAnAdt) => {
|
Err(CopyImplementationError::NotAnAdt) => {
|
||||||
tcx.sess.emit_err(CopyImplOnNonAdt { span });
|
tcx.sess.emit_err(errors::CopyImplOnNonAdt { span });
|
||||||
}
|
}
|
||||||
Err(CopyImplementationError::HasDestructor) => {
|
Err(CopyImplementationError::HasDestructor) => {
|
||||||
tcx.sess.emit_err(CopyImplOnTypeWithDtor { span });
|
tcx.sess.emit_err(errors::CopyImplOnTypeWithDtor { span });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +116,7 @@ fn visit_implementation_of_const_param_ty(tcx: TyCtxt<'_>, impl_did: LocalDefId)
|
|||||||
infringing_fields_error(tcx, fields, LangItem::ConstParamTy, impl_did, span);
|
infringing_fields_error(tcx, fields, LangItem::ConstParamTy, impl_did, span);
|
||||||
}
|
}
|
||||||
Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed) => {
|
Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed) => {
|
||||||
tcx.sess.emit_err(ConstParamTyImplOnNonAdt { span });
|
tcx.sess.emit_err(errors::ConstParamTyImplOnNonAdt { span });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,8 +151,6 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||||||
|
|
||||||
let param_env = tcx.param_env(impl_did);
|
let param_env = tcx.param_env(impl_did);
|
||||||
|
|
||||||
let create_err = |msg: &str| struct_span_err!(tcx.sess, span, E0378, "{}", msg);
|
|
||||||
|
|
||||||
let infcx = tcx.infer_ctxt().build();
|
let infcx = tcx.infer_ctxt().build();
|
||||||
let cause = ObligationCause::misc(span, impl_did);
|
let cause = ObligationCause::misc(span, impl_did);
|
||||||
|
|
||||||
@ -176,22 +173,19 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||||||
let source_path = tcx.def_path_str(def_a.did());
|
let source_path = tcx.def_path_str(def_a.did());
|
||||||
let target_path = tcx.def_path_str(def_b.did());
|
let target_path = tcx.def_path_str(def_b.did());
|
||||||
|
|
||||||
create_err(&format!(
|
tcx.sess.emit_err(errors::DispatchFromDynCoercion {
|
||||||
"the trait `DispatchFromDyn` may only be implemented \
|
span,
|
||||||
for a coercion between structures with the same \
|
trait_name: "DispatchFromDyn",
|
||||||
definition; expected `{source_path}`, found `{target_path}`",
|
note: true,
|
||||||
))
|
source_path,
|
||||||
.emit();
|
target_path,
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if def_a.repr().c() || def_a.repr().packed() {
|
if def_a.repr().c() || def_a.repr().packed() {
|
||||||
create_err(
|
tcx.sess.emit_err(errors::DispatchFromDynRepr { span });
|
||||||
"structs implementing `DispatchFromDyn` may not have \
|
|
||||||
`#[repr(packed)]` or `#[repr(C)]`",
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let fields = &def_a.non_enum_variant().fields;
|
let fields = &def_a.non_enum_variant().fields;
|
||||||
@ -213,16 +207,11 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||||||
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, ty_a, ty_b)
|
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, ty_a, ty_b)
|
||||||
{
|
{
|
||||||
if ok.obligations.is_empty() {
|
if ok.obligations.is_empty() {
|
||||||
create_err(
|
tcx.sess.emit_err(errors::DispatchFromDynZST {
|
||||||
"the trait `DispatchFromDyn` may only be implemented \
|
span,
|
||||||
for structs containing the field being coerced, \
|
name: field.name,
|
||||||
ZST fields with 1 byte alignment, and nothing else",
|
ty: ty_a,
|
||||||
)
|
});
|
||||||
.note(format!(
|
|
||||||
"extra field `{}` of type `{}` is not allowed",
|
|
||||||
field.name, ty_a,
|
|
||||||
))
|
|
||||||
.emit();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -233,23 +222,17 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if coerced_fields.is_empty() {
|
if coerced_fields.is_empty() {
|
||||||
create_err(
|
tcx.sess.emit_err(errors::DispatchFromDynSingle {
|
||||||
"the trait `DispatchFromDyn` may only be implemented \
|
span,
|
||||||
for a coercion between structures with a single field \
|
trait_name: "DispatchFromDyn",
|
||||||
being coerced, none found",
|
note: true,
|
||||||
)
|
});
|
||||||
.emit();
|
|
||||||
} else if coerced_fields.len() > 1 {
|
} else if coerced_fields.len() > 1 {
|
||||||
create_err("implementing the `DispatchFromDyn` trait requires multiple coercions")
|
tcx.sess.emit_err(errors::DispatchFromDynMulti {
|
||||||
.note(
|
span,
|
||||||
"the trait `DispatchFromDyn` may only be implemented \
|
coercions_note: true,
|
||||||
for a coercion between structures with a single field \
|
number: coerced_fields.len(),
|
||||||
being coerced",
|
coercions: coerced_fields
|
||||||
)
|
|
||||||
.note(format!(
|
|
||||||
"currently, {} fields need coercions: {}",
|
|
||||||
coerced_fields.len(),
|
|
||||||
coerced_fields
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|field| {
|
.map(|field| {
|
||||||
format!(
|
format!(
|
||||||
@ -260,9 +243,8 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ")
|
.join(", "),
|
||||||
))
|
});
|
||||||
.emit();
|
|
||||||
} else {
|
} else {
|
||||||
let ocx = ObligationCtxt::new(&infcx);
|
let ocx = ObligationCtxt::new(&infcx);
|
||||||
for field in coerced_fields {
|
for field in coerced_fields {
|
||||||
@ -288,11 +270,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
create_err(
|
tcx.sess.emit_err(errors::CoerceUnsizedMay { span, trait_name: "DispatchFromDyn" });
|
||||||
"the trait `DispatchFromDyn` may only be implemented \
|
|
||||||
for a coercion between structures",
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,17 +337,13 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||||||
if def_a != def_b {
|
if def_a != def_b {
|
||||||
let source_path = tcx.def_path_str(def_a.did());
|
let source_path = tcx.def_path_str(def_a.did());
|
||||||
let target_path = tcx.def_path_str(def_b.did());
|
let target_path = tcx.def_path_str(def_b.did());
|
||||||
struct_span_err!(
|
tcx.sess.emit_err(errors::DispatchFromDynSame {
|
||||||
tcx.sess,
|
|
||||||
span,
|
span,
|
||||||
E0377,
|
trait_name: "CoerceUnsized",
|
||||||
"the trait `CoerceUnsized` may only be implemented \
|
note: true,
|
||||||
for a coercion between structures with the same \
|
|
||||||
definition; expected `{}`, found `{}`",
|
|
||||||
source_path,
|
source_path,
|
||||||
target_path
|
target_path,
|
||||||
)
|
});
|
||||||
.emit();
|
|
||||||
return err_info;
|
return err_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,15 +419,11 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if diff_fields.is_empty() {
|
if diff_fields.is_empty() {
|
||||||
struct_span_err!(
|
tcx.sess.emit_err(errors::CoerceUnsizedOneField {
|
||||||
tcx.sess,
|
|
||||||
span,
|
span,
|
||||||
E0374,
|
trait_name: "CoerceUnsized",
|
||||||
"the trait `CoerceUnsized` may only be implemented \
|
note: true,
|
||||||
for a coercion between structures with one field \
|
});
|
||||||
being coerced, none found"
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
return err_info;
|
return err_info;
|
||||||
} else if diff_fields.len() > 1 {
|
} else if diff_fields.len() > 1 {
|
||||||
let item = tcx.hir().expect_item(impl_did);
|
let item = tcx.hir().expect_item(impl_did);
|
||||||
@ -463,29 +433,17 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||||||
tcx.def_span(impl_did)
|
tcx.def_span(impl_did)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct_span_err!(
|
tcx.sess.emit_err(errors::CoerceUnsizedMulti {
|
||||||
tcx.sess,
|
|
||||||
span,
|
span,
|
||||||
E0375,
|
coercions_note: true,
|
||||||
"implementing the trait \
|
number: diff_fields.len(),
|
||||||
`CoerceUnsized` requires multiple \
|
coercions: diff_fields
|
||||||
coercions"
|
|
||||||
)
|
|
||||||
.note(
|
|
||||||
"`CoerceUnsized` may only be implemented for \
|
|
||||||
a coercion between structures with one field being coerced",
|
|
||||||
)
|
|
||||||
.note(format!(
|
|
||||||
"currently, {} fields need coercions: {}",
|
|
||||||
diff_fields.len(),
|
|
||||||
diff_fields
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(i, a, b)| { format!("`{}` (`{}` to `{}`)", fields[i].name, a, b) })
|
.map(|&(i, a, b)| format!("`{}` (`{}` to `{}`)", fields[i].name, a, b))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ")
|
.join(", "),
|
||||||
))
|
});
|
||||||
.span_label(span, "requires multiple coercions")
|
|
||||||
.emit();
|
|
||||||
return err_info;
|
return err_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,14 +453,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
struct_span_err!(
|
tcx.sess.emit_err(errors::DispatchFromDynStruct { span, trait_name: "CoerceUnsized" });
|
||||||
tcx.sess,
|
|
||||||
span,
|
|
||||||
E0376,
|
|
||||||
"the trait `CoerceUnsized` may only be implemented \
|
|
||||||
for a coercion between structures"
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
return err_info;
|
return err_info;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -540,13 +491,6 @@ fn infringing_fields_error(
|
|||||||
|
|
||||||
let trait_name = tcx.def_path_str(trait_did);
|
let trait_name = tcx.def_path_str(trait_did);
|
||||||
|
|
||||||
let mut err = struct_span_err!(
|
|
||||||
tcx.sess,
|
|
||||||
impl_span,
|
|
||||||
E0204,
|
|
||||||
"the trait `{trait_name}` cannot be implemented for this type"
|
|
||||||
);
|
|
||||||
|
|
||||||
// We'll try to suggest constraining type parameters to fulfill the requirements of
|
// We'll try to suggest constraining type parameters to fulfill the requirements of
|
||||||
// their `Copy` implementation.
|
// their `Copy` implementation.
|
||||||
let mut errors: BTreeMap<_, Vec<_>> = Default::default();
|
let mut errors: BTreeMap<_, Vec<_>> = Default::default();
|
||||||
@ -554,14 +498,15 @@ fn infringing_fields_error(
|
|||||||
|
|
||||||
let mut seen_tys = FxHashSet::default();
|
let mut seen_tys = FxHashSet::default();
|
||||||
|
|
||||||
|
let mut label_spans = Vec::new();
|
||||||
|
|
||||||
for (field, ty, reason) in fields {
|
for (field, ty, reason) in fields {
|
||||||
// Only report an error once per type.
|
// Only report an error once per type.
|
||||||
if !seen_tys.insert(ty) {
|
if !seen_tys.insert(ty) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let field_span = tcx.def_span(field.did);
|
label_spans.push(tcx.def_span(field.did));
|
||||||
err.span_label(field_span, format!("this field does not implement `{trait_name}`"));
|
|
||||||
|
|
||||||
match reason {
|
match reason {
|
||||||
InfringingFieldsReason::Fulfill(fulfillment_errors) => {
|
InfringingFieldsReason::Fulfill(fulfillment_errors) => {
|
||||||
@ -625,13 +570,24 @@ fn infringing_fields_error(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let mut notes = Vec::new();
|
||||||
for ((ty, error_predicate), spans) in errors {
|
for ((ty, error_predicate), spans) in errors {
|
||||||
let span: MultiSpan = spans.into();
|
let span: MultiSpan = spans.into();
|
||||||
err.span_note(
|
notes.push(errors::ImplForTyRequires {
|
||||||
span,
|
span,
|
||||||
format!("the `{trait_name}` impl for `{ty}` requires that `{error_predicate}`"),
|
error_predicate,
|
||||||
);
|
trait_name: trait_name.clone(),
|
||||||
|
ty,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut err = tcx.sess.create_err(errors::TraitCannotImplForTy {
|
||||||
|
span: impl_span,
|
||||||
|
trait_name,
|
||||||
|
label_spans,
|
||||||
|
notes,
|
||||||
|
});
|
||||||
|
|
||||||
suggest_constraining_type_params(
|
suggest_constraining_type_params(
|
||||||
tcx,
|
tcx,
|
||||||
tcx.hir().get_generics(impl_did).expect("impls always have generics"),
|
tcx.hir().get_generics(impl_did).expect("impls always have generics"),
|
||||||
|
@ -963,6 +963,25 @@ pub struct InherentTyOutside {
|
|||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_coerce_unsized_may, code = "E0378")]
|
||||||
|
pub struct DispatchFromDynCoercion<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub trait_name: &'a str,
|
||||||
|
#[note(hir_analysis_coercion_between_struct_same_note)]
|
||||||
|
pub note: bool,
|
||||||
|
pub source_path: String,
|
||||||
|
pub target_path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_dispatch_from_dyn_repr, code = "E0378")]
|
||||||
|
pub struct DispatchFromDynRepr {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(hir_analysis_inherent_ty_outside_relevant, code = "E0390")]
|
#[diag(hir_analysis_inherent_ty_outside_relevant, code = "E0390")]
|
||||||
#[help]
|
#[help]
|
||||||
@ -1025,3 +1044,108 @@ pub struct InherentNominal {
|
|||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_dispatch_from_dyn_zst, code = "E0378")]
|
||||||
|
#[note]
|
||||||
|
pub struct DispatchFromDynZST<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub name: Symbol,
|
||||||
|
pub ty: Ty<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_coerce_unsized_may, code = "E0378")]
|
||||||
|
pub struct DispatchFromDynSingle<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub trait_name: &'a str,
|
||||||
|
#[note(hir_analysis_coercion_between_struct_single_note)]
|
||||||
|
pub note: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_dispatch_from_dyn_multi, code = "E0378")]
|
||||||
|
#[note]
|
||||||
|
pub struct DispatchFromDynMulti {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[note(hir_analysis_coercions_note)]
|
||||||
|
pub coercions_note: bool,
|
||||||
|
pub number: usize,
|
||||||
|
pub coercions: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_coerce_unsized_may, code = "E0376")]
|
||||||
|
pub struct DispatchFromDynStruct<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub trait_name: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_coerce_unsized_may, code = "E0377")]
|
||||||
|
pub struct DispatchFromDynSame<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub trait_name: &'a str,
|
||||||
|
#[note(hir_analysis_coercion_between_struct_same_note)]
|
||||||
|
pub note: bool,
|
||||||
|
pub source_path: String,
|
||||||
|
pub target_path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_coerce_unsized_may, code = "E0374")]
|
||||||
|
pub struct CoerceUnsizedOneField<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub trait_name: &'a str,
|
||||||
|
#[note(hir_analysis_coercion_between_struct_single_note)]
|
||||||
|
pub note: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_coerce_unsized_multi, code = "E0375")]
|
||||||
|
#[note]
|
||||||
|
pub struct CoerceUnsizedMulti {
|
||||||
|
#[primary_span]
|
||||||
|
#[label]
|
||||||
|
pub span: Span,
|
||||||
|
#[note(hir_analysis_coercions_note)]
|
||||||
|
pub coercions_note: bool,
|
||||||
|
pub number: usize,
|
||||||
|
pub coercions: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_coerce_unsized_may, code = "E0378")]
|
||||||
|
pub struct CoerceUnsizedMay<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub trait_name: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_trait_cannot_impl_for_ty, code = "E0204")]
|
||||||
|
pub struct TraitCannotImplForTy {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub trait_name: String,
|
||||||
|
#[label]
|
||||||
|
pub label_spans: Vec<Span>,
|
||||||
|
#[subdiagnostic]
|
||||||
|
pub notes: Vec<ImplForTyRequires>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[note(hir_analysis_requires_note)]
|
||||||
|
pub struct ImplForTyRequires {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: MultiSpan,
|
||||||
|
pub error_predicate: String,
|
||||||
|
pub trait_name: String,
|
||||||
|
pub ty: String,
|
||||||
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced, none found
|
error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures
|
||||||
--> $DIR/E0374.rs:8:1
|
--> $DIR/E0374.rs:8:1
|
||||||
|
|
|
|
||||||
LL | impl<T, U> CoerceUnsized<Foo<U>> for Foo<T>
|
LL | impl<T, U> CoerceUnsized<Foo<U>> for Foo<T>
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: expected a single field to be coerced, none found
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with the same definition; expected `Foo`, found `Bar`
|
error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures
|
||||||
--> $DIR/E0377.rs:12:1
|
--> $DIR/E0377.rs:12:1
|
||||||
|
|
|
|
||||||
LL | impl<T, U> CoerceUnsized<Bar<U>> for Foo<T> where T: CoerceUnsized<U> {}
|
LL | impl<T, U> CoerceUnsized<Bar<U>> for Foo<T> where T: CoerceUnsized<U> {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: expected coercion between the same definition; expected `Foo`, found `Bar`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -15,11 +15,13 @@ LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for Multipl
|
|||||||
= note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced
|
= note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced
|
||||||
= note: currently, 2 fields need coercions: `ptr1` (`*const T` to `*const U`), `ptr2` (`*const T` to `*const U`)
|
= note: currently, 2 fields need coercions: `ptr1` (`*const T` to `*const U`), `ptr2` (`*const T` to `*const U`)
|
||||||
|
|
||||||
error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced, none found
|
error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures
|
||||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:31:1
|
--> $DIR/invalid_dispatch_from_dyn_impls.rs:31:1
|
||||||
|
|
|
|
||||||
LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {}
|
LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: expected a single field to be coerced, none found
|
||||||
|
|
||||||
error[E0378]: structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`
|
error[E0378]: structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`
|
||||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:37:1
|
--> $DIR/invalid_dispatch_from_dyn_impls.rs:37:1
|
||||||
|
Loading…
Reference in New Issue
Block a user