Skip to content

Commit 2ea60dd

Browse files
committed
Auto merge of #154374 - lqd:rename-metasized, r=<try>
Rename `MetaSized` trait to `SizeOfVal` try-job: dist-x86_64-linux
2 parents 64d5cb6 + 13cbf33 commit 2ea60dd

155 files changed

Lines changed: 704 additions & 706 deletions

File tree

Some content is hidden

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

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#[lang = "pointee_sized"]
1919
pub trait PointeeSized {}
2020

21-
#[lang = "meta_sized"]
22-
pub trait MetaSized: PointeeSized {}
21+
#[lang = "size_of_val"]
22+
pub trait SizeOfVal: PointeeSized {}
2323

2424
#[lang = "sized"]
25-
pub trait Sized: MetaSized {}
25+
pub trait Sized: SizeOfVal {}
2626

2727
#[lang = "destruct"]
2828
pub trait Destruct {}
@@ -52,14 +52,14 @@ impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U
5252
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
5353
// *mut T -> *mut U
5454
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
55-
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U>> for Box<T> {}
55+
impl<T: SizeOfVal + Unsize<U>, U: SizeOfVal> DispatchFromDyn<Box<U>> for Box<T> {}
5656

5757
#[lang = "legacy_receiver"]
5858
pub trait LegacyReceiver {}
5959

6060
impl<T: PointeeSized> LegacyReceiver for &T {}
6161
impl<T: PointeeSized> LegacyReceiver for &mut T {}
62-
impl<T: MetaSized> LegacyReceiver for Box<T> {}
62+
impl<T: SizeOfVal> LegacyReceiver for Box<T> {}
6363

6464
#[lang = "copy"]
6565
pub trait Copy {}

compiler/rustc_codegen_gcc/example/mini_core.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ unsafe extern "C" fn _Unwind_Resume() {
2222
#[lang = "pointee_sized"]
2323
pub trait PointeeSized {}
2424

25-
#[lang = "meta_sized"]
26-
pub trait MetaSized: PointeeSized {}
25+
#[lang = "size_of_val"]
26+
pub trait SizeOfVal: PointeeSized {}
2727

2828
#[lang = "sized"]
29-
pub trait Sized: MetaSized {}
29+
pub trait Sized: SizeOfVal {}
3030

3131
#[lang = "destruct"]
3232
pub trait Destruct {}
@@ -56,14 +56,14 @@ impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U
5656
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
5757
// *mut T -> *mut U
5858
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
59-
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
59+
impl<T: SizeOfVal + Unsize<U>, U: SizeOfVal> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
6060

6161
#[lang = "legacy_receiver"]
6262
pub trait LegacyReceiver {}
6363

6464
impl<T: PointeeSized> LegacyReceiver for &T {}
6565
impl<T: PointeeSized> LegacyReceiver for &mut T {}
66-
impl<T: MetaSized> LegacyReceiver for Box<T> {}
66+
impl<T: SizeOfVal> LegacyReceiver for Box<T> {}
6767

6868
#[lang = "receiver"]
6969
trait Receiver {}

compiler/rustc_codegen_gcc/tests/run/simd-ffi.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
6262
#[lang = "pointee_sized"]
6363
pub trait PointeeSized {}
6464

65-
#[lang = "meta_sized"]
66-
pub trait MetaSized: PointeeSized {}
65+
#[lang = "size_of_val"]
66+
pub trait SizeOfVal: PointeeSized {}
6767

6868
#[lang = "sized"]
69-
pub trait Sized: MetaSized {}
69+
pub trait Sized: SizeOfVal {}
7070

7171
#[lang = "copy"]
7272
pub trait Copy {}

compiler/rustc_hir/src/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<CTX> HashStable<CTX> for LangItem {
153153
language_item_table! {
154154
// Variant name, Name, Getter method name, Target Generic requirements;
155155
Sized, sym::sized, sized_trait, Target::Trait, GenericRequirement::Exact(0);
156-
MetaSized, sym::meta_sized, meta_sized_trait, Target::Trait, GenericRequirement::Exact(0);
156+
SizeOfVal, sym::size_of_val, size_of_val_trait, Target::Trait, GenericRequirement::Exact(0);
157157
PointeeSized, sym::pointee_sized, pointee_sized_trait, Target::Trait, GenericRequirement::Exact(0);
158158
Unsize, sym::unsize, unsize_trait, Target::Trait, GenericRequirement::Minimum(1);
159159
AlignOf, sym::mem_align_const, align_const, Target::AssocConst, GenericRequirement::Exact(0);

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ fn bounds_from_generic_predicates<'tcx>(
376376
projections_str.push(format!("{} = {}", name, p.term));
377377
}
378378
}
379-
let bound_def_path = if tcx.is_lang_item(bound, LangItem::MetaSized) {
379+
let bound_def_path = if tcx.is_lang_item(bound, LangItem::SizeOfVal) {
380380
String::from("?Sized")
381381
} else {
382382
tcx.def_path_str(bound)

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ impl CollectedBound {
4444
struct CollectedSizednessBounds {
4545
// Collected `Sized` bounds
4646
sized: CollectedBound,
47-
// Collected `MetaSized` bounds
48-
meta_sized: CollectedBound,
47+
// Collected `SizeOfVal` bounds
48+
size_of_val: CollectedBound,
4949
// Collected `PointeeSized` bounds
5050
pointee_sized: CollectedBound,
5151
}
5252

5353
impl CollectedSizednessBounds {
5454
/// Returns `true` if any of `Trait`, `?Trait` or `!Trait` were encountered for `Sized`,
55-
/// `MetaSized` or `PointeeSized`.
55+
/// `SizeOfVal` or `PointeeSized`.
5656
fn any(&self) -> bool {
57-
self.sized.any() || self.meta_sized.any() || self.pointee_sized.any()
57+
self.sized.any() || self.size_of_val.any() || self.pointee_sized.any()
5858
}
5959
}
6060

@@ -127,13 +127,13 @@ fn collect_sizedness_bounds<'tcx>(
127127
let sized_did = tcx.require_lang_item(hir::LangItem::Sized, span);
128128
let sized = collect_bounds(hir_bounds, context, sized_did);
129129

130-
let meta_sized_did = tcx.require_lang_item(hir::LangItem::MetaSized, span);
131-
let meta_sized = collect_bounds(hir_bounds, context, meta_sized_did);
130+
let size_of_val_did = tcx.require_lang_item(hir::LangItem::SizeOfVal, span);
131+
let size_of_val = collect_bounds(hir_bounds, context, size_of_val_did);
132132

133133
let pointee_sized_did = tcx.require_lang_item(hir::LangItem::PointeeSized, span);
134134
let pointee_sized = collect_bounds(hir_bounds, context, pointee_sized_did);
135135

136-
CollectedSizednessBounds { sized, meta_sized, pointee_sized }
136+
CollectedSizednessBounds { sized, size_of_val, pointee_sized }
137137
}
138138

139139
/// Add a trait bound for `did`.
@@ -155,9 +155,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
155155
///
156156
/// - On parameters, opaque type and associated types, add default `Sized` bound if no explicit
157157
/// sizedness bounds are present.
158-
/// - On traits and trait aliases, add default `MetaSized` supertrait if no explicit sizedness
158+
/// - On traits and trait aliases, add default `SizeOfVal` supertrait if no explicit sizedness
159159
/// bounds are present.
160-
/// - On parameters, opaque type, associated types and trait aliases, add a `MetaSized` bound if
160+
/// - On parameters, opaque type, associated types and trait aliases, add a `SizeOfVal` bound if
161161
/// a `?Sized` bound is present.
162162
pub(crate) fn add_implicit_sizedness_bounds(
163163
&self,
@@ -174,7 +174,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
174174
return;
175175
}
176176

177-
let meta_sized_did = tcx.require_lang_item(hir::LangItem::MetaSized, span);
177+
let size_of_val_did = tcx.require_lang_item(hir::LangItem::SizeOfVal, span);
178178
let pointee_sized_did = tcx.require_lang_item(hir::LangItem::PointeeSized, span);
179179

180180
// If adding sizedness bounds to a trait, then there are some relevant early exits
@@ -210,18 +210,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
210210
let collected = collect_sizedness_bounds(tcx, hir_bounds, context, span);
211211
if (collected.sized.maybe || collected.sized.negative)
212212
&& !collected.sized.positive
213-
&& !collected.meta_sized.any()
213+
&& !collected.size_of_val.any()
214214
&& !collected.pointee_sized.any()
215215
{
216-
// `?Sized` is equivalent to `MetaSized` (but only add the bound if there aren't any
216+
// `?Sized` is equivalent to `SizeOfVal` (but only add the bound if there aren't any
217217
// other explicit ones) - this can happen for trait aliases as well as bounds.
218-
add_trait_bound(tcx, bounds, self_ty, meta_sized_did, span);
218+
add_trait_bound(tcx, bounds, self_ty, size_of_val_did, span);
219219
} else if !collected.any() {
220220
match context {
221221
ImpliedBoundsContext::TraitDef(..) => {
222222
// If there are no explicit sizedness bounds on a trait then add a default
223-
// `MetaSized` supertrait.
224-
add_trait_bound(tcx, bounds, self_ty, meta_sized_did, span);
223+
// `SizeOfVal` supertrait.
224+
add_trait_bound(tcx, bounds, self_ty, size_of_val_did, span);
225225
}
226226
ImpliedBoundsContext::TyParam(..)
227227
| ImpliedBoundsContext::AssociatedTypeOrImplTrait => {

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
9292

9393
// FIXME(sized-hierarchy): https://github.com/rust-lang/rust/pull/142712#issuecomment-3013231794
9494
debug!(?user_written_bounds, ?elaborated_trait_bounds);
95-
let meta_sized_did = tcx.require_lang_item(LangItem::MetaSized, span);
96-
// Don't strip out `MetaSized` when the user wrote it explicitly, only when it was
95+
let size_of_val_did = tcx.require_lang_item(LangItem::SizeOfVal, span);
96+
// Don't strip out `SizeOfVal` when the user wrote it explicitly, only when it was
9797
// elaborated
98-
if user_written_bounds
99-
.iter()
100-
.all(|(clause, _)| clause.as_trait_clause().map(|p| p.def_id()) != Some(meta_sized_did))
101-
{
102-
elaborated_trait_bounds.retain(|(pred, _)| pred.def_id() != meta_sized_did);
98+
if user_written_bounds.iter().all(|(clause, _)| {
99+
clause.as_trait_clause().map(|p| p.def_id()) != Some(size_of_val_did)
100+
}) {
101+
elaborated_trait_bounds.retain(|(pred, _)| pred.def_id() != size_of_val_did);
103102
}
104103
debug!(?user_written_bounds, ?elaborated_trait_bounds);
105104

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use crate::{NoVariantNamed, check_c_variadic_abi};
6262
#[derive(Clone, Copy)]
6363
pub(crate) enum ImpliedBoundsContext<'tcx> {
6464
/// An implied bound is added to a trait definition (i.e. a new supertrait), used when adding
65-
/// a default `MetaSized` supertrait
65+
/// a default `SizeOfVal` supertrait
6666
TraitDef(LocalDefId),
6767
/// An implied bound is added to a type parameter
6868
TyParam(LocalDefId, &'tcx [hir::WherePredicate<'tcx>]),

compiler/rustc_lint/src/multiple_supertrait_upcastable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
4747
.explicit_super_predicates_of(def_id)
4848
.iter_identity_copied()
4949
.filter_map(|(pred, _)| pred.as_trait_clause())
50-
.filter(|pred| !cx.tcx.is_lang_item(pred.def_id(), hir::LangItem::MetaSized))
50+
.filter(|pred| !cx.tcx.is_lang_item(pred.def_id(), hir::LangItem::SizeOfVal))
5151
.filter(|pred| !cx.tcx.is_default_trait(pred.def_id()));
5252
if direct_super_traits_iter.count() > 1 {
5353
cx.emit_span_lint(

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ impl<'tcx> TyCtxt<'tcx> {
990990
}
991991

992992
pub fn is_sizedness_trait(self, def_id: DefId) -> bool {
993-
matches!(self.as_lang_item(def_id), Some(LangItem::Sized | LangItem::MetaSized))
993+
matches!(self.as_lang_item(def_id), Some(LangItem::Sized | LangItem::SizeOfVal))
994994
}
995995

996996
/// Returns a range of the start/end indices specified with the

0 commit comments

Comments
 (0)