Rename "parameter" to "arg"
This commit is contained in:
parent
3e89753283
commit
76c0d68745
35 changed files with 242 additions and 355 deletions
|
|
@ -244,9 +244,8 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
|||
None
|
||||
}
|
||||
|
||||
fn generics_to_path_params(&self, generics: ty::Generics) -> hir::PathParameters {
|
||||
let mut lifetimes = vec![];
|
||||
let mut types = vec![];
|
||||
fn generics_to_path_params(&self, generics: ty::Generics) -> hir::GenericArgs {
|
||||
let mut args = vec![];
|
||||
|
||||
for param in generics.params.iter() {
|
||||
match param.kind {
|
||||
|
|
@ -257,21 +256,20 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
|||
hir::LifetimeName::Name(param.name.as_symbol())
|
||||
};
|
||||
|
||||
lifetimes.push(hir::Lifetime {
|
||||
args.push(hir::GenericArg::Lifetime(hir::Lifetime {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: DUMMY_SP,
|
||||
name,
|
||||
});
|
||||
}));
|
||||
}
|
||||
ty::GenericParamDefKind::Type {..} => {
|
||||
types.push(P(self.ty_param_to_ty(param.clone())));
|
||||
args.push(hir::GenericArg::Type(P(self.ty_param_to_ty(param.clone()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hir::PathParameters {
|
||||
lifetimes: HirVec::from_vec(lifetimes),
|
||||
types: HirVec::from_vec(types),
|
||||
hir::GenericArgs {
|
||||
args: HirVec::from_vec(args),
|
||||
bindings: HirVec::new(),
|
||||
parenthesized: false,
|
||||
}
|
||||
|
|
@ -555,9 +553,9 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
|||
let mut new_path = path.clone();
|
||||
let last_segment = new_path.segments.pop().unwrap();
|
||||
|
||||
let (old_input, old_output) = match last_segment.params {
|
||||
PathParameters::AngleBracketed { types, .. } => (types, None),
|
||||
PathParameters::Parenthesized { inputs, output, .. } => {
|
||||
let (old_input, old_output) = match last_segment.args {
|
||||
GenericArgs::AngleBracketed { types, .. } => (types, None),
|
||||
GenericArgs::Parenthesized { inputs, output, .. } => {
|
||||
(inputs, output)
|
||||
}
|
||||
};
|
||||
|
|
@ -569,14 +567,14 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
|||
);
|
||||
}
|
||||
|
||||
let new_params = PathParameters::Parenthesized {
|
||||
let new_params = GenericArgs::Parenthesized {
|
||||
inputs: old_input,
|
||||
output,
|
||||
};
|
||||
|
||||
new_path.segments.push(PathSegment {
|
||||
name: last_segment.name,
|
||||
params: new_params,
|
||||
args: new_params,
|
||||
});
|
||||
|
||||
Type::ResolvedPath {
|
||||
|
|
@ -793,13 +791,13 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
|||
|
||||
// FIXME: Remove this scope when NLL lands
|
||||
{
|
||||
let params =
|
||||
&mut new_trait_path.segments.last_mut().unwrap().params;
|
||||
let args =
|
||||
&mut new_trait_path.segments.last_mut().unwrap().args;
|
||||
|
||||
match params {
|
||||
match args {
|
||||
// Convert somethiung like '<T as Iterator::Item> = u8'
|
||||
// to 'T: Iterator<Item=u8>'
|
||||
&mut PathParameters::AngleBracketed {
|
||||
&mut GenericArgs::AngleBracketed {
|
||||
ref mut bindings,
|
||||
..
|
||||
} => {
|
||||
|
|
@ -808,7 +806,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
|||
ty: rhs,
|
||||
});
|
||||
}
|
||||
&mut PathParameters::Parenthesized { .. } => {
|
||||
&mut GenericArgs::Parenthesized { .. } => {
|
||||
existing_predicates.push(
|
||||
WherePredicate::EqPredicate {
|
||||
lhs: lhs.clone(),
|
||||
|
|
|
|||
|
|
@ -1607,7 +1607,7 @@ fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self
|
|||
def: Def::Err,
|
||||
segments: vec![PathSegment {
|
||||
name: name.to_string(),
|
||||
params: external_generic_args(cx, trait_did, has_self, bindings, substs)
|
||||
args: external_generic_args(cx, trait_did, has_self, bindings, substs)
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
|
@ -2656,7 +2656,7 @@ impl Type {
|
|||
match *self {
|
||||
ResolvedPath { ref path, .. } => {
|
||||
path.segments.last().and_then(|seg| {
|
||||
if let GenericArgs::AngleBracketed { ref types, .. } = seg.params {
|
||||
if let GenericArgs::AngleBracketed { ref types, .. } = seg.args {
|
||||
Some(&**types)
|
||||
} else {
|
||||
None
|
||||
|
|
@ -2851,7 +2851,7 @@ impl Clean<Type> for hir::Ty {
|
|||
let provided_params = &path.segments.last().unwrap();
|
||||
let mut ty_substs = FxHashMap();
|
||||
let mut lt_substs = FxHashMap();
|
||||
provided_params.with_parameters(|provided_params| {
|
||||
provided_params.with_args(|provided_params| {
|
||||
let mut indices = GenericParamCount {
|
||||
lifetimes: 0,
|
||||
types: 0
|
||||
|
|
@ -2859,8 +2859,8 @@ impl Clean<Type> for hir::Ty {
|
|||
for param in generics.params.iter() {
|
||||
match param {
|
||||
hir::GenericParam::Lifetime(lt_param) => {
|
||||
if let Some(lt) = provided_params.lifetimes
|
||||
.get(indices.lifetimes).cloned() {
|
||||
if let Some(lt) = provided_params.lifetimes()
|
||||
.nth(indices.lifetimes).cloned() {
|
||||
if !lt.is_elided() {
|
||||
let lt_def_id =
|
||||
cx.tcx.hir.local_def_id(lt_param.lifetime.id);
|
||||
|
|
@ -2872,8 +2872,8 @@ impl Clean<Type> for hir::Ty {
|
|||
hir::GenericParam::Type(ty_param) => {
|
||||
let ty_param_def =
|
||||
Def::TyParam(cx.tcx.hir.local_def_id(ty_param.id));
|
||||
if let Some(ty) = provided_params.types
|
||||
.get(indices.types).cloned() {
|
||||
if let Some(ty) = provided_params.types()
|
||||
.nth(indices.types).cloned() {
|
||||
ty_substs.insert(ty_param_def, ty.into_inner().clean(cx));
|
||||
} else if let Some(default) = ty_param.default.clone() {
|
||||
ty_substs.insert(ty_param_def,
|
||||
|
|
@ -3447,7 +3447,7 @@ impl Path {
|
|||
def: Def::Err,
|
||||
segments: vec![PathSegment {
|
||||
name,
|
||||
params: GenericArgs::AngleBracketed {
|
||||
args: GenericArgs::AngleBracketed {
|
||||
lifetimes: Vec::new(),
|
||||
types: Vec::new(),
|
||||
bindings: Vec::new(),
|
||||
|
|
@ -3471,7 +3471,7 @@ impl Clean<Path> for hir::Path {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eg, Debug, Hash)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
||||
pub enum GenericArgs {
|
||||
AngleBracketed {
|
||||
lifetimes: Vec<Lifetime>,
|
||||
|
|
@ -3509,14 +3509,14 @@ impl Clean<GenericArgs> for hir::GenericArgs {
|
|||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct PathSegment {
|
||||
pub name: String,
|
||||
pub params: GenericArgs,
|
||||
pub args: GenericArgs,
|
||||
}
|
||||
|
||||
impl Clean<PathSegment> for hir::PathSegment {
|
||||
fn clean(&self, cx: &DocContext) -> PathSegment {
|
||||
PathSegment {
|
||||
name: self.name.clean(cx),
|
||||
params: self.with_parameters(|parameters| parameters.clean(cx))
|
||||
args: self.with_args(|args| args.clean(cx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3550,7 +3550,7 @@ fn strip_path(path: &Path) -> Path {
|
|||
let segments = path.segments.iter().map(|s| {
|
||||
PathSegment {
|
||||
name: s.name.clone(),
|
||||
params: PathParameters::AngleBracketed {
|
||||
args: GenericArgs::AngleBracketed {
|
||||
lifetimes: Vec::new(),
|
||||
types: Vec::new(),
|
||||
bindings: Vec::new(),
|
||||
|
|
@ -4365,7 +4365,7 @@ where F: Fn(DefId) -> Def {
|
|||
def: def_ctor(def_id),
|
||||
segments: hir::HirVec::from_vec(apb.names.iter().map(|s| hir::PathSegment {
|
||||
name: ast::Name::intern(&s),
|
||||
parameters: None,
|
||||
args: None,
|
||||
infer_types: false,
|
||||
}).collect())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ pub fn where_clauses(cx: &DocContext, clauses: Vec<WP>) -> Vec<WP> {
|
|||
return false
|
||||
}
|
||||
let last = path.segments.last_mut().unwrap();
|
||||
match last.params {
|
||||
match last.args {
|
||||
PP::AngleBracketed { ref mut bindings, .. } => {
|
||||
bindings.push(clean::TypeBinding {
|
||||
name: name.clone(),
|
||||
|
|
|
|||
|
|
@ -369,9 +369,9 @@ impl fmt::Display for clean::PathSegment {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(&self.name)?;
|
||||
if f.alternate() {
|
||||
write!(f, "{:#}", self.params)
|
||||
write!(f, "{:#}", self.args)
|
||||
} else {
|
||||
write!(f, "{}", self.params)
|
||||
write!(f, "{}", self.args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -447,7 +447,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
|||
}
|
||||
}
|
||||
if w.alternate() {
|
||||
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
|
||||
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.args)?;
|
||||
} else {
|
||||
let path = if use_absolute {
|
||||
match href(did) {
|
||||
|
|
@ -461,7 +461,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
|||
} else {
|
||||
format!("{}", HRef::new(did, &last.name))
|
||||
};
|
||||
write!(w, "{}{}", path, last.params)?;
|
||||
write!(w, "{}{}", path, last.args)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -757,7 +757,7 @@ fn fmt_impl(i: &clean::Impl,
|
|||
clean::ResolvedPath { typarams: None, ref path, is_generic: false, .. } => {
|
||||
let last = path.segments.last().unwrap();
|
||||
fmt::Display::fmt(&last.name, f)?;
|
||||
fmt::Display::fmt(&last.params, f)?;
|
||||
fmt::Display::fmt(&last.args, f)?;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue