Skip to content

Commit 151256b

Browse files
committed
Auto merge of #117135 - matthiaskrgr:rollup-zdh18i6, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #116094 (Introduce `-C instrument-coverage=branch` to gate branch coverage) - #116396 (Migrate diagnostics in `rustc_hir_analysis/src/coherence/orphan.rs`) - #116714 (Derive `Ord`, `PartialOrd` and `Hash` for `SocketAddr*`) - #116792 (Avoid unnecessary renumbering during borrowck) - #116841 (Suggest unwrap/expect for let binding type mismatch) - #116943 (Add target features for LoongArch) - #117010 (Add method to convert internal to stable constructs) - #117127 (Remove `#[allow(incomplete_features)]` from RPITIT/AFIT tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 98b4a64 + 060bdfd commit 151256b

File tree

75 files changed

+1035
-435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1035
-435
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4525,6 +4525,7 @@ dependencies = [
45254525
"rustc_middle",
45264526
"rustc_span",
45274527
"rustc_target",
4528+
"scoped-tls",
45284529
"stable_mir",
45294530
"tracing",
45304531
]

compiler/rustc_borrowck/src/renumber.rs

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ impl<'a, 'tcx> MutVisitor<'tcx> for RegionRenumberer<'a, 'tcx> {
8181

8282
#[instrument(skip(self), level = "debug")]
8383
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
84+
if matches!(ty_context, TyContext::ReturnTy(_)) {
85+
// We will renumber the return ty when called again with `TyContext::LocalDecl`
86+
return;
87+
}
8488
*ty = self.renumber_regions(*ty, || RegionCtxt::TyContext(ty_context));
8589

8690
debug!(?ty);

compiler/rustc_codegen_ssa/src/target_features.rs

+16
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,19 @@ const CSKY_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
342342
("hard-float-abi", Some(sym::csky_target_feature)),
343343
// tidy-alphabetical-end
344344
];
345+
346+
const LOONGARCH_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
347+
// tidy-alphabetical-start
348+
("d", Some(sym::loongarch_target_feature)),
349+
("f", Some(sym::loongarch_target_feature)),
350+
("lasx", Some(sym::loongarch_target_feature)),
351+
("lbt", Some(sym::loongarch_target_feature)),
352+
("lsx", Some(sym::loongarch_target_feature)),
353+
("lvz", Some(sym::loongarch_target_feature)),
354+
("ual", Some(sym::loongarch_target_feature)),
355+
// tidy-alphabetical-end
356+
];
357+
345358
/// When rustdoc is running, provide a list of all known features so that all their respective
346359
/// primitives may be documented.
347360
///
@@ -358,6 +371,7 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol
358371
.chain(WASM_ALLOWED_FEATURES.iter())
359372
.chain(BPF_ALLOWED_FEATURES.iter())
360373
.chain(CSKY_ALLOWED_FEATURES)
374+
.chain(LOONGARCH_ALLOWED_FEATURES)
361375
.cloned()
362376
}
363377

@@ -373,6 +387,7 @@ pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Opt
373387
"wasm32" | "wasm64" => WASM_ALLOWED_FEATURES,
374388
"bpf" => BPF_ALLOWED_FEATURES,
375389
"csky" => CSKY_ALLOWED_FEATURES,
390+
"loongarch64" => LOONGARCH_ALLOWED_FEATURES,
376391
_ => &[],
377392
}
378393
}
@@ -445,6 +460,7 @@ pub fn from_target_feature(
445460
Some(sym::bpf_target_feature) => rust_features.bpf_target_feature,
446461
Some(sym::aarch64_ver_target_feature) => rust_features.aarch64_ver_target_feature,
447462
Some(sym::csky_target_feature) => rust_features.csky_target_feature,
463+
Some(sym::loongarch_target_feature) => rust_features.loongarch_target_feature,
448464
Some(name) => bug!("unknown target feature gate {}", name),
449465
None => true,
450466
};

compiler/rustc_feature/src/unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ declare_features! (
288288
(unstable, csky_target_feature, "1.73.0", Some(44839), None),
289289
(unstable, ermsb_target_feature, "1.49.0", Some(44839), None),
290290
(unstable, hexagon_target_feature, "1.27.0", Some(44839), None),
291+
(unstable, loongarch_target_feature, "1.73.0", Some(44839), None),
291292
(unstable, mips_target_feature, "1.27.0", Some(44839), None),
292293
(unstable, powerpc_target_feature, "1.27.0", Some(44839), None),
293294
(unstable, riscv_target_feature, "1.45.0", Some(44839), None),

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}
@@ -237,6 +243,28 @@ hir_analysis_must_implement_not_function_span_note = required by this annotation
237243
238244
hir_analysis_must_implement_one_of_attribute = the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args
239245
246+
hir_analysis_only_current_traits_arbitrary = only traits defined in the current crate can be implemented for arbitrary types
247+
248+
hir_analysis_only_current_traits_foreign = this is not defined in the current crate because this is a foreign trait
249+
250+
hir_analysis_only_current_traits_label = impl doesn't use only types from inside the current crate
251+
252+
hir_analysis_only_current_traits_name = this is not defined in the current crate because {$name} are always foreign
253+
254+
hir_analysis_only_current_traits_note = define and implement a trait or new type instead
255+
256+
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
257+
258+
hir_analysis_only_current_traits_outside = only traits defined in the current crate can be implemented for types defined outside of the crate
259+
260+
hir_analysis_only_current_traits_pointer = `{$pointer}` is not defined in the current crate because raw pointers are always foreign
261+
262+
hir_analysis_only_current_traits_pointer_sugg = consider introducing a new wrapper type
263+
264+
hir_analysis_only_current_traits_primitive = only traits defined in the current crate can be implemented for primitive types
265+
266+
hir_analysis_only_current_traits_ty = `{$ty}` is not defined in the current crate
267+
240268
hir_analysis_paren_sugar_attribute = the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation
241269
.help = add `#![feature(unboxed_closures)]` to the crate attributes to use it
242270
@@ -326,6 +354,9 @@ hir_analysis_trait_object_declared_with_no_traits =
326354
at least one trait is required for an object type
327355
.alias_span = this alias does not contain a trait
328356
357+
hir_analysis_traits_with_defualt_impl = traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`
358+
.note = a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds
359+
329360
hir_analysis_transparent_enum_variant = transparent enum needs exactly one variant, but has {$number}
330361
.label = needs exactly one variant, but has {$number}
331362
.many_label = too many variants in `{$path}`
@@ -339,6 +370,16 @@ hir_analysis_transparent_non_zero_sized_enum = the variant of a transparent {$de
339370
.label = needs at most one field with non-trivial size or alignment, but has {$field_count}
340371
.labels = this field has non-zero size or requires alignment
341372
373+
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}`)
374+
.label = type parameter `{$param_ty}` must be covered by another type when it appears before the first local type (`{$local_type}`)
375+
.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
376+
.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
377+
378+
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}>`)
379+
.label = type parameter `{$param_ty}` must be used as the type parameter for some local type
380+
.note = implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
381+
.only_note = only traits defined in the current crate can be implemented for a type parameter
382+
342383
hir_analysis_type_of = {$type_of}
343384
344385
hir_analysis_typeof_reserved_keyword_used =

0 commit comments

Comments
 (0)