Various minor/cosmetic improvements to code
This commit is contained in:
parent
4a45578bc5
commit
ee89c088b0
457 changed files with 2384 additions and 2360 deletions
|
@ -255,7 +255,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
|||
// handle_lifetimes determines what *needs be* true in order for an impl to hold.
|
||||
// lexical_region_resolve, along with much of the rest of the compiler, is concerned
|
||||
// with determining if a given set up constraints/predicates *are* met, given some
|
||||
// starting conditions (e.g. user-provided code). For this reason, it's easier
|
||||
// starting conditions (e.g., user-provided code). For this reason, it's easier
|
||||
// to perform the calculations we need on our own, rather than trying to make
|
||||
// existing inference/solver code do what we want.
|
||||
fn handle_lifetimes<'cx>(
|
||||
|
@ -274,7 +274,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
|||
// Flattening is done in two parts. First, we insert all of the constraints
|
||||
// into a map. Each RegionTarget (either a RegionVid or a Region) maps
|
||||
// to its smaller and larger regions. Note that 'larger' regions correspond
|
||||
// to sub-regions in Rust code (e.g. in 'a: 'b, 'a is the larger region).
|
||||
// to sub-regions in Rust code (e.g., in 'a: 'b, 'a is the larger region).
|
||||
for constraint in regions.constraints.keys() {
|
||||
match constraint {
|
||||
&Constraint::VarSubVar(r1, r2) => {
|
||||
|
@ -524,7 +524,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
|||
// display on the docs page. Cleaning the Predicates produces sub-optimal WherePredicate's,
|
||||
// so we fix them up:
|
||||
//
|
||||
// * Multiple bounds for the same type are coalesced into one: e.g. 'T: Copy', 'T: Debug'
|
||||
// * Multiple bounds for the same type are coalesced into one: e.g., 'T: Copy', 'T: Debug'
|
||||
// becomes 'T: Copy + Debug'
|
||||
// * Fn bounds are handled specially - instead of leaving it as 'T: Fn(), <T as Fn::Output> =
|
||||
// K', we use the dedicated syntax 'T: Fn() -> K'
|
||||
|
@ -545,7 +545,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
|||
);
|
||||
|
||||
// The `Sized` trait must be handled specially, since we only only display it when
|
||||
// it is *not* required (i.e. '?Sized')
|
||||
// it is *not* required (i.e., '?Sized')
|
||||
let sized_trait = self.cx
|
||||
.tcx
|
||||
.require_lang_item(lang_items::SizedTraitLangItem);
|
||||
|
@ -629,7 +629,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
|||
let is_fn = match &mut b {
|
||||
&mut GenericBound::TraitBound(ref mut p, _) => {
|
||||
// Insert regions into the for_generics hash map first, to ensure
|
||||
// that we don't end up with duplicate bounds (e.g. for<'b, 'b>)
|
||||
// that we don't end up with duplicate bounds (e.g., for<'b, 'b>)
|
||||
for_generics.extend(p.generic_params.clone());
|
||||
p.generic_params = for_generics.into_iter().collect();
|
||||
self.is_fn_ty(&tcx, &p.trait_)
|
||||
|
@ -737,7 +737,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
|||
hir::TraitBoundModifier::None,
|
||||
));
|
||||
|
||||
// Remove any existing 'plain' bound (e.g. 'T: Iterator`) so
|
||||
// Remove any existing 'plain' bound (e.g., 'T: Iterator`) so
|
||||
// that we don't see a
|
||||
// duplicate bound like `T: Iterator + Iterator<Item=u8>`
|
||||
// on the docs page.
|
||||
|
@ -837,7 +837,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
|||
// auto-trait impls always render in exactly the same way.
|
||||
//
|
||||
// Using the Debug implementation for sorting prevents us from needing to
|
||||
// write quite a bit of almost entirely useless code (e.g. how should two
|
||||
// write quite a bit of almost entirely useless code (e.g., how should two
|
||||
// Types be sorted relative to each other). It also allows us to solve the
|
||||
// problem for both WherePredicates and GenericBounds at the same time. This
|
||||
// approach is probably somewhat slower, but the small number of items
|
||||
|
|
|
@ -31,13 +31,13 @@ pub enum Cfg {
|
|||
True,
|
||||
/// Denies all configurations.
|
||||
False,
|
||||
/// A generic configuration option, e.g. `test` or `target_os = "linux"`.
|
||||
/// A generic configuration option, e.g., `test` or `target_os = "linux"`.
|
||||
Cfg(Symbol, Option<Symbol>),
|
||||
/// Negate a configuration requirement, i.e. `not(x)`.
|
||||
/// Negate a configuration requirement, i.e., `not(x)`.
|
||||
Not(Box<Cfg>),
|
||||
/// Union of a list of configuration requirements, i.e. `any(...)`.
|
||||
/// Union of a list of configuration requirements, i.e., `any(...)`.
|
||||
Any(Vec<Cfg>),
|
||||
/// Intersection of a list of configuration requirements, i.e. `all(...)`.
|
||||
/// Intersection of a list of configuration requirements, i.e., `all(...)`.
|
||||
All(Vec<Cfg>),
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ impl Cfg {
|
|||
|
||||
/// Parses a `MetaItem` into a `Cfg`.
|
||||
///
|
||||
/// The `MetaItem` should be the content of the `#[cfg(...)]`, e.g. `unix` or
|
||||
/// The `MetaItem` should be the content of the `#[cfg(...)]`, e.g., `unix` or
|
||||
/// `target_os = "redox"`.
|
||||
///
|
||||
/// If the content is not properly formatted, it will return an error indicating what and where
|
||||
|
|
|
@ -11,14 +11,31 @@
|
|||
//! This module contains the "cleaned" pieces of the AST, and the functions
|
||||
//! that clean them.
|
||||
|
||||
pub use self::Type::*;
|
||||
pub use self::Mutability::*;
|
||||
pub use self::ItemEnum::*;
|
||||
pub use self::SelfTy::*;
|
||||
pub use self::FunctionRetTy::*;
|
||||
pub use self::Visibility::{Public, Inherited};
|
||||
pub mod inline;
|
||||
pub mod cfg;
|
||||
mod simplify;
|
||||
mod auto_trait;
|
||||
mod blanket_impl;
|
||||
pub mod def_ctor;
|
||||
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_typeck::hir_ty_to_ty;
|
||||
use rustc::infer::region_constraints::{RegionConstraintData, Constraint};
|
||||
use rustc::mir::interpret::ConstValue;
|
||||
use rustc::middle::resolve_lifetime as rl;
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::middle::stability;
|
||||
use rustc::mir::interpret::GlobalId;
|
||||
use rustc::hir::{self, GenericArg, HirVec};
|
||||
use rustc::hir::def::{self, Def, CtorKind};
|
||||
use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind};
|
||||
use rustc::ty::fold::TypeFolder;
|
||||
use rustc::ty::layout::VariantIdx;
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use syntax::ast::{self, AttrStyle, Ident};
|
||||
use syntax::attr;
|
||||
use syntax::ext::base::MacroKind;
|
||||
|
@ -28,30 +45,12 @@ use syntax::symbol::keywords::{self, Keyword};
|
|||
use syntax::symbol::InternedString;
|
||||
use syntax_pos::{self, DUMMY_SP, Pos, FileName};
|
||||
|
||||
use rustc::mir::interpret::ConstValue;
|
||||
use rustc::middle::resolve_lifetime as rl;
|
||||
use rustc::ty::fold::TypeFolder;
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::mir::interpret::GlobalId;
|
||||
use rustc::hir::{self, GenericArg, HirVec};
|
||||
use rustc::hir::def::{self, Def, CtorKind};
|
||||
use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind};
|
||||
use rustc::ty::layout::VariantIdx;
|
||||
use rustc::middle::stability;
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc_typeck::hir_ty_to_ty;
|
||||
use rustc::infer::region_constraints::{RegionConstraintData, Constraint};
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::default::Default;
|
||||
use std::{mem, slice, vec};
|
||||
use std::iter::{FromIterator, once};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
use std::cell::RefCell;
|
||||
|
@ -66,17 +65,17 @@ use visit_ast;
|
|||
use html::render::{cache, ExternalLocation};
|
||||
use html::item_type::ItemType;
|
||||
|
||||
pub mod inline;
|
||||
pub mod cfg;
|
||||
mod simplify;
|
||||
mod auto_trait;
|
||||
mod blanket_impl;
|
||||
pub mod def_ctor;
|
||||
|
||||
use self::cfg::Cfg;
|
||||
use self::auto_trait::AutoTraitFinder;
|
||||
use self::blanket_impl::BlanketImplFinder;
|
||||
|
||||
pub use self::Type::*;
|
||||
pub use self::Mutability::*;
|
||||
pub use self::ItemEnum::*;
|
||||
pub use self::SelfTy::*;
|
||||
pub use self::FunctionRetTy::*;
|
||||
pub use self::Visibility::{Public, Inherited};
|
||||
|
||||
thread_local!(pub static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = Default::default());
|
||||
|
||||
const FN_OUTPUT_NAME: &'static str = "Output";
|
||||
|
@ -1621,7 +1620,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
|
|||
}
|
||||
|
||||
// It would be nice to collect all of the bounds on a type and recombine
|
||||
// them if possible, to avoid e.g. `where T: Foo, T: Bar, T: Sized, T: 'a`
|
||||
// them if possible, to avoid e.g., `where T: Foo, T: Bar, T: Sized, T: 'a`
|
||||
// and instead see `where T: Foo + Bar + Sized + 'a`
|
||||
|
||||
Generics {
|
||||
|
@ -3899,7 +3898,7 @@ impl Clean<Deprecation> for attr::Deprecation {
|
|||
}
|
||||
}
|
||||
|
||||
/// An equality constraint on an associated type, e.g. `A=Bar` in `Foo<A=Bar>`
|
||||
/// An equality constraint on an associated type, e.g., `A=Bar` in `Foo<A=Bar>`
|
||||
#[derive(Clone, PartialEq, Eq, RustcDecodable, RustcEncodable, Debug, Hash)]
|
||||
pub struct TypeBinding {
|
||||
pub name: String,
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
//! more canonical form.
|
||||
//!
|
||||
//! Currently all cross-crate-inlined function use `rustc::ty` to reconstruct
|
||||
//! the AST (e.g. see all of `clean::inline`), but this is not always a
|
||||
//! the AST (e.g., see all of `clean::inline`), but this is not always a
|
||||
//! non-lossy transformation. The current format of storage for where clauses
|
||||
//! for functions and such is simply a list of predicates. One example of this
|
||||
//! is that the AST predicate of: `where T: Trait<Foo=Bar>` is encoded as:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue