Skip to content

Commit fd48ca2

Browse files
Alexander RegueiroCentril
Alexander Regueiro
andcommitted
Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
1 parent c1d29ee commit fd48ca2

File tree

9 files changed

+54
-60
lines changed

9 files changed

+54
-60
lines changed

src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub struct LoweringContext<'a> {
126126
/// lifetime definitions in the corresponding impl or function generics.
127127
lifetimes_to_define: Vec<(Span, ParamName)>,
128128

129-
/// `true` ifs in-band lifetimes are being collected. This is used to
129+
/// `true` if in-band lifetimes are being collected. This is used to
130130
/// indicate whether or not we're in a place where new lifetimes will result
131131
/// in in-band lifetime definitions, such a function or an impl header,
132132
/// including implicit lifetimes from `impl_header_lifetime_elision`.

src/librustc/mir/interpret/allocation.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use super::{
44
Pointer, InterpResult, AllocId, ScalarMaybeUndef, write_target_uint, read_target_uint, Scalar,
55
};
66

7+
use crate::mir;
78
use crate::ty::layout::{Size, Align};
9+
10+
use rustc_data_structures::sorted_map::SortedMap;
11+
use rustc_target::abi::HasDataLayout;
812
use syntax::ast::Mutability;
913
use std::iter;
10-
use crate::mir;
1114
use std::ops::{Range, Deref, DerefMut};
12-
use rustc_data_structures::sorted_map::SortedMap;
13-
use rustc_target::abi::HasDataLayout;
1415
use std::borrow::Cow;
1516

1617
// NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in
@@ -765,7 +766,7 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
765766
}
766767
}
767768

768-
/// Apply a relocation copy.
769+
/// Applies a relocation copy.
769770
/// The affected range, as defined in the parameters to `prepare_relocation_copy` is expected
770771
/// to be clear of relocations.
771772
pub fn mark_relocation_range(

src/librustc/mir/interpret/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ pub enum GlobalAlloc<'tcx> {
349349
Memory(&'tcx Allocation),
350350
}
351351

352-
#[derive(Clone)]
353352
pub struct AllocMap<'tcx> {
354353
/// Maps `AllocId`s to their corresponding allocations.
355354
alloc_map: FxHashMap<AllocId, GlobalAlloc<'tcx>>,

src/librustc/mir/mod.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,6 @@ pub enum LocalKind {
605605

606606
#[derive(Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
607607
pub struct VarBindingForm<'tcx> {
608-
/// The `HirId` of the variable.
609-
pub var_id: hir::HirId,
610608
/// Is variable bound via `x`, `mut x`, `ref x`, or `ref mut x`?
611609
pub binding_mode: ty::BindingMode,
612610
/// If an explicit type was provided for this variable binding,
@@ -656,7 +654,6 @@ pub enum ImplicitSelfKind {
656654
CloneTypeFoldableAndLiftImpls! { BindingForm<'tcx>, }
657655

658656
impl_stable_hash_for!(struct self::VarBindingForm<'tcx> {
659-
var_id,
660657
binding_mode,
661658
opt_ty_info,
662659
opt_match_place,
@@ -877,7 +874,9 @@ impl<'tcx> LocalDecl<'tcx> {
877874
match self.is_user_variable {
878875
Some(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm {
879876
binding_mode: ty::BindingMode::BindByValue(_),
880-
..
877+
opt_ty_info: _,
878+
opt_match_place: _,
879+
pat_span: _,
881880
}))) => true,
882881

883882
Some(ClearCrossCrate::Set(BindingForm::ImplicitSelf(ImplicitSelfKind::Imm))) => true,
@@ -893,7 +892,9 @@ impl<'tcx> LocalDecl<'tcx> {
893892
match self.is_user_variable {
894893
Some(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm {
895894
binding_mode: ty::BindingMode::BindByValue(_),
896-
..
895+
opt_ty_info: _,
896+
opt_match_place: _,
897+
pat_span: _,
897898
}))) => true,
898899

899900
Some(ClearCrossCrate::Set(BindingForm::ImplicitSelf(_))) => true,
@@ -2830,7 +2831,7 @@ impl Location {
28302831
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
28312832
pub enum UnsafetyViolationKind {
28322833
General,
2833-
/// Permitted in const fns and regular fns.
2834+
/// Permitted both in `const fn`s and regular `fn`s.
28342835
GeneralAndConstFn,
28352836
ExternStatic(hir::HirId),
28362837
BorrowPacked(hir::HirId),
@@ -2848,7 +2849,7 @@ pub struct UnsafetyViolation {
28482849
pub struct UnsafetyCheckResult {
28492850
/// Violations that are propagated *upwards* from this function.
28502851
pub violations: Lrc<[UnsafetyViolation]>,
2851-
/// Unsafe blocks in this function, along with whether they are used. This is
2852+
/// `unsafe` blocks in this function, along with whether they are used. This is
28522853
/// used for the "unused_unsafe" lint.
28532854
pub unsafe_blocks: Lrc<[(hir::HirId, bool)]>,
28542855
}
@@ -2875,12 +2876,14 @@ pub struct GeneratorLayout<'tcx> {
28752876
/// layout.
28762877
pub storage_conflicts: BitMatrix<GeneratorSavedLocal, GeneratorSavedLocal>,
28772878

2878-
/// Names and scopes of all the stored generator locals.
2879+
/// The names and scopes of all the stored generator locals.
2880+
///
2881+
/// N.B., this is *strictly* a temporary hack for codegen
2882+
/// debuginfo generation, and will be removed at some point.
2883+
/// Do **NOT** use it for anything else, local information should not be
2884+
/// in the MIR, please rely on local crate HIR or other side-channels.
28792885
//
2880-
// NOTE(tmandry) This is *strictly* a temporary hack for codegen
2881-
// debuginfo generation, and will be removed at some point.
2882-
// Do **NOT** use it for anything else, local information should not be
2883-
// in the MIR, please rely on local crate HIR or other side-channels.
2886+
// FIXME(tmandry): see above.
28842887
pub __local_debuginfo_codegen_only_do_not_use: IndexVec<GeneratorSavedLocal, LocalDecl<'tcx>>,
28852888
}
28862889

src/librustc/session/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,11 @@ impl Passes {
711711
}
712712

713713
/// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
714-
/// macro is to define an interface that can be programmatically used by the option parser in order
714+
/// macro is to define an interface that can be programmatically used by the option parser
715715
/// to initialize the struct without hardcoding field names all over the place.
716716
///
717717
/// The goal is to invoke this macro once with the correct fields, and then this macro generates all
718-
/// necessary code. The main gotcha of this macro is the cgsetters module which is a bunch of
718+
/// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
719719
/// generated code to parse an option into its respective field in the struct. There are a few
720720
/// hand-written parsers for parsing specific types of values in this module.
721721
macro_rules! options {

src/librustc/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl<'tcx> TyCtxt<'tcx> {
571571
-> Vec<ty::PolyTraitRef<'tcx>>
572572
{
573573
if source_trait_ref.def_id() == target_trait_def_id {
574-
return vec![source_trait_ref]; // Shorcut the most common case.
574+
return vec![source_trait_ref]; // Shortcut the most common case.
575575
}
576576

577577
supertraits(self, source_trait_ref)

src/librustc/ty/context.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-tidy-filelength
2-
31
//! Type context book-keeping.
42
53
use crate::arena::Arena;
@@ -1753,7 +1751,7 @@ pub mod tls {
17531751
pub task_deps: Option<&'a Lock<TaskDeps>>,
17541752
}
17551753

1756-
/// Sets Rayon's thread local variablem, which is preserved for Rayon jobs
1754+
/// Sets Rayon's thread-local variable, which is preserved for Rayon jobs
17571755
/// to `value` during the call to `f`. It is restored to its previous value after.
17581756
/// This is used to set the pointer to the new `ImplicitCtxt`.
17591757
#[cfg(parallel_compiler)]
@@ -1762,7 +1760,7 @@ pub mod tls {
17621760
rayon_core::tlv::with(value, f)
17631761
}
17641762

1765-
/// Gets Rayon's thread local variable, which is preserved for Rayon jobs.
1763+
/// Gets Rayon's thread-local variable, which is preserved for Rayon jobs.
17661764
/// This is used to get the pointer to the current `ImplicitCtxt`.
17671765
#[cfg(parallel_compiler)]
17681766
#[inline]

src/librustc/ty/print/pretty.rs

+24-27
Original file line numberDiff line numberDiff line change
@@ -1093,38 +1093,35 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
10931093
}
10941094

10951095
let key = self.tcx.def_key(def_id);
1096-
match key.disambiguated_data.data {
1097-
DefPathData::Impl => {
1098-
// Always use types for non-local impls, where types are always
1099-
// available, and filename/line-number is mostly uninteresting.
1100-
let use_types =
1101-
!def_id.is_local() || {
1102-
// Otherwise, use filename/line-number if forced.
1103-
let force_no_types = FORCE_IMPL_FILENAME_LINE.with(|f| f.get());
1104-
!force_no_types
1105-
};
1106-
1107-
if !use_types {
1108-
// If no type info is available, fall back to
1109-
// pretty-printing some span information. This should
1110-
// only occur very early in the compiler pipeline.
1111-
let parent_def_id = DefId { index: key.parent.unwrap(), ..def_id };
1112-
let span = self.tcx.def_span(def_id);
1096+
if let DefPathData::Impl = key.disambiguated_data.data {
1097+
// Always use types for non-local impls, where types are always
1098+
// available, and filename/line-number is mostly uninteresting.
1099+
let use_types =
1100+
!def_id.is_local() || {
1101+
// Otherwise, use filename/line-number if forced.
1102+
let force_no_types = FORCE_IMPL_FILENAME_LINE.with(|f| f.get());
1103+
!force_no_types
1104+
};
11131105

1114-
self = self.print_def_path(parent_def_id, &[])?;
1106+
if !use_types {
1107+
// If no type info is available, fall back to
1108+
// pretty printing some span information. This should
1109+
// only occur very early in the compiler pipeline.
1110+
let parent_def_id = DefId { index: key.parent.unwrap(), ..def_id };
1111+
let span = self.tcx.def_span(def_id);
11151112

1116-
// HACK(eddyb) copy of `path_append` to avoid
1117-
// constructing a `DisambiguatedDefPathData`.
1118-
if !self.empty_path {
1119-
write!(self, "::")?;
1120-
}
1121-
write!(self, "<impl at {:?}>", span)?;
1122-
self.empty_path = false;
1113+
self = self.print_def_path(parent_def_id, &[])?;
11231114

1124-
return Ok(self);
1115+
// HACK(eddyb) copy of `path_append` to avoid
1116+
// constructing a `DisambiguatedDefPathData`.
1117+
if !self.empty_path {
1118+
write!(self, "::")?;
11251119
}
1120+
write!(self, "<impl at {:?}>", span)?;
1121+
self.empty_path = false;
1122+
1123+
return Ok(self);
11261124
}
1127-
_ => {}
11281125
}
11291126

11301127
self.default_print_def_path(def_id, substs)

src/librustc/ty/query/on_disk_cache.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl<'sess> OnDiskCache<'sess> {
429429

430430
//- DECODING -------------------------------------------------------------------
431431

432-
/// A decoder that can read fro the incr. comp. cache. It is similar to the onem
432+
/// A decoder that can read fro the incr. comp. cache. It is similar to the one
433433
/// we use for crate metadata decoding in that it can rebase spans and eventually
434434
/// will also handle things that contain `Ty` instances.
435435
struct CacheDecoder<'a, 'tcx> {
@@ -460,27 +460,25 @@ impl<'a, 'tcx> CacheDecoder<'a, 'tcx> {
460460
}
461461
}
462462

463-
pub trait DecoderWithPosition: Decoder {
463+
trait DecoderWithPosition: Decoder {
464464
fn position(&self) -> usize;
465465
}
466466

467467
impl<'a> DecoderWithPosition for opaque::Decoder<'a> {
468-
#[inline]
469468
fn position(&self) -> usize {
470469
self.position()
471470
}
472471
}
473472

474473
impl<'a, 'tcx> DecoderWithPosition for CacheDecoder<'a, 'tcx> {
475-
#[inline]
476474
fn position(&self) -> usize {
477475
self.opaque.position()
478476
}
479477
}
480478

481479
// Decodes something that was encoded with `encode_tagged()` and verify that the
482480
// tag matches and the correct amount of bytes was read.
483-
pub fn decode_tagged<D, T, V>(decoder: &mut D, expected_tag: T) -> Result<V, D::Error>
481+
fn decode_tagged<D, T, V>(decoder: &mut D, expected_tag: T) -> Result<V, D::Error>
484482
where
485483
T: Decodable + Eq + ::std::fmt::Debug,
486484
V: Decodable,
@@ -700,7 +698,6 @@ impl<'a, 'tcx> SpecializedDecoder<NodeId> for CacheDecoder<'a, 'tcx> {
700698
}
701699

702700
impl<'a, 'tcx> SpecializedDecoder<Fingerprint> for CacheDecoder<'a, 'tcx> {
703-
#[inline]
704701
fn specialized_decode(&mut self) -> Result<Fingerprint, Self::Error> {
705702
Fingerprint::decode_opaque(&mut self.opaque)
706703
}
@@ -754,7 +751,7 @@ where
754751
/// encode the specified tag, then the given value, then the number of
755752
/// bytes taken up by tag and value. On decoding, we can then verify that
756753
/// we get the expected tag and read the expected number of bytes.
757-
pub fn encode_tagged<T: Encodable, V: Encodable>(
754+
fn encode_tagged<T: Encodable, V: Encodable>(
758755
&mut self,
759756
tag: T,
760757
value: &V
@@ -960,7 +957,6 @@ where
960957
}
961958

962959
impl<'a, 'tcx> SpecializedEncoder<Fingerprint> for CacheEncoder<'a, 'tcx, opaque::Encoder> {
963-
#[inline]
964960
fn specialized_encode(&mut self, f: &Fingerprint) -> Result<(), Self::Error> {
965961
f.encode_opaque(&mut self.encoder)
966962
}

0 commit comments

Comments
 (0)