Skip to content

Commit e8dfb53

Browse files
committed
Migrate diagnostics in rustc_hir_analysis/src/coherence/orphan.rs
1 parent 781ebbe commit e8dfb53

File tree

3 files changed

+338
-166
lines changed

3 files changed

+338
-166
lines changed

compiler/rustc_hir_analysis/messages.ftl

+41
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ hir_analysis_copy_impl_on_type_with_dtor =
7272
the trait `Copy` cannot be implemented for this type; the type has a destructor
7373
.label = `Copy` not allowed on types with destructors
7474
75+
hir_analysis_cross_crate_traits = cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`
76+
.label = can't implement cross-crate trait with a default impl for non-struct/enum type
77+
78+
hir_analysis_cross_crate_traits_defined = cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type defined in the current crate
79+
.label = can't implement cross-crate trait for type in another crate
80+
7581
hir_analysis_dispatch_from_dyn_multi = implementing the `DispatchFromDyn` trait requires multiple coercions
7682
.note = the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced
7783
.coercions_note = currently, {$number} fields need coercions: {$coercions}
@@ -239,6 +245,28 @@ hir_analysis_must_implement_not_function_span_note = required by this annotation
239245
240246
hir_analysis_must_implement_one_of_attribute = the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args
241247
248+
hir_analysis_only_current_traits_arbitrary = only traits defined in the current crate can be implemented for arbitrary types
249+
250+
hir_analysis_only_current_traits_foreign = this is not defined in the current crate because this is a foreign trait
251+
252+
hir_analysis_only_current_traits_label = impl doesn't use only types from inside the current crate
253+
254+
hir_analysis_only_current_traits_name = this is not defined in the current crate because {$name} are always foreign
255+
256+
hir_analysis_only_current_traits_note = define and implement a trait or new type instead
257+
258+
hir_analysis_only_current_traits_opaque = type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate
259+
260+
hir_analysis_only_current_traits_outside = only traits defined in the current crate can be implemented for types defined outside of the crate
261+
262+
hir_analysis_only_current_traits_pointer = `{$pointer}` is not defined in the current crate because raw pointers are always foreign
263+
264+
hir_analysis_only_current_traits_pointer_sugg = consider introducing a new wrapper type
265+
266+
hir_analysis_only_current_traits_primitive = only traits defined in the current crate can be implemented for primitive types
267+
268+
hir_analysis_only_current_traits_ty = `{$ty}` is not defined in the current crate
269+
242270
hir_analysis_paren_sugar_attribute = the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation
243271
.help = add `#![feature(unboxed_closures)]` to the crate attributes to use it
244272
@@ -328,6 +356,9 @@ hir_analysis_trait_object_declared_with_no_traits =
328356
at least one trait is required for an object type
329357
.alias_span = this alias does not contain a trait
330358
359+
hir_analysis_traits_with_defualt_impl = traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`
360+
.note = a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds
361+
331362
hir_analysis_transparent_enum_variant = transparent enum needs exactly one variant, but has {$number}
332363
.label = needs exactly one variant, but has {$number}
333364
.many_label = too many variants in `{$path}`
@@ -341,6 +372,16 @@ hir_analysis_transparent_non_zero_sized_enum = the variant of a transparent {$de
341372
.label = needs at most one field with non-trivial size or alignment, but has {$field_count}
342373
.labels = this field has non-zero size or requires alignment
343374
375+
hir_analysis_ty_param_first_local = type parameter `{$param_ty}` must be covered by another type when it appears before the first local type (`{$local_type}`)
376+
.label = type parameter `{$param_ty}` must be covered by another type when it appears before the first local type (`{$local_type}`)
377+
.note = implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
378+
.case_note = in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
379+
380+
hir_analysis_ty_param_some = type parameter `{$param_ty}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param_ty}>`)
381+
.label = type parameter `{$param_ty}` must be used as the type parameter for some local type
382+
.note = implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
383+
.only_note = only traits defined in the current crate can be implemented for a type parameter
384+
344385
hir_analysis_typeof_reserved_keyword_used =
345386
`typeof` is a reserved keyword but unimplemented
346387
.suggestion = consider replacing `typeof(...)` with an actual type

0 commit comments

Comments
 (0)