Skip to content

Commit 5986ff0

Browse files
committed
Auto merge of rust-lang#137248 - matthiaskrgr:rollup-s18zjau, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#136936 (Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto') - rust-lang#137026 (Stabilize (and const-stabilize) `integer_sign_cast`) - rust-lang#137059 (fix: Alloc new errorcode E0803 for E0495) - rust-lang#137177 (Update `minifier-rs` version to `0.3.5`) - rust-lang#137210 (compiler: Stop reexporting stuff in cg_llvm::abi) - rust-lang#137213 (Remove `rustc_middle::mir::tcx` module.) - rust-lang#137216 (eval_outlives: bail out early if both regions are in the same SCC) - rust-lang#137228 (Fix typo in hidden internal docs of `TrustedRandomAccess`) - rust-lang#137242 (Add reference annotations for the `do_not_recommend` attribute) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 17c1c32 + 24ba1ad commit 5986ff0

File tree

64 files changed

+585
-546
lines changed

Some content is hidden

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

64 files changed

+585
-546
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2211,9 +2211,9 @@ dependencies = [
22112211

22122212
[[package]]
22132213
name = "minifier"
2214-
version = "0.3.4"
2214+
version = "0.3.5"
22152215
source = "registry+https://github.com/rust-lang/crates.io-index"
2216-
checksum = "1cf47565b1430f5fe6c81d3afcb4b835271348d7eb35294a4d592e38dd09ea22"
2216+
checksum = "9bfdc64e2f805f3d12965f10522000bae36e88d2cfea44112331f467d4f4bf68"
22172217

22182218
[[package]]
22192219
name = "minimal-lexical"

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ use rustc_hir::intravisit::{Visitor, walk_block, walk_expr};
1818
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField};
1919
use rustc_middle::bug;
2020
use rustc_middle::hir::nested_filter::OnlyBodies;
21-
use rustc_middle::mir::tcx::PlaceTy;
2221
use rustc_middle::mir::{
2322
self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, ConstraintCategory,
2423
FakeBorrowKind, FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, MutBorrowKind,
25-
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
26-
TerminatorKind, VarBindingForm, VarDebugInfoContents,
24+
Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement, StatementKind,
25+
Terminator, TerminatorKind, VarBindingForm, VarDebugInfoContents,
2726
};
2827
use rustc_middle::ty::print::PrintTraitRefExt as _;
2928
use rustc_middle::ty::{

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ use rustc_infer::infer::{
1313
};
1414
use rustc_infer::traits::SelectionError;
1515
use rustc_middle::bug;
16-
use rustc_middle::mir::tcx::PlaceTy;
1716
use rustc_middle::mir::{
1817
AggregateKind, CallSource, ConstOperand, ConstraintCategory, FakeReadCause, Local, LocalInfo,
19-
LocalKind, Location, Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement,
18+
LocalKind, Location, Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement,
2019
StatementKind, Terminator, TerminatorKind, find_self_call,
2120
};
2221
use rustc_middle::ty::print::Print;

compiler/rustc_borrowck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use rustc_index::{IndexSlice, IndexVec};
3333
use rustc_infer::infer::{
3434
InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
3535
};
36-
use rustc_middle::mir::tcx::PlaceTy;
3736
use rustc_middle::mir::*;
3837
use rustc_middle::query::Providers;
3938
use rustc_middle::ty::fold::fold_regions;

compiler/rustc_borrowck/src/region_infer/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12671267
let sub_region_scc = self.constraint_sccs.scc(sub_region);
12681268
let sup_region_scc = self.constraint_sccs.scc(sup_region);
12691269

1270+
if sub_region_scc == sup_region_scc {
1271+
debug!("{sup_region:?}: {sub_region:?} holds trivially; they are in the same SCC");
1272+
return true;
1273+
}
1274+
12701275
// If we are checking that `'sup: 'sub`, and `'sub` contains
12711276
// some placeholder that `'sup` cannot name, then this is only
12721277
// true if `'sup` outlives static.

compiler/rustc_borrowck/src/type_check/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_infer::infer::{
1919
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
2020
};
2121
use rustc_infer::traits::PredicateObligations;
22-
use rustc_middle::mir::tcx::PlaceTy;
2322
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
2423
use rustc_middle::mir::*;
2524
use rustc_middle::traits::query::NoSolution;

compiler/rustc_codegen_llvm/src/abi.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ use std::borrow::Borrow;
22
use std::cmp;
33

44
use libc::c_uint;
5-
use rustc_abi as abi;
6-
pub(crate) use rustc_abi::ExternAbi;
7-
use rustc_abi::{HasDataLayout, Primitive, Reg, RegKind, Size};
5+
use rustc_abi::{BackendRepr, HasDataLayout, Primitive, Reg, RegKind, Size};
86
use rustc_codegen_ssa::MemFlags;
97
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
108
use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue};
119
use rustc_codegen_ssa::traits::*;
1210
use rustc_middle::ty::Ty;
1311
use rustc_middle::ty::layout::LayoutOf;
14-
pub(crate) use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA};
1512
use rustc_middle::{bug, ty};
1613
use rustc_session::config;
17-
pub(crate) use rustc_target::callconv::*;
14+
use rustc_target::callconv::{
15+
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, Conv, FnAbi, PassMode,
16+
};
1817
use rustc_target::spec::SanitizerSet;
1918
use smallvec::SmallVec;
2019

@@ -458,7 +457,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
458457
match &self.ret.mode {
459458
PassMode::Direct(attrs) => {
460459
attrs.apply_attrs_to_llfn(llvm::AttributePlace::ReturnValue, cx, llfn);
461-
if let abi::BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr {
460+
if let BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr {
462461
apply_range_attr(llvm::AttributePlace::ReturnValue, scalar);
463462
}
464463
}
@@ -499,7 +498,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
499498
}
500499
PassMode::Direct(attrs) => {
501500
let i = apply(attrs);
502-
if let abi::BackendRepr::Scalar(scalar) = arg.layout.backend_repr {
501+
if let BackendRepr::Scalar(scalar) = arg.layout.backend_repr {
503502
apply_range_attr(llvm::AttributePlace::Argument(i), scalar);
504503
}
505504
}
@@ -514,9 +513,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
514513
PassMode::Pair(a, b) => {
515514
let i = apply(a);
516515
let ii = apply(b);
517-
if let abi::BackendRepr::ScalarPair(scalar_a, scalar_b) =
518-
arg.layout.backend_repr
519-
{
516+
if let BackendRepr::ScalarPair(scalar_a, scalar_b) = arg.layout.backend_repr {
520517
apply_range_attr(llvm::AttributePlace::Argument(i), scalar_a);
521518
apply_range_attr(llvm::AttributePlace::Argument(ii), scalar_b);
522519
}
@@ -576,7 +573,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
576573
}
577574
if bx.cx.sess().opts.optimize != config::OptLevel::No
578575
&& llvm_util::get_version() < (19, 0, 0)
579-
&& let abi::BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr
576+
&& let BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr
580577
&& matches!(scalar.primitive(), Primitive::Int(..))
581578
// If the value is a boolean, the range is 0..2 and that ultimately
582579
// become 0..0 when the type becomes i1, which would be rejected

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use rustc_codegen_ssa::traits::*;
1111
use rustc_hir::def::{CtorKind, DefKind};
1212
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1313
use rustc_middle::bug;
14-
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf, TyAndLayout};
14+
use rustc_middle::ty::layout::{
15+
HasTypingEnv, LayoutOf, TyAndLayout, WIDE_PTR_ADDR, WIDE_PTR_EXTRA,
16+
};
1517
use rustc_middle::ty::{
1618
self, AdtKind, CoroutineArgsExt, ExistentialTraitRef, Instance, Ty, TyCtxt, Visibility,
1719
};
@@ -34,12 +36,12 @@ use crate::common::{AsCCharPtr, CodegenCx};
3436
use crate::debuginfo::dwarf_const;
3537
use crate::debuginfo::metadata::type_map::build_type_with_children;
3638
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
39+
use crate::llvm;
3740
use crate::llvm::debuginfo::{
3841
DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
3942
DebugNameTableKind,
4043
};
4144
use crate::value::Value;
42-
use crate::{abi, llvm};
4345

4446
impl PartialEq for llvm::Metadata {
4547
fn eq(&self, other: &Self) -> bool {
@@ -211,16 +213,16 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
211213
};
212214

213215
let layout = cx.layout_of(layout_type);
214-
let addr_field = layout.field(cx, abi::WIDE_PTR_ADDR);
215-
let extra_field = layout.field(cx, abi::WIDE_PTR_EXTRA);
216+
let addr_field = layout.field(cx, WIDE_PTR_ADDR);
217+
let extra_field = layout.field(cx, WIDE_PTR_EXTRA);
216218

217219
let (addr_field_name, extra_field_name) = match wide_pointer_kind {
218220
WidePtrKind::Dyn => ("pointer", "vtable"),
219221
WidePtrKind::Slice => ("data_ptr", "length"),
220222
};
221223

222-
assert_eq!(abi::WIDE_PTR_ADDR, 0);
223-
assert_eq!(abi::WIDE_PTR_EXTRA, 1);
224+
assert_eq!(WIDE_PTR_ADDR, 0);
225+
assert_eq!(WIDE_PTR_EXTRA, 1);
224226

225227
// The data pointer type is a regular, thin pointer, regardless of whether this
226228
// is a slice or a trait object.
@@ -242,7 +244,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
242244
owner,
243245
addr_field_name,
244246
(addr_field.size, addr_field.align.abi),
245-
layout.fields.offset(abi::WIDE_PTR_ADDR),
247+
layout.fields.offset(WIDE_PTR_ADDR),
246248
DIFlags::FlagZero,
247249
data_ptr_type_di_node,
248250
None,
@@ -252,7 +254,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
252254
owner,
253255
extra_field_name,
254256
(extra_field.size, extra_field.align.abi),
255-
layout.fields.offset(abi::WIDE_PTR_EXTRA),
257+
layout.fields.offset(WIDE_PTR_EXTRA),
256258
DIFlags::FlagZero,
257259
type_di_node(cx, extra_field.ty),
258260
None,

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ use rustc_session::config::{self, DebugInfo};
2222
use rustc_span::{
2323
BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span, StableSourceFileId, Symbol,
2424
};
25+
use rustc_target::callconv::FnAbi;
2526
use rustc_target::spec::DebuginfoKind;
2627
use smallvec::SmallVec;
2728
use tracing::debug;
2829

2930
use self::metadata::{UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER, file_metadata, type_di_node};
3031
use self::namespace::mangled_name_of_instance;
3132
use self::utils::{DIB, create_DIArray, is_node_local_to_unit};
32-
use crate::abi::FnAbi;
3333
use crate::builder::Builder;
3434
use crate::common::{AsCCharPtr, CodegenCx};
3535
use crate::llvm;

compiler/rustc_codegen_llvm/src/declare.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ use rustc_codegen_ssa::traits::TypeMembershipCodegenMethods;
1616
use rustc_data_structures::fx::FxIndexSet;
1717
use rustc_middle::ty::{Instance, Ty};
1818
use rustc_sanitizers::{cfi, kcfi};
19+
use rustc_target::callconv::FnAbi;
1920
use smallvec::SmallVec;
2021
use tracing::debug;
2122

22-
use crate::abi::{FnAbi, FnAbiLlvmExt};
23+
use crate::abi::FnAbiLlvmExt;
2324
use crate::common::AsCCharPtr;
2425
use crate::context::{CodegenCx, SimpleCx};
2526
use crate::llvm::AttributePlace::Function;

compiler/rustc_codegen_llvm/src/intrinsic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::assert_matches::assert_matches;
22
use std::cmp::Ordering;
33

4-
use rustc_abi::{self as abi, Align, Float, HasDataLayout, Primitive, Size};
4+
use rustc_abi::{Align, BackendRepr, ExternAbi, Float, HasDataLayout, Primitive, Size};
55
use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh};
66
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
77
use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization};
@@ -14,10 +14,11 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
1414
use rustc_middle::ty::{self, GenericArgsRef, Ty};
1515
use rustc_middle::{bug, span_bug};
1616
use rustc_span::{Span, Symbol, sym};
17+
use rustc_target::callconv::{FnAbi, PassMode};
1718
use rustc_target::spec::{HasTargetSpec, PanicStrategy};
1819
use tracing::debug;
1920

20-
use crate::abi::{ExternAbi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode};
21+
use crate::abi::{FnAbiLlvmExt, LlvmType};
2122
use crate::builder::Builder;
2223
use crate::context::CodegenCx;
2324
use crate::llvm::{self, Metadata};
@@ -257,7 +258,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
257258
}
258259
sym::va_arg => {
259260
match fn_abi.ret.layout.backend_repr {
260-
abi::BackendRepr::Scalar(scalar) => {
261+
BackendRepr::Scalar(scalar) => {
261262
match scalar.primitive() {
262263
Primitive::Int(..) => {
263264
if self.cx().size_of(ret_ty).bytes() < 4 {
@@ -470,7 +471,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
470471
}
471472

472473
sym::raw_eq => {
473-
use abi::BackendRepr::*;
474+
use BackendRepr::*;
474475
let tp_ty = fn_args.type_at(0);
475476
let layout = self.layout_of(tp_ty).layout;
476477
let use_integer_compare = match layout.backend_repr() {
@@ -582,8 +583,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
582583
}
583584

584585
let llret_ty = if ret_ty.is_simd()
585-
&& let abi::BackendRepr::Memory { .. } =
586-
self.layout_of(ret_ty).layout.backend_repr
586+
&& let BackendRepr::Memory { .. } = self.layout_of(ret_ty).layout.backend_repr
587587
{
588588
let (size, elem_ty) = ret_ty.simd_size_and_type(self.tcx());
589589
let elem_ll_ty = match elem_ty.kind() {

compiler/rustc_codegen_ssa/src/mir/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_abi::Primitive::{Int, Pointer};
22
use rustc_abi::{Align, BackendRepr, FieldsShape, Size, TagEncoding, VariantIdx, Variants};
3+
use rustc_middle::mir::PlaceTy;
34
use rustc_middle::mir::interpret::Scalar;
4-
use rustc_middle::mir::tcx::PlaceTy;
55
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
66
use rustc_middle::ty::{self, Ty};
77
use rustc_middle::{bug, mir};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
A trait implementation returns a reference without an
2+
explicit lifetime linking it to `self`.
3+
It commonly arises in generic trait implementations
4+
requiring explicit lifetime bounds.
5+
6+
Erroneous code example:
7+
8+
```compile_fail,E0803
9+
trait DataAccess<T> {
10+
fn get_ref(&self) -> T;
11+
}
12+
13+
struct Container<'a> {
14+
value: &'a f64,
15+
}
16+
17+
// Attempting to implement reference return
18+
impl<'a> DataAccess<&f64> for Container<'a> {
19+
fn get_ref(&self) -> &f64 { // Error: Lifetime mismatch
20+
self.value
21+
}
22+
}
23+
```
24+
25+
The trait method returns &f64 requiring an independent lifetime
26+
The struct Container<'a> carries lifetime parameter 'a
27+
The compiler cannot verify if the returned reference satisfies 'a constraints
28+
Solution
29+
Explicitly bind lifetimes to clarify constraints:
30+
```
31+
// Modified trait with explicit lifetime binding
32+
trait DataAccess<'a, T> {
33+
fn get_ref(&'a self) -> T;
34+
}
35+
36+
struct Container<'a> {
37+
value: &'a f64,
38+
}
39+
40+
// Correct implementation (bound lifetimes)
41+
impl<'a> DataAccess<'a, &'a f64> for Container<'a> {
42+
fn get_ref(&'a self) -> &'a f64 {
43+
self.value
44+
}
45+
}
46+
```

compiler/rustc_error_codes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ E0799: 0799,
546546
E0800: 0800,
547547
E0801: 0801,
548548
E0802: 0802,
549+
E0803: 0803,
549550
);
550551
)
551552
}

compiler/rustc_middle/src/mir/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub mod pretty;
5353
mod query;
5454
mod statement;
5555
mod syntax;
56-
pub mod tcx;
5756
mod terminator;
5857

5958
pub mod traversal;

0 commit comments

Comments
 (0)