Skip to content

Commit aebb289

Browse files
FractalFirestebank
andauthored
Apply suggestions from code review
Co-authored-by: Esteban Kuber <[email protected]>
1 parent 27fd195 commit aebb289

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

compiler/rustc_middle/src/ty/instance.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'tcx> Instance<'tcx> {
639639
self.def.has_polymorphic_mir_body().then_some(self.args)
640640
}
641641

642-
/// Instantiates a generic value `v`(like `Vec<T>`), substituting its generic arguments and turning it into a concrete one(like `i32`, or `Vec<f32>`).
642+
/// Instantiates a generic value `v` (like `Vec<T>`), substituting its generic arguments and turning it into a concrete one (like `i32` or `Vec<f32>`).
643643
/// If a value is not generic, this will do nothing.
644644
/// This function does not erase lifetimes, so a value like `&'a i32` will remain unchanged.
645645
/// For monomorphizing generics while also erasing lifetimes, try using [`Self::instantiate_mir_and_normalize_erasing_regions`].
@@ -655,7 +655,7 @@ impl<'tcx> Instance<'tcx> {
655655
}
656656
}
657657

658-
/// Instantiates a generic value `v`(like `Vec<T>`), substituting its generic arguments and turning it into a concrete one(like `i32`, or `Vec<f32>`).
658+
/// Instantiates a generic value `v` (like `Vec<T>`), substituting its generic arguments and turning it into a concrete one (like `i32` or `Vec<f32>`).
659659
/// This function erases lifetimes, so a value like `&'a i32` will become `&ReErased i32`.
660660
/// If a value is not generic and has no lifetime info, this will do nothing.
661661
/// For monomorphizing generics while preserving lifetimes, use [`Self::instantiate_mir`].

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ impl<'tcx> FnSig<'tcx> {
13451345
pub fn inputs(&self) -> &'tcx [Ty<'tcx>] {
13461346
&self.inputs_and_output[..self.inputs_and_output.len() - 1]
13471347
}
1348-
/// The return type of this siganture.
1348+
/// The return type of this signature.
13491349
pub fn output(&self) -> Ty<'tcx> {
13501350
self.inputs_and_output[self.inputs_and_output.len() - 1]
13511351
}
@@ -2037,7 +2037,7 @@ impl<'tcx> Ty<'tcx> {
20372037
}
20382038
}
20392039

2040-
/// Creates a new [`Ty`] representing a reference to type `tm.ty` with mutability `tm.mutbl` in region `r`.
2040+
/// Creates a reference with type and mutability for a certain [`Region`].
20412041
#[inline]
20422042
pub fn new_ref(tcx: TyCtxt<'tcx>, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
20432043
Ty::new(tcx, Ref(r, tm.ty, tm.mutbl))
@@ -2105,13 +2105,13 @@ impl<'tcx> Ty<'tcx> {
21052105
Ty::new(tcx, Slice(ty))
21062106
}
21072107

2108-
/// Creates a new [`Ty`] representing a tuple contining `ts` types.
2108+
/// Create a new tuple type.
21092109
#[inline]
21102110
pub fn new_tup(tcx: TyCtxt<'tcx>, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
21112111
if ts.is_empty() { tcx.types.unit } else { Ty::new(tcx, Tuple(tcx.mk_type_list(ts))) }
21122112
}
21132113

2114-
/// Creates a new [`Ty`] representing a tuple contining types from the iterator `iter`.
2114+
/// Create a new [`Ty`] representing a tuple containing types from an iterator.
21152115
pub fn new_tup_from_iter<I, T>(tcx: TyCtxt<'tcx>, iter: I) -> T::Output
21162116
where
21172117
I: Iterator<Item = T>,
@@ -2120,7 +2120,7 @@ impl<'tcx> Ty<'tcx> {
21202120
T::collect_and_apply(iter, |ts| Ty::new_tup(tcx, ts))
21212121
}
21222122

2123-
/// Creates a new [`Ty`] representing a function definition type, with `def_id` and `args` generic args.
2123+
/// Create a new [`Ty`] representing a function definition type.
21242124
#[inline]
21252125
pub fn new_fn_def(
21262126
tcx: TyCtxt<'tcx>,
@@ -2350,7 +2350,7 @@ impl<'tcx> Ty<'tcx> {
23502350
}
23512351
}
23522352

2353-
/// Checks if this type is a silice type.
2353+
/// `true` if this type is a slice type.
23542354
#[inline]
23552355
pub fn is_slice(self) -> bool {
23562356
matches!(self.kind(), Slice(_))
@@ -2380,8 +2380,7 @@ impl<'tcx> Ty<'tcx> {
23802380
}
23812381
}
23822382

2383-
/// If the type is a slice, array, or a string slice, it will returns its element type.
2384-
/// If this type is not one of those, this function will panic.
2383+
/// Return the element type of a slice, array, or a string slice, or panic.
23852384
pub fn sequence_element_type(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
23862385
match self.kind() {
23872386
Array(ty, _) | Slice(ty) => *ty,
@@ -2447,7 +2446,7 @@ impl<'tcx> Ty<'tcx> {
24472446
self.is_ref() || self.is_unsafe_ptr() || self.is_fn_ptr()
24482447
}
24492448

2450-
/// Checks if this type is an [`Box`].
2449+
/// `true` if this type is [`Box`].
24512450
#[inline]
24522451
pub fn is_box(self) -> bool {
24532452
match self.kind() {
@@ -2489,13 +2488,13 @@ impl<'tcx> Ty<'tcx> {
24892488
matches!(self.kind(), Float(_) | Infer(FloatVar(_)))
24902489
}
24912490

2492-
/// Checks if this type is an unsized trait object(`dyn Trait`).
2491+
/// `true` if this type is an unsized trait object (`dyn Trait`).
24932492
#[inline]
24942493
pub fn is_trait(self) -> bool {
24952494
matches!(self.kind(), Dynamic(_, _, ty::Dyn))
24962495
}
24972496

2498-
/// Checks if this type is an sized trait object(`dyn* Trait`).
2497+
/// `true` if this type is an sized trait object (`dyn* Trait`).
24992498
#[inline]
25002499
pub fn is_dyn_star(self) -> bool {
25012500
matches!(self.kind(), Dynamic(_, _, ty::DynStar))
@@ -2524,7 +2523,7 @@ impl<'tcx> Ty<'tcx> {
25242523
matches!(self.kind(), Coroutine(..))
25252524
}
25262525

2527-
/// Checks if this type is an intgeral type(signed, unsigned on infered).
2526+
/// `true` if this type is an integer type.
25282527
#[inline]
25292528
pub fn is_integral(self) -> bool {
25302529
matches!(self.kind(), Infer(IntVar(_)) | Int(_) | Uint(_))
@@ -2546,19 +2545,19 @@ impl<'tcx> Ty<'tcx> {
25462545
matches!(self.kind(), Char)
25472546
}
25482547

2549-
/// Checks if this type is numeric(integral or floating point).
2548+
/// `true` if this type is an integer or floating point.
25502549
#[inline]
25512550
pub fn is_numeric(self) -> bool {
25522551
self.is_integral() || self.is_floating_point()
25532552
}
25542553

2555-
/// Checks if this type is a signed intiger.
2554+
/// `true` if this type is a signed integer.
25562555
#[inline]
25572556
pub fn is_signed(self) -> bool {
25582557
matches!(self.kind(), Int(_))
25592558
}
25602559

2561-
/// Checks if this type is `usize` or `isize`.
2560+
/// `true` if this type is `usize` or `isize`.
25622561
#[inline]
25632562
pub fn is_ptr_sized_integral(self) -> bool {
25642563
matches!(self.kind(), Int(ty::IntTy::Isize) | Uint(ty::UintTy::Usize))
@@ -2632,7 +2631,7 @@ impl<'tcx> Ty<'tcx> {
26322631
}
26332632
}
26342633

2635-
/// If this type is a function definition or a function pointer, this will retunrn its signature. Otherwise, this function will panic.
2634+
/// If this type is a function definition or a function pointer, return its signature. Otherwise, panic.
26362635
pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
26372636
match self.kind() {
26382637
FnDef(def_id, args) => tcx.fn_sig(*def_id).instantiate(tcx, args),
@@ -2648,13 +2647,13 @@ impl<'tcx> Ty<'tcx> {
26482647
}
26492648
}
26502649

2651-
/// Checks if this type is a function definition or a function pointer.
2650+
/// `true` if this type is a function definition or a function pointer.
26522651
#[inline]
26532652
pub fn is_fn(self) -> bool {
26542653
matches!(self.kind(), FnDef(..) | FnPtr(_))
26552654
}
26562655

2657-
/// Checks if this type is a function pointer.
2656+
/// `true` if this type is a function pointer.
26582657
#[inline]
26592658
pub fn is_fn_ptr(self) -> bool {
26602659
matches!(self.kind(), FnPtr(_))
@@ -2664,7 +2663,7 @@ impl<'tcx> Ty<'tcx> {
26642663
pub fn is_impl_trait(self) -> bool {
26652664
matches!(self.kind(), Alias(ty::Opaque, ..))
26662665
}
2667-
/// Returns the `AdtDef` defining this type, if it is an ADT(struct,union or enum). If this type is not an ADT, returns `None`.
2666+
/// Returns the `AdtDef` for this type's definition if it is an ADT, `None` otherwise.
26682667
#[inline]
26692668
pub fn ty_adt_def(self) -> Option<AdtDef<'tcx>> {
26702669
match self.kind() {

compiler/rustc_middle/src/ty/util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for OpaqueTypeExpander<'tcx> {
10061006
}
10071007

10081008
impl<'tcx> Ty<'tcx> {
1009-
/// Returns the `Size` for primitive types (bool, uint, int, char, float).
1010-
/// If the type is not primitive, will panic with message "non primitive type".
1009+
/// Returns the `Size` for primitive types (bool, uint, int, char, float), or panic.
10111010
pub fn primitive_size(self, tcx: TyCtxt<'tcx>) -> Size {
10121011
match *self.kind() {
10131012
ty::Bool => Size::from_bytes(1),

0 commit comments

Comments
 (0)