Skip to content

Commit 6677875

Browse files
committed
Auto merge of rust-lang#143337 - matthiaskrgr:rollup-lqwhe0i, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#141847 (Explain `TOCTOU` on the top of `std::fs`, and reference it in functions) - rust-lang#142138 (Add `Vec::into_chunks`) - rust-lang#142321 (Expose elf abi on ppc64 targets) - rust-lang#142886 (ci: aarch64-gnu: Stop skipping `panic_abort_doc_tests`) - rust-lang#143194 (fix bitcast of single-element SIMD vectors) - rust-lang#143231 (Suggest use another lifetime specifier instead of underscore lifetime) - rust-lang#143232 ([COMPILETEST-UNTANGLE 3/N] Use "directives" consistently within compiletest) - rust-lang#143258 (Don't recompute `DisambiguatorState` for every RPITIT in trait definition) - rust-lang#143274 (ci: support optional jobs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1ce9c97 + c572231 commit 6677875

File tree

42 files changed

+306
-132
lines changed

Some content is hidden

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

42 files changed

+306
-132
lines changed

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ pub(super) fn transmute_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
11171117
// While optimizations will remove no-op transmutes, they might still be
11181118
// there in debug or things that aren't no-op in MIR because they change
11191119
// the Rust type but not the underlying layout/niche.
1120-
if from_scalar == to_scalar {
1120+
if from_scalar == to_scalar && from_backend_ty == to_backend_ty {
11211121
return imm;
11221122
}
11231123

@@ -1136,13 +1136,7 @@ pub(super) fn transmute_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
11361136
assume_scalar_range(bx, imm, from_scalar, from_backend_ty);
11371137

11381138
imm = match (from_scalar.primitive(), to_scalar.primitive()) {
1139-
(Int(..) | Float(_), Int(..) | Float(_)) => {
1140-
if from_backend_ty == to_backend_ty {
1141-
imm
1142-
} else {
1143-
bx.bitcast(imm, to_backend_ty)
1144-
}
1145-
}
1139+
(Int(..) | Float(_), Int(..) | Float(_)) => bx.bitcast(imm, to_backend_ty),
11461140
(Pointer(..), Pointer(..)) => bx.pointercast(imm, to_backend_ty),
11471141
(Int(..), Pointer(..)) => bx.ptradd(bx.const_null(bx.type_ptr()), imm),
11481142
(Pointer(..), Int(..)) => {

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,13 +2459,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24592459
// type a projection.
24602460
let in_trait = match opaque_ty.origin {
24612461
hir::OpaqueTyOrigin::FnReturn {
2462+
parent,
24622463
in_trait_or_impl: Some(hir::RpitContext::Trait),
24632464
..
24642465
}
24652466
| hir::OpaqueTyOrigin::AsyncFn {
2467+
parent,
24662468
in_trait_or_impl: Some(hir::RpitContext::Trait),
24672469
..
2468-
} => true,
2470+
} => Some(parent),
24692471
hir::OpaqueTyOrigin::FnReturn {
24702472
in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
24712473
..
@@ -2474,7 +2476,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24742476
in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
24752477
..
24762478
}
2477-
| hir::OpaqueTyOrigin::TyAlias { .. } => false,
2479+
| hir::OpaqueTyOrigin::TyAlias { .. } => None,
24782480
};
24792481

24802482
self.lower_opaque_ty(opaque_ty.def_id, in_trait)
@@ -2594,17 +2596,25 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
25942596

25952597
/// Lower an opaque type (i.e., an existential impl-Trait type) from the HIR.
25962598
#[instrument(level = "debug", skip(self), ret)]
2597-
fn lower_opaque_ty(&self, def_id: LocalDefId, in_trait: bool) -> Ty<'tcx> {
2599+
fn lower_opaque_ty(&self, def_id: LocalDefId, in_trait: Option<LocalDefId>) -> Ty<'tcx> {
25982600
let tcx = self.tcx();
25992601

26002602
let lifetimes = tcx.opaque_captured_lifetimes(def_id);
26012603
debug!(?lifetimes);
26022604

2603-
// If this is an RPITIT and we are using the new RPITIT lowering scheme, we
2604-
// generate the def_id of an associated type for the trait and return as
2605-
// type a projection.
2606-
let def_id = if in_trait {
2607-
tcx.associated_type_for_impl_trait_in_trait(def_id).to_def_id()
2605+
// If this is an RPITIT and we are using the new RPITIT lowering scheme,
2606+
// do a linear search to map this to the synthetic associated type that
2607+
// it will be lowered to.
2608+
let def_id = if let Some(parent_def_id) = in_trait {
2609+
*tcx.associated_types_for_impl_traits_in_associated_fn(parent_def_id)
2610+
.iter()
2611+
.find(|rpitit| match tcx.opt_rpitit_info(**rpitit) {
2612+
Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => {
2613+
opaque_def_id.expect_local() == def_id
2614+
}
2615+
_ => unreachable!(),
2616+
})
2617+
.unwrap()
26082618
} else {
26092619
def_id.to_def_id()
26102620
};
@@ -2627,7 +2637,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
26272637
});
26282638
debug!(?args);
26292639

2630-
if in_trait {
2640+
if in_trait.is_some() {
26312641
Ty::new_projection_from_args(tcx, def_id, args)
26322642
} else {
26332643
Ty::new_opaque(tcx, def_id, args)

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,13 +1093,6 @@ rustc_queries! {
10931093
separate_provide_extern
10941094
}
10951095

1096-
/// Given an impl trait in trait `opaque_ty_def_id`, create and return the corresponding
1097-
/// associated item.
1098-
query associated_type_for_impl_trait_in_trait(opaque_ty_def_id: LocalDefId) -> LocalDefId {
1099-
desc { |tcx| "creating the associated item corresponding to the opaque type `{}`", tcx.def_path_str(opaque_ty_def_id.to_def_id()) }
1100-
cache_on_disk_if { true }
1101-
}
1102-
11031096
/// Given an `impl_id`, return the trait it implements along with some header information.
11041097
/// Return `None` if this is an inherent impl.
11051098
query impl_trait_header(impl_id: DefId) -> Option<ty::ImplTraitHeader<'tcx>> {

compiler/rustc_resolve/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ resolve_undeclared_label =
432432
433433
resolve_underscore_lifetime_is_reserved = `'_` cannot be used here
434434
.label = `'_` is a reserved lifetime name
435+
.help = use another lifetime specifier
435436
436437
resolve_unexpected_res_change_ty_to_const_param_sugg =
437438
you might have meant to write a const parameter here

compiler/rustc_resolve/src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ pub(crate) struct ImplicitElidedLifetimeNotAllowedHere {
934934

935935
#[derive(Diagnostic)]
936936
#[diag(resolve_underscore_lifetime_is_reserved, code = E0637)]
937+
#[help]
937938
pub(crate) struct UnderscoreLifetimeIsReserved {
938939
#[primary_span]
939940
#[label]

compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub(crate) fn target() -> Target {
1010
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
1111
base.max_atomic_width = Some(64);
1212
base.stack_probes = StackProbeType::Inline;
13+
base.abi = "elfv2".into();
1314
base.llvm_abiname = "elfv2".into();
1415

1516
Target {

compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub(crate) fn target() -> Target {
1010
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
1111
base.max_atomic_width = Some(64);
1212
base.stack_probes = StackProbeType::Inline;
13+
base.abi = "elfv1".into();
1314
base.llvm_abiname = "elfv1".into();
1415

1516
Target {

compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub(crate) fn target() -> Target {
1212
base.stack_probes = StackProbeType::Inline;
1313
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
1414
base.crt_static_default = true;
15+
base.abi = "elfv2".into();
1516
base.llvm_abiname = "elfv2".into();
1617

1718
Target {

compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub(crate) fn target() -> Target {
1010
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
1111
base.max_atomic_width = Some(64);
1212
base.stack_probes = StackProbeType::Inline;
13+
base.abi = "elfv2".into();
1314
base.llvm_abiname = "elfv2".into();
1415

1516
Target {

compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub(crate) fn target() -> Target {
1010
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
1111
base.max_atomic_width = Some(64);
1212
base.stack_probes = StackProbeType::Inline;
13+
base.abi = "elfv1".into();
1314
base.llvm_abiname = "elfv1".into();
1415

1516
Target {

0 commit comments

Comments
 (0)