Skip to content

Commit 4793ef5

Browse files
committed
Auto merge of #146698 - Zalathar:rollup-0oxl4gx, r=Zalathar
Rollup of 5 pull requests Successful merges: - #146566 (Lint more overlapping assignments in MIR.) - #146645 (Cleanup `FnDecl::inner_full_print`) - #146664 (Clean up `ty::Dynamic`) - #146673 (cg_llvm: Replace some DIBuilder wrappers with LLVM-C API bindings (part 4)) - #146694 (Remove ImplSubject) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9311767 + 06cbfd6 commit 4793ef5

File tree

90 files changed

+916
-1038
lines changed

Some content is hidden

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

90 files changed

+916
-1038
lines changed

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
438438

439439
let elaborated_args =
440440
std::iter::zip(*args, &generics.own_params).map(|(arg, param)| {
441-
if let Some(ty::Dynamic(obj, _, ty::Dyn)) = arg.as_type().map(Ty::kind) {
441+
if let Some(ty::Dynamic(obj, _)) = arg.as_type().map(Ty::kind) {
442442
let default = tcx.object_lifetime_default(param.def_id);
443443

444444
let re_static = tcx.lifetimes.re_static;
@@ -464,7 +464,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
464464

465465
has_dyn = true;
466466

467-
Ty::new_dynamic(tcx, obj, implied_region, ty::Dyn).into()
467+
Ty::new_dynamic(tcx, obj, implied_region).into()
468468
} else {
469469
arg
470470
}

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
19031903
| ty::Slice(_)
19041904
| ty::FnDef(_, _)
19051905
| ty::FnPtr(..)
1906-
| ty::Dynamic(_, _, _)
1906+
| ty::Dynamic(_, _)
19071907
| ty::Closure(_, _)
19081908
| ty::CoroutineClosure(_, _)
19091909
| ty::Coroutine(_, _)
@@ -1949,7 +1949,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
19491949
| ty::Ref(_, _, _)
19501950
| ty::FnDef(_, _)
19511951
| ty::FnPtr(..)
1952-
| ty::Dynamic(_, _, _)
1952+
| ty::Dynamic(_, _)
19531953
| ty::CoroutineWitness(..)
19541954
| ty::Never
19551955
| ty::UnsafeBinder(_)

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
14871487
unsize_to: None,
14881488
},
14891489
);
1490-
} else if let ty::Dynamic(src_tty, _src_lt, ty::Dyn) =
1490+
} else if let ty::Dynamic(src_tty, _src_lt) =
14911491
*self.struct_tail(src.ty, location).kind()
1492-
&& let ty::Dynamic(dst_tty, dst_lt, ty::Dyn) =
1492+
&& let ty::Dynamic(dst_tty, dst_lt) =
14931493
*self.struct_tail(dst.ty, location).kind()
14941494
&& src_tty.principal().is_some()
14951495
&& dst_tty.principal().is_some()
@@ -1511,15 +1511,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
15111511
// FIXME: Once we disallow casting `*const dyn Trait + 'short`
15121512
// to `*const dyn Trait + 'long`, then this can just be `src_lt`.
15131513
dst_lt,
1514-
ty::Dyn,
15151514
);
15161515
let dst_obj = Ty::new_dynamic(
15171516
tcx,
15181517
tcx.mk_poly_existential_predicates(
15191518
&dst_tty.without_auto_traits().collect::<Vec<_>>(),
15201519
),
15211520
dst_lt,
1522-
ty::Dyn,
15231521
);
15241522

15251523
debug!(?src_tty, ?dst_tty, ?src_obj, ?dst_obj);

compiler/rustc_codegen_cranelift/src/abi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ pub(crate) fn codegen_drop<'tcx>(
715715
fx.bcx.ins().jump(ret_block, &[]);
716716
} else {
717717
match ty.kind() {
718-
ty::Dynamic(_, _, ty::Dyn) => {
718+
ty::Dynamic(_, _) => {
719719
// IN THIS ARM, WE HAVE:
720720
// ty = *mut (dyn Trait)
721721
// which is: exists<T> ( *mut T, Vtable<T: Trait> )

compiler/rustc_codegen_cranelift/src/unsize.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ pub(crate) fn unsized_info<'tcx>(
3030
fx.pointer_type,
3131
len.try_to_target_usize(fx.tcx).expect("expected monomorphic const in codegen") as i64,
3232
),
33-
(&ty::Dynamic(data_a, _, src_dyn_kind), &ty::Dynamic(data_b, _, target_dyn_kind))
34-
if src_dyn_kind == target_dyn_kind =>
35-
{
33+
(&ty::Dynamic(data_a, _), &ty::Dynamic(data_b, _)) => {
3634
let old_info =
3735
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
3836
let b_principal_def_id = data_b.principal_def_id();

compiler/rustc_codegen_cranelift/src/value_and_place.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ pub(crate) fn assert_assignable<'tcx>(
909909
);
910910
// fn(&T) -> for<'l> fn(&'l T) is allowed
911911
}
912-
(&ty::Dynamic(from_traits, _, _from_kind), &ty::Dynamic(to_traits, _, _to_kind)) => {
913-
// FIXME(dyn-star): Do the right thing with DynKinds
912+
(&ty::Dynamic(from_traits, _), &ty::Dynamic(to_traits, _)) => {
914913
for (from, to) in from_traits.iter().zip(to_traits) {
915914
let from = fx.tcx.normalize_erasing_late_bound_regions(fx.typing_env(), from);
916915
let to = fx.tcx.normalize_erasing_late_bound_regions(fx.typing_env(), to);

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,15 @@ fn build_basic_type_di_node<'ll, 'tcx>(
821821
};
822822

823823
let typedef_di_node = unsafe {
824-
llvm::LLVMRustDIBuilderCreateTypedef(
824+
llvm::LLVMDIBuilderCreateTypedef(
825825
DIB(cx),
826826
ty_di_node,
827-
typedef_name.as_c_char_ptr(),
827+
typedef_name.as_ptr(),
828828
typedef_name.len(),
829829
unknown_file_metadata(cx),
830-
0,
831-
None,
830+
0, // (no line number)
831+
None, // (no scope)
832+
0u32, // (no alignment specified)
832833
)
833834
};
834835

@@ -1034,10 +1035,10 @@ fn create_member_type<'ll, 'tcx>(
10341035
type_di_node: &'ll DIType,
10351036
) -> &'ll DIType {
10361037
unsafe {
1037-
llvm::LLVMRustDIBuilderCreateMemberType(
1038+
llvm::LLVMDIBuilderCreateMemberType(
10381039
DIB(cx),
10391040
owner,
1040-
name.as_c_char_ptr(),
1041+
name.as_ptr(),
10411042
name.len(),
10421043
file_metadata,
10431044
line_number,

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1111
use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty};
1212
use smallvec::smallvec;
1313

14-
use crate::common::{AsCCharPtr, CodegenCx};
14+
use crate::common::CodegenCx;
1515
use crate::debuginfo::dwarf_const::DW_TAG_const_type;
1616
use crate::debuginfo::metadata::enums::DiscrResult;
1717
use crate::debuginfo::metadata::type_map::{self, Stub, UniqueTypeId};
@@ -378,20 +378,17 @@ fn build_single_variant_union_fields<'ll, 'tcx>(
378378
variant_struct_type_wrapper_di_node,
379379
None,
380380
),
381-
unsafe {
382-
llvm::LLVMRustDIBuilderCreateStaticMemberType(
383-
DIB(cx),
384-
enum_type_di_node,
385-
TAG_FIELD_NAME.as_c_char_ptr(),
386-
TAG_FIELD_NAME.len(),
387-
unknown_file_metadata(cx),
388-
UNKNOWN_LINE_NUMBER,
389-
variant_names_type_di_node,
390-
visibility_flags,
391-
Some(cx.const_u64(SINGLE_VARIANT_VIRTUAL_DISR)),
392-
tag_base_type_align.bits() as u32,
393-
)
394-
}
381+
create_static_member_type(
382+
cx,
383+
enum_type_di_node,
384+
TAG_FIELD_NAME,
385+
unknown_file_metadata(cx),
386+
UNKNOWN_LINE_NUMBER,
387+
variant_names_type_di_node,
388+
visibility_flags,
389+
Some(cx.const_u64(SINGLE_VARIANT_VIRTUAL_DISR)),
390+
tag_base_type_align,
391+
),
395392
]
396393
}
397394

@@ -570,27 +567,28 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
570567
let build_assoc_const = |name: &str,
571568
type_di_node_: &'ll DIType,
572569
value: u64,
573-
align: Align| unsafe {
570+
align: Align|
571+
-> &'ll llvm::Metadata {
574572
// FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have
575573
// problems inspecting other value types. Since DISCR_* is typically only going to be
576574
// directly inspected via the debugger visualizer - which compares it to the `tag` value
577575
// (whose type is not modified at all) it shouldn't cause any real problems.
578576
let (t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
579-
(type_di_node_, align.bits() as u32)
577+
(type_di_node_, align)
580578
} else {
581579
let ty_u64 = Ty::new_uint(cx.tcx, ty::UintTy::U64);
582-
(type_di_node(cx, ty_u64), Align::EIGHT.bits() as u32)
580+
(type_di_node(cx, ty_u64), Align::EIGHT)
583581
};
584582

585583
// must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
586-
let field_type =
587-
llvm::LLVMRustDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di);
584+
let field_type = unsafe {
585+
llvm::LLVMDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di)
586+
};
588587

589-
llvm::LLVMRustDIBuilderCreateStaticMemberType(
590-
DIB(cx),
588+
create_static_member_type(
589+
cx,
591590
wrapper_struct_type_di_node,
592-
name.as_c_char_ptr(),
593-
name.len(),
591+
name,
594592
unknown_file_metadata(cx),
595593
UNKNOWN_LINE_NUMBER,
596594
field_type,
@@ -975,3 +973,30 @@ fn variant_struct_wrapper_type_name(variant_index: VariantIdx) -> Cow<'static, s
975973
.map(|&s| Cow::from(s))
976974
.unwrap_or_else(|| format!("Variant{}", variant_index.as_usize()).into())
977975
}
976+
977+
fn create_static_member_type<'ll>(
978+
cx: &CodegenCx<'ll, '_>,
979+
scope: &'ll llvm::Metadata,
980+
name: &str,
981+
file: &'ll llvm::Metadata,
982+
line_number: c_uint,
983+
ty: &'ll llvm::Metadata,
984+
flags: DIFlags,
985+
value: Option<&'ll llvm::Value>,
986+
align: Align,
987+
) -> &'ll llvm::Metadata {
988+
unsafe {
989+
llvm::LLVMDIBuilderCreateStaticMemberType(
990+
DIB(cx),
991+
scope,
992+
name.as_ptr(),
993+
name.len(),
994+
file,
995+
line_number,
996+
ty,
997+
flags,
998+
value,
999+
align.bits() as c_uint,
1000+
)
1001+
}
1002+
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_target::spec::SymbolVisibility;
2424

2525
use super::RustString;
2626
use super::debuginfo::{
27-
DIArray, DIBasicType, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
27+
DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
2828
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
2929
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
3030
};
@@ -1943,6 +1943,52 @@ unsafe extern "C" {
19431943
UniqueId: *const c_uchar, // See "PTR_LEN_STR".
19441944
UniqueIdLen: size_t,
19451945
) -> &'ll Metadata;
1946+
1947+
pub(crate) fn LLVMDIBuilderCreateMemberType<'ll>(
1948+
Builder: &DIBuilder<'ll>,
1949+
Scope: &'ll Metadata,
1950+
Name: *const c_uchar, // See "PTR_LEN_STR".
1951+
NameLen: size_t,
1952+
File: &'ll Metadata,
1953+
LineNo: c_uint,
1954+
SizeInBits: u64,
1955+
AlignInBits: u32,
1956+
OffsetInBits: u64,
1957+
Flags: DIFlags,
1958+
Ty: &'ll Metadata,
1959+
) -> &'ll Metadata;
1960+
1961+
pub(crate) fn LLVMDIBuilderCreateStaticMemberType<'ll>(
1962+
Builder: &DIBuilder<'ll>,
1963+
Scope: &'ll Metadata,
1964+
Name: *const c_uchar, // See "PTR_LEN_STR".
1965+
NameLen: size_t,
1966+
File: &'ll Metadata,
1967+
LineNumber: c_uint,
1968+
Type: &'ll Metadata,
1969+
Flags: DIFlags,
1970+
ConstantVal: Option<&'ll Value>,
1971+
AlignInBits: u32,
1972+
) -> &'ll Metadata;
1973+
1974+
/// Creates a "qualified type" in the C/C++ sense, by adding modifiers
1975+
/// like `const` or `volatile`.
1976+
pub(crate) fn LLVMDIBuilderCreateQualifiedType<'ll>(
1977+
Builder: &DIBuilder<'ll>,
1978+
Tag: c_uint, // (DWARF tag, e.g. `DW_TAG_const_type`)
1979+
Type: &'ll Metadata,
1980+
) -> &'ll Metadata;
1981+
1982+
pub(crate) fn LLVMDIBuilderCreateTypedef<'ll>(
1983+
Builder: &DIBuilder<'ll>,
1984+
Type: &'ll Metadata,
1985+
Name: *const c_uchar, // See "PTR_LEN_STR".
1986+
NameLen: size_t,
1987+
File: &'ll Metadata,
1988+
LineNo: c_uint,
1989+
Scope: Option<&'ll Metadata>,
1990+
AlignInBits: u32, // (optional; default is 0)
1991+
) -> &'ll Metadata;
19461992
}
19471993

19481994
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2278,30 +2324,6 @@ unsafe extern "C" {
22782324
TParam: &'a DIArray,
22792325
) -> &'a DISubprogram;
22802326

2281-
pub(crate) fn LLVMRustDIBuilderCreateTypedef<'a>(
2282-
Builder: &DIBuilder<'a>,
2283-
Type: &'a DIBasicType,
2284-
Name: *const c_char,
2285-
NameLen: size_t,
2286-
File: &'a DIFile,
2287-
LineNo: c_uint,
2288-
Scope: Option<&'a DIScope>,
2289-
) -> &'a DIDerivedType;
2290-
2291-
pub(crate) fn LLVMRustDIBuilderCreateMemberType<'a>(
2292-
Builder: &DIBuilder<'a>,
2293-
Scope: &'a DIDescriptor,
2294-
Name: *const c_char,
2295-
NameLen: size_t,
2296-
File: &'a DIFile,
2297-
LineNo: c_uint,
2298-
SizeInBits: u64,
2299-
AlignInBits: u32,
2300-
OffsetInBits: u64,
2301-
Flags: DIFlags,
2302-
Ty: &'a DIType,
2303-
) -> &'a DIDerivedType;
2304-
23052327
pub(crate) fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
23062328
Builder: &DIBuilder<'a>,
23072329
Scope: &'a DIScope,
@@ -2317,25 +2339,6 @@ unsafe extern "C" {
23172339
Ty: &'a DIType,
23182340
) -> &'a DIType;
23192341

2320-
pub(crate) fn LLVMRustDIBuilderCreateStaticMemberType<'a>(
2321-
Builder: &DIBuilder<'a>,
2322-
Scope: &'a DIDescriptor,
2323-
Name: *const c_char,
2324-
NameLen: size_t,
2325-
File: &'a DIFile,
2326-
LineNo: c_uint,
2327-
Ty: &'a DIType,
2328-
Flags: DIFlags,
2329-
val: Option<&'a Value>,
2330-
AlignInBits: u32,
2331-
) -> &'a DIDerivedType;
2332-
2333-
pub(crate) fn LLVMRustDIBuilderCreateQualifiedType<'a>(
2334-
Builder: &DIBuilder<'a>,
2335-
Tag: c_uint,
2336-
Type: &'a DIType,
2337-
) -> &'a DIDerivedType;
2338-
23392342
pub(crate) fn LLVMRustDIBuilderCreateStaticVariable<'a>(
23402343
Builder: &DIBuilder<'a>,
23412344
Context: Option<&'a DIScope>,

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
168168
(&ty::Array(_, len), &ty::Slice(_)) => cx.const_usize(
169169
len.try_to_target_usize(cx.tcx()).expect("expected monomorphic const in codegen"),
170170
),
171-
(&ty::Dynamic(data_a, _, src_dyn_kind), &ty::Dynamic(data_b, _, target_dyn_kind))
172-
if src_dyn_kind == target_dyn_kind =>
173-
{
171+
(&ty::Dynamic(data_a, _), &ty::Dynamic(data_b, _)) => {
174172
let old_info =
175173
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
176174
let b_principal_def_id = data_b.principal_def_id();
@@ -208,7 +206,7 @@ fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
208206
old_info
209207
}
210208
}
211-
(_, ty::Dynamic(data, _, _)) => meth::get_vtable(
209+
(_, ty::Dynamic(data, _)) => meth::get_vtable(
212210
cx,
213211
source,
214212
data.principal()

0 commit comments

Comments
 (0)