Skip to content

Commit d246b2c

Browse files
author
Alexander Regueiro
committed
Cosmetic improvements and fixes to stderr files
1 parent a8e7baa commit d246b2c

35 files changed

+232
-421
lines changed

src/librustc/hir/map/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use syntax_pos::Span;
1414
use ich::StableHashingContext;
1515
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};
1616

17-
/// A Visitor that walks over the HIR and collects Nodes into a HIR map
17+
/// A visitor that walks over the HIR and collects `Node`s into a HIR map.
1818
pub(super) struct NodeCollector<'a, 'hir> {
1919
/// The crate
2020
krate: &'hir Crate,

src/librustc/hir/map/definitions.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ impl DefPath {
260260
DefPath { data: data, krate: krate }
261261
}
262262

263-
/// Returns a string representation of the DefPath without
263+
/// Returns a string representation of the `DefPath` without
264264
/// the crate-prefix. This method is useful if you don't have
265-
/// a TyCtxt available.
265+
/// a `TyCtxt` available.
266266
pub fn to_string_no_crate(&self) -> String {
267267
let mut s = String::with_capacity(self.data.len() * 16);
268268

@@ -271,13 +271,13 @@ impl DefPath {
271271
"::{}[{}]",
272272
component.data.as_interned_str(),
273273
component.disambiguator)
274-
.unwrap();
274+
.unwrap();
275275
}
276276

277277
s
278278
}
279279

280-
/// Return filename friendly string of the DefPah with the
280+
/// Returns filename-friendly string of the `DefPath` with the
281281
/// crate-prefix.
282282
pub fn to_string_friendly<F>(&self, crate_imported_name: F) -> String
283283
where F: FnOnce(CrateNum) -> Symbol
@@ -295,16 +295,16 @@ impl DefPath {
295295
"{}[{}]",
296296
component.data.as_interned_str(),
297297
component.disambiguator)
298-
.unwrap();
298+
.unwrap();
299299
}
300300
}
301301

302302
s
303303
}
304304

305-
/// Return filename friendly string of the DefPah without
305+
/// Returns filename-friendly string of the `DefPath` without
306306
/// the crate-prefix. This method is useful if you don't have
307-
/// a TyCtxt available.
307+
/// a `TyCtxt` available.
308308
pub fn to_filename_friendly_no_crate(&self) -> String {
309309
let mut s = String::with_capacity(self.data.len() * 16);
310310

@@ -319,7 +319,7 @@ impl DefPath {
319319
"{}[{}]",
320320
component.data.as_interned_str(),
321321
component.disambiguator)
322-
.unwrap();
322+
.unwrap();
323323
}
324324
}
325325
s
@@ -659,7 +659,7 @@ impl DefPathData {
659659
GlobalMetaData(name) => {
660660
return name
661661
}
662-
// note that this does not show up in user printouts
662+
// Note that this does not show up in user print-outs.
663663
CrateRoot => "{{root}}",
664664
Impl => "{{impl}}",
665665
Misc => "{{?}}",

src/librustc/hir/mod.rs

+24-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub use self::PrimTy::*;
1010
pub use self::UnOp::*;
1111
pub use self::UnsafeSource::*;
1212

13+
use errors::FatalError;
1314
use hir::def::Def;
1415
use hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX};
1516
use util::nodemap::{NodeMap, FxHashSet};
@@ -607,7 +608,7 @@ pub enum SyntheticTyParamKind {
607608
ImplTrait
608609
}
609610

610-
/// A `where` clause in a definition
611+
/// A `where` clause in a definition.
611612
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
612613
pub struct WhereClause {
613614
pub id: NodeId,
@@ -626,7 +627,7 @@ impl WhereClause {
626627
}
627628
}
628629

629-
/// A single predicate in a `where` clause
630+
/// A single predicate in a `where` clause.
630631
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
631632
pub enum WherePredicate {
632633
/// A type binding (e.g., `for<'c> Foo: Send + Clone + 'c`).
@@ -2053,6 +2054,20 @@ pub struct TraitRef {
20532054
pub hir_ref_id: HirId,
20542055
}
20552056

2057+
impl TraitRef {
2058+
/// Get the `DefId` of the referenced trait. It _must_ actually be a trait or trait alias.
2059+
pub fn trait_def_id(&self) -> DefId {
2060+
match self.path.def {
2061+
Def::Trait(did) => did,
2062+
Def::TraitAlias(did) => did,
2063+
Def::Err => {
2064+
FatalError.raise();
2065+
}
2066+
_ => unreachable!(),
2067+
}
2068+
}
2069+
}
2070+
20562071
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
20572072
pub struct PolyTraitRef {
20582073
/// The `'a` in `<'a> Foo<&'a T>`.
@@ -2484,25 +2499,25 @@ impl CodegenFnAttrs {
24842499
}
24852500
}
24862501

2487-
/// True if `#[inline]` or `#[inline(always)]` is present.
2502+
/// Returns whether `#[inline]` or `#[inline(always)]` is present.
24882503
pub fn requests_inline(&self) -> bool {
24892504
match self.inline {
24902505
InlineAttr::Hint | InlineAttr::Always => true,
24912506
InlineAttr::None | InlineAttr::Never => false,
24922507
}
24932508
}
24942509

2495-
/// True if it looks like this symbol needs to be exported, for example:
2510+
/// Returns whether it looks like this symbol needs to be exported, for example:
24962511
///
2497-
/// * `#[no_mangle]` is present
2498-
/// * `#[export_name(...)]` is present
2499-
/// * `#[linkage]` is present
2512+
/// * `#[no_mangle]` is present.
2513+
/// * `#[export_name(...)]` is present.
2514+
/// * `#[linkage]` is present.
25002515
pub fn contains_extern_indicator(&self) -> bool {
25012516
self.flags.contains(CodegenFnAttrFlags::NO_MANGLE) ||
25022517
self.export_name.is_some() ||
25032518
match self.linkage {
2504-
// these are private, make sure we don't try to consider
2505-
// them external
2519+
// These are private, so make sure we don't try to consider
2520+
// them external.
25062521
None |
25072522
Some(Linkage::Internal) |
25082523
Some(Linkage::Private) => false,

src/librustc/infer/resolve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, 'tcx>
119119
/// then an `Err` result is returned.
120120
pub fn fully_resolve<'a, 'gcx, 'tcx, T>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
121121
value: &T) -> FixupResult<T>
122-
where T : TypeFoldable<'tcx>
122+
where T: TypeFoldable<'tcx>
123123
{
124124
let mut full_resolver = FullTypeResolver { infcx: infcx, err: None };
125125
let result = value.fold_with(&mut full_resolver);

src/librustc/lint/builtin.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,10 @@ declare_lint! {
353353
}
354354

355355
declare_lint! {
356-
pub DUPLICATE_AUTO_TRAITS_IN_TRAIT_OBJECTS,
357-
Warn,
358-
"duplicate auto traits in trait object bounds"
356+
pub DEPRECATED_IN_FUTURE,
357+
Allow,
358+
"detects use of items that will be deprecated in a future version",
359+
report_in_external_macro: true
359360
}
360361

361362
/// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
@@ -367,13 +368,6 @@ pub mod parser {
367368
}
368369
}
369370

370-
declare_lint! {
371-
pub DEPRECATED_IN_FUTURE,
372-
Allow,
373-
"detects use of items that will be deprecated in a future version",
374-
report_in_external_macro: true
375-
}
376-
377371
/// Does nothing as a lint pass, but registers some `Lint`s
378372
/// that are used by other parts of the compiler.
379373
#[derive(Copy, Clone)]
@@ -436,9 +430,8 @@ impl LintPass for HardwiredLints {
436430
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
437431
MACRO_USE_EXTERN_CRATE,
438432
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
439-
DUPLICATE_AUTO_TRAITS_IN_TRAIT_OBJECTS,
440-
parser::QUESTION_MARK_MACRO_SEP,
441433
DEPRECATED_IN_FUTURE,
434+
parser::QUESTION_MARK_MACRO_SEP,
442435
)
443436
}
444437
}

src/librustc/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>(
898898
param_env: ty::ParamEnv<'tcx>,
899899
value: &T)
900900
-> Result<T, Vec<FulfillmentError<'tcx>>>
901-
where T : TypeFoldable<'tcx>
901+
where T: TypeFoldable<'tcx>
902902
{
903903
debug!("fully_normalize_with_fulfillcx(value={:?})", value);
904904
let selcx = &mut SelectionContext::new(infcx);

src/librustc/traits/object_safety.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
173173
predicates
174174
.predicates
175175
.iter()
176-
.map(|(predicate, _)| predicate.subst_supertrait(self, &trait_ref))
177-
.any(|predicate| {
178-
match predicate {
176+
.map(|(pred, _)| pred.subst_supertrait(self, &trait_ref))
177+
.any(|pred| {
178+
match pred {
179179
ty::Predicate::Trait(ref data) => {
180180
// In the case of a trait predicate, we can skip the "self" type.
181181
data.skip_binder().input_types().skip(1).any(|t| t.has_self_ty())

src/librustc/traits/project.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ pub type ProjectionTyObligation<'tcx> =
7878
/// When attempting to resolve `<T as TraitRef>::Name` ...
7979
#[derive(Debug)]
8080
pub enum ProjectionTyError<'tcx> {
81-
/// ...we found multiple sources of information and couldn't resolve the ambiguity.
81+
/// ... we found multiple sources of information and couldn't resolve the ambiguity.
8282
TooManyCandidates,
8383

84-
/// ...an error occurred matching `T : TraitRef`
84+
/// ... an error occurred matching `T: TraitRef`.
8585
TraitSelectionError(SelectionError<'tcx>),
8686
}
8787

@@ -92,13 +92,13 @@ pub struct MismatchedProjectionTypes<'tcx> {
9292

9393
#[derive(PartialEq, Eq, Debug)]
9494
enum ProjectionTyCandidate<'tcx> {
95-
// from a where-clause in the env or object type
95+
// From a where-clause in the env or object type.
9696
ParamEnv(ty::PolyProjectionPredicate<'tcx>),
9797

98-
// from the definition of `Trait` when you have something like <<A as Trait>::B as Trait2>::C
98+
// From the definition of `Trait` when you have something like `<<A as Trait>::B as Trait2>::C`.
9999
TraitDef(ty::PolyProjectionPredicate<'tcx>),
100100

101-
// from a "impl" (or a "pseudo-impl" returned by select)
101+
// From a "impl" (or a "pseudo-impl" returned by select).
102102
Select(Selection<'tcx>),
103103
}
104104

@@ -270,7 +270,7 @@ pub fn normalize<'a, 'b, 'gcx, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'gcx
270270
cause: ObligationCause<'tcx>,
271271
value: &T)
272272
-> Normalized<'tcx, T>
273-
where T : TypeFoldable<'tcx>
273+
where T: TypeFoldable<'tcx>
274274
{
275275
normalize_with_depth(selcx, param_env, cause, 0, value)
276276
}
@@ -284,7 +284,7 @@ pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>(
284284
value: &T)
285285
-> Normalized<'tcx, T>
286286

287-
where T : TypeFoldable<'tcx>
287+
where T: TypeFoldable<'tcx>
288288
{
289289
debug!("normalize_with_depth(depth={}, value={:?})", depth, value);
290290
let mut normalizer = AssociatedTypeNormalizer::new(selcx, param_env, cause, depth);
@@ -386,7 +386,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
386386
// handle normalization within binders because
387387
// otherwise we wind up a need to normalize when doing
388388
// trait matching (since you can have a trait
389-
// obligation like `for<'a> T::B : Fn(&'a int)`), but
389+
// obligation like `for<'a> T::B: Fn(&'a int)`), but
390390
// we can't normalize with bound regions in scope. So
391391
// far now we just ignore binders but only normalize
392392
// if all bound regions are gone (and then we still
@@ -948,7 +948,7 @@ fn assemble_candidates_from_param_env<'cx, 'gcx, 'tcx>(
948948
///
949949
/// ```
950950
/// trait Foo {
951-
/// type FooT : Bar<BarT=i32>
951+
/// type FooT: Bar<BarT = i32>
952952
/// }
953953
/// ```
954954
///
@@ -1139,8 +1139,8 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>(
11391139
// fn foo<T:SomeTrait>(...) { }
11401140
// ```
11411141
//
1142-
// If the user writes `<T as SomeTrait>::Foo`, then the `T
1143-
// : SomeTrait` binding does not help us decide what the
1142+
// If the user writes `<T as SomeTrait>::Foo`, then the
1143+
// `T: SomeTrait` binding does not help us decide what the
11441144
// type `Foo` is (at least, not more specifically than
11451145
// what we already knew).
11461146
//
@@ -1150,10 +1150,10 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>(
11501150
// fn bar<T:SomeTrait<Foo=usize>>(...) { ... }
11511151
// ```
11521152
//
1153-
// Doesn't the `T : Sometrait<Foo=usize>` predicate help
1153+
// Doesn't the `T: Sometrait<Foo = usize>` predicate help
11541154
// resolve `T::Foo`? And of course it does, but in fact
11551155
// that single predicate is desugared into two predicates
1156-
// in the compiler: a trait predicate (`T : SomeTrait`) and a
1156+
// in the compiler: a trait predicate (`T: SomeTrait`) and a
11571157
// projection. And the projection where clause is handled
11581158
// in `assemble_candidates_from_param_env`.
11591159
false

src/librustc/traits/select.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3812,19 +3812,19 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
38123812
let mut predicates: Vec<_> = predicates
38133813
.predicates
38143814
.iter()
3815-
.flat_map(|(predicate, _)| {
3816-
let predicate = normalize_with_depth(
3815+
.flat_map(|(pred, _)| {
3816+
let pred = normalize_with_depth(
38173817
self,
38183818
param_env,
38193819
cause.clone(),
38203820
recursion_depth,
3821-
&predicate.subst(tcx, substs),
3821+
&pred.subst(tcx, substs),
38223822
);
3823-
predicate.obligations.into_iter().chain(Some(Obligation {
3823+
pred.obligations.into_iter().chain(Some(Obligation {
38243824
cause: cause.clone(),
38253825
recursion_depth,
38263826
param_env,
3827-
predicate: predicate.value,
3827+
predicate: pred.value,
38283828
}))
38293829
})
38303830
.collect();

src/librustc/ty/codec.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ pub fn encode_predicates<'tcx, E, C>(encoder: &mut E,
107107
}
108108

109109
pub trait TyDecoder<'a, 'tcx: 'a>: Decoder {
110-
111110
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>;
112111

113112
fn peek_byte(&self) -> u8;
@@ -168,8 +167,8 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
168167
Ok(ty::GenericPredicates {
169168
parent: Decodable::decode(decoder)?,
170169
predicates: (0..decoder.read_usize()?).map(|_| {
171-
// Handle shorthands first, if we have an usize > 0x80.
172-
let predicate = if decoder.positioned_at_shorthand() {
170+
// Handle shorthands first, if we have an usize greater than `0x80`.
171+
let pred = if decoder.positioned_at_shorthand() {
173172
let pos = decoder.read_usize()?;
174173
assert!(pos >= SHORTHAND_OFFSET);
175174
let shorthand = pos - SHORTHAND_OFFSET;
@@ -178,7 +177,7 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
178177
} else {
179178
ty::Predicate::decode(decoder)
180179
}?;
181-
Ok((predicate, Decodable::decode(decoder)?))
180+
Ok((pred, Decodable::decode(decoder)?))
182181
})
183182
.collect::<Result<Vec<_>, _>>()?,
184183
})

src/librustc/ty/context.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ use lint::{self, Lint};
1616
use ich::{StableHashingContext, NodeIdHashingMode};
1717
use infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
1818
use infer::outlives::free_region_map::FreeRegionMap;
19-
use middle::cstore::CrateStoreDyn;
20-
use middle::cstore::EncodedMetadata;
19+
use middle::cstore::{CrateStoreDyn, EncodedMetadata};
2120
use middle::lang_items;
2221
use middle::resolve_lifetime::{self, ObjectLifetimeDefault};
2322
use middle::stability;
@@ -1366,7 +1365,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13661365

13671366
pub fn def_path_debug_str(self, def_id: DefId) -> String {
13681367
// We are explicitly not going through queries here in order to get
1369-
// crate name and disambiguator since this code is called from debug!()
1368+
// crate name and disambiguator since this code is called from `debug!()`
13701369
// statements within the query system and we'd run into endless
13711370
// recursion otherwise.
13721371
let (crate_name, crate_disambiguator) = if def_id.is_local() {
@@ -1390,7 +1389,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13901389
}
13911390

13921391
// Note that this is *untracked* and should only be used within the query
1393-
// system if the result is otherwise tracked through queries
1392+
// system if the result is otherwise tracked through queries.
13941393
pub fn crate_data_as_rc_any(self, cnum: CrateNum) -> Lrc<dyn Any> {
13951394
self.cstore.crate_data_as_rc_any(cnum)
13961395
}

0 commit comments

Comments
 (0)