Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition librustdoc to Rust 2018 #58100

Merged
merged 2 commits into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "rustdoc"
version = "0.0.0"
edition = "2018"

[lib]
name = "rustdoc"
Expand Down
11 changes: 7 additions & 4 deletions src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
}
}

fn get_lifetime(&self, region: Region, names_map: &FxHashMap<String, Lifetime>) -> Lifetime {
fn get_lifetime(
&self, region: Region<'_>,
names_map: &FxHashMap<String, Lifetime>
) -> Lifetime {
self.region_name(region)
.map(|name| {
names_map.get(&name).unwrap_or_else(|| {
Expand All @@ -231,7 +234,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
.clone()
}

fn region_name(&self, region: Region) -> Option<String> {
fn region_name(&self, region: Region<'_>) -> Option<String> {
match region {
&ty::ReEarlyBound(r) => Some(r.name.to_string()),
_ => None,
Expand Down Expand Up @@ -259,7 +262,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
// we need to create the Generics.
let mut finished: FxHashMap<_, Vec<_>> = Default::default();

let mut vid_map: FxHashMap<RegionTarget, RegionDeps> = Default::default();
let mut vid_map: FxHashMap<RegionTarget<'_>, RegionDeps<'_>> = Default::default();

// 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
Expand Down Expand Up @@ -842,7 +845,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
vec.sort_by_cached_key(|x| format!("{:?}", x))
}

fn is_fn_ty(&self, tcx: &TyCtxt, ty: &Type) -> bool {
fn is_fn_ty(&self, tcx: &TyCtxt<'_, '_, '_>, ty: &Type) -> bool {
match &ty {
&&Type::ResolvedPath { ref did, .. } => {
*did == tcx.require_lang_item(lang_items::FnTraitLangItem)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc::ty::subst::Subst;
use rustc::infer::InferOk;
use syntax_pos::DUMMY_SP;

use core::DocAccessLevels;
use crate::core::DocAccessLevels;

use super::*;

Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use syntax::feature_gate::Features;

use syntax_pos::Span;

use html::escape::Escape;
use crate::html::escape::Escape;

#[derive(Clone, RustcEncodable, RustcDecodable, Debug, PartialEq, Eq, Hash)]
pub enum Cfg {
Expand Down Expand Up @@ -261,7 +261,7 @@ impl ops::BitOr for Cfg {
struct Html<'a>(&'a Cfg, bool);

fn write_with_opt_paren<T: fmt::Display>(
fmt: &mut fmt::Formatter,
fmt: &mut fmt::Formatter<'_>,
has_paren: bool,
obj: T,
) -> fmt::Result {
Expand All @@ -277,7 +277,7 @@ fn write_with_opt_paren<T: fmt::Display>(


impl<'a> fmt::Display for Html<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self.0 {
Cfg::Not(ref child) => match **child {
Cfg::Any(ref sub_cfgs) => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/clean/def_ctor.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::DocContext;
use crate::core::DocContext;

use super::*;

pub fn get_def_from_def_id<F>(cx: &DocContext,
pub fn get_def_from_def_id<F>(cx: &DocContext<'_, '_, '_>,
def_id: DefId,
callback: &F,
) -> Vec<Item>
Expand Down Expand Up @@ -38,7 +38,7 @@ where F: Fn(& dyn Fn(DefId) -> Def) -> Vec<Item> {
}
}

pub fn get_def_from_node_id<F>(cx: &DocContext,
pub fn get_def_from_node_id<F>(cx: &DocContext<'_, '_, '_>,
id: ast::NodeId,
name: String,
callback: &F,
Expand Down
53 changes: 31 additions & 22 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use rustc_metadata::cstore::LoadedMacro;
use rustc::ty;
use rustc::util::nodemap::FxHashSet;

use core::{DocContext, DocAccessLevels};
use doctree;
use clean::{
use crate::core::{DocContext, DocAccessLevels};
use crate::doctree;
use crate::clean::{
self,
GetDefId,
ToSource,
Expand All @@ -35,7 +35,12 @@ use super::Clean;
///
/// The returned value is `None` if the definition could not be inlined,
/// and `Some` of a vector of items if it was successfully expanded.
pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHashSet<DefId>)
pub fn try_inline(
cx: &DocContext<'_, '_, '_>,
def: Def,
name: ast::Name,
visited: &mut FxHashSet<DefId>
)
-> Option<Vec<clean::Item>> {
let did = if let Some(did) = def.opt_def_id() {
did
Expand Down Expand Up @@ -124,7 +129,7 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa
Some(ret)
}

pub fn try_inline_glob(cx: &DocContext, def: Def, visited: &mut FxHashSet<DefId>)
pub fn try_inline_glob(cx: &DocContext<'_, '_, '_>, def: Def, visited: &mut FxHashSet<DefId>)
-> Option<Vec<clean::Item>>
{
if def == Def::Err { return None }
Expand All @@ -141,15 +146,15 @@ pub fn try_inline_glob(cx: &DocContext, def: Def, visited: &mut FxHashSet<DefId>
}
}

pub fn load_attrs(cx: &DocContext, did: DefId) -> clean::Attributes {
pub fn load_attrs(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Attributes {
cx.tcx.get_attrs(did).clean(cx)
}

/// Record an external fully qualified name in the external_paths cache.
///
/// These names are used later on by HTML rendering to generate things like
/// source links back to the original item.
pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) {
pub fn record_extern_fqn(cx: &DocContext<'_, '_, '_>, did: DefId, kind: clean::TypeKind) {
let mut crate_name = cx.tcx.crate_name(did.krate).to_string();
if did.is_local() {
crate_name = cx.crate_name.clone().unwrap_or(crate_name);
Expand Down Expand Up @@ -177,7 +182,7 @@ pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) {
}
}

pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
pub fn build_external_trait(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Trait {
let auto_trait = cx.tcx.trait_def(did).has_auto_impl;
let trait_items = cx.tcx.associated_items(did).map(|item| item.clean(cx)).collect();
let predicates = cx.tcx.predicates_of(did);
Expand All @@ -197,7 +202,7 @@ pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
}
}

fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
fn build_external_function(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Function {
let sig = cx.tcx.fn_sig(did);

let constness = if cx.tcx.is_min_const_fn(did) {
Expand All @@ -219,7 +224,7 @@ fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
}
}

fn build_enum(cx: &DocContext, did: DefId) -> clean::Enum {
fn build_enum(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Enum {
let predicates = cx.tcx.predicates_of(did);

clean::Enum {
Expand All @@ -229,7 +234,7 @@ fn build_enum(cx: &DocContext, did: DefId) -> clean::Enum {
}
}

fn build_struct(cx: &DocContext, did: DefId) -> clean::Struct {
fn build_struct(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Struct {
let predicates = cx.tcx.predicates_of(did);
let variant = cx.tcx.adt_def(did).non_enum_variant();

Expand All @@ -245,7 +250,7 @@ fn build_struct(cx: &DocContext, did: DefId) -> clean::Struct {
}
}

fn build_union(cx: &DocContext, did: DefId) -> clean::Union {
fn build_union(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Union {
let predicates = cx.tcx.predicates_of(did);
let variant = cx.tcx.adt_def(did).non_enum_variant();

Expand All @@ -257,7 +262,7 @@ fn build_union(cx: &DocContext, did: DefId) -> clean::Union {
}
}

fn build_type_alias(cx: &DocContext, did: DefId) -> clean::Typedef {
fn build_type_alias(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Typedef {
let predicates = cx.tcx.predicates_of(did);

clean::Typedef {
Expand All @@ -266,7 +271,7 @@ fn build_type_alias(cx: &DocContext, did: DefId) -> clean::Typedef {
}
}

pub fn build_impls(cx: &DocContext, did: DefId) -> Vec<clean::Item> {
pub fn build_impls(cx: &DocContext<'_, '_, '_>, did: DefId) -> Vec<clean::Item> {
let tcx = cx.tcx;
let mut impls = Vec::new();

Expand All @@ -277,7 +282,7 @@ pub fn build_impls(cx: &DocContext, did: DefId) -> Vec<clean::Item> {
impls
}

pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
pub fn build_impl(cx: &DocContext<'_, '_, '_>, did: DefId, ret: &mut Vec<clean::Item>) {
if !cx.renderinfo.borrow_mut().inlined.insert(did) {
return
}
Expand Down Expand Up @@ -387,15 +392,19 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
});
}

fn build_module(cx: &DocContext, did: DefId, visited: &mut FxHashSet<DefId>) -> clean::Module {
fn build_module(
cx: &DocContext<'_, '_, '_>,
did: DefId,
visited: &mut FxHashSet<DefId>
) -> clean::Module {
let mut items = Vec::new();
fill_in(cx, did, &mut items, visited);
return clean::Module {
items,
is_crate: false,
};

fn fill_in(cx: &DocContext, did: DefId, items: &mut Vec<clean::Item>,
fn fill_in(cx: &DocContext<'_, '_, '_>, did: DefId, items: &mut Vec<clean::Item>,
visited: &mut FxHashSet<DefId>) {
// If we're re-exporting a re-export it may actually re-export something in
// two namespaces, so the target may be listed twice. Make sure we only
Expand All @@ -412,30 +421,30 @@ fn build_module(cx: &DocContext, did: DefId, visited: &mut FxHashSet<DefId>) ->
}
}

pub fn print_inlined_const(cx: &DocContext, did: DefId) -> String {
pub fn print_inlined_const(cx: &DocContext<'_, '_, '_>, did: DefId) -> String {
if let Some(node_id) = cx.tcx.hir().as_local_node_id(did) {
cx.tcx.hir().node_to_pretty_string(node_id)
} else {
cx.tcx.rendered_const(did)
}
}

fn build_const(cx: &DocContext, did: DefId) -> clean::Constant {
fn build_const(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Constant {
clean::Constant {
type_: cx.tcx.type_of(did).clean(cx),
expr: print_inlined_const(cx, did)
}
}

fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
fn build_static(cx: &DocContext<'_, '_, '_>, did: DefId, mutable: bool) -> clean::Static {
clean::Static {
type_: cx.tcx.type_of(did).clean(cx),
mutability: if mutable {clean::Mutable} else {clean::Immutable},
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
}
}

fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> clean::ItemEnum {
fn build_macro(cx: &DocContext<'_, '_, '_>, did: DefId, name: ast::Name) -> clean::ItemEnum {
let imported_from = cx.tcx.original_crate_name(did.krate);
match cx.cstore.load_macro_untracked(did, cx.sess()) {
LoadedMacro::MacroDef(def) => {
Expand Down Expand Up @@ -537,7 +546,7 @@ fn separate_supertrait_bounds(mut g: clean::Generics)
(g, ty_bounds)
}

pub fn record_extern_trait(cx: &DocContext, did: DefId) {
pub fn record_extern_trait(cx: &DocContext<'_, '_, '_>, did: DefId) {
if did.is_local() {
return;
}
Expand Down
Loading