1
Fork 0

Make method and variable names more consistent

This commit is contained in:
varkor 2018-05-16 12:57:45 +01:00
parent 76c0d68745
commit f9d0968906
28 changed files with 183 additions and 164 deletions

View file

@ -1726,7 +1726,7 @@ impl<'a> LoweringContext<'a> {
hir::PathSegment::new(
self.lower_ident(segment.ident),
generic_args,
infer_types
infer_types,
)
}
@ -1738,7 +1738,7 @@ impl<'a> LoweringContext<'a> {
) -> (hir::GenericArgs, bool) {
let &AngleBracketedArgs { ref args, ref bindings, .. } = data;
(hir::GenericArgs {
args: args.iter().map(|p| self.lower_generic_arg(p, itctx)).collect(),
args: args.iter().map(|a| self.lower_generic_arg(a, itctx)).collect(),
bindings: bindings.iter().map(|b| self.lower_ty_binding(b, itctx)).collect(),
parenthesized: false,
},

View file

@ -360,7 +360,7 @@ impl PathSegment {
// FIXME: hack required because you can't create a static
// GenericArgs, so you can't just return a &GenericArgs.
pub fn with_args<F, R>(&self, f: F) -> R
pub fn with_generic_args<F, R>(&self, f: F) -> R
where F: FnOnce(&GenericArgs) -> R
{
let dummy = GenericArgs::none();

View file

@ -1269,11 +1269,11 @@ impl<'a> State<'a> {
self.s.word(".")?;
self.print_name(segment.name)?;
segment.with_args(|args| {
if !args.args.is_empty() ||
!args.bindings.is_empty()
segment.with_generic_args(|generic_args| {
if !generic_args.args.is_empty() ||
!generic_args.bindings.is_empty()
{
self.print_generic_args(&args, segment.infer_types, true)
self.print_generic_args(&generic_args, segment.infer_types, true)
} else {
Ok(())
}
@ -1641,10 +1641,10 @@ impl<'a> State<'a> {
if segment.name != keywords::CrateRoot.name() &&
segment.name != keywords::DollarCrate.name() {
self.print_name(segment.name)?;
segment.with_args(|parameters| {
self.print_generic_args(parameters,
segment.infer_types,
colons_before_params)
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
segment.infer_types,
colons_before_params)
})?;
}
}
@ -1673,10 +1673,10 @@ impl<'a> State<'a> {
if segment.name != keywords::CrateRoot.name() &&
segment.name != keywords::DollarCrate.name() {
self.print_name(segment.name)?;
segment.with_args(|parameters| {
self.print_generic_args(parameters,
segment.infer_types,
colons_before_params)
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
segment.infer_types,
colons_before_params)
})?;
}
}
@ -1685,10 +1685,10 @@ impl<'a> State<'a> {
self.s.word("::")?;
let item_segment = path.segments.last().unwrap();
self.print_name(item_segment.name)?;
item_segment.with_args(|parameters| {
self.print_generic_args(parameters,
item_segment.infer_types,
colons_before_params)
item_segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
item_segment.infer_types,
colons_before_params)
})
}
hir::QPath::TypeRelative(ref qself, ref item_segment) => {
@ -1697,10 +1697,10 @@ impl<'a> State<'a> {
self.s.word(">")?;
self.s.word("::")?;
self.print_name(item_segment.name)?;
item_segment.with_args(|parameters| {
self.print_generic_args(parameters,
item_segment.infer_types,
colons_before_params)
item_segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
item_segment.infer_types,
colons_before_params)
})
}
}
@ -1734,11 +1734,11 @@ impl<'a> State<'a> {
let elide_lifetimes = generic_args.lifetimes().all(|lt| lt.is_elided());
if !elide_lifetimes {
start_or_comma(self)?;
self.commasep(Inconsistent, &generic_args.args, |s, p| {
match p {
self.commasep(Inconsistent, &generic_args.args, |s, generic_arg| {
match generic_arg {
GenericArg::Lifetime(lt) => s.print_lifetime(lt),
GenericArg::Type(ty) => s.print_type(ty),
}
}
})?;
} else if generic_args.types().count() != 0 {
start_or_comma(self)?;

View file

@ -1601,20 +1601,21 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
&mut self,
def: Def,
depth: usize,
args: &'tcx hir::GenericArgs,
generic_args: &'tcx hir::GenericArgs,
) {
if args.parenthesized {
if generic_args.parenthesized {
let was_in_fn_syntax = self.is_in_fn_syntax;
self.is_in_fn_syntax = true;
self.visit_fn_like_elision(args.inputs(), Some(&args.bindings[0].ty));
self.visit_fn_like_elision(generic_args.inputs(),
Some(&generic_args.bindings[0].ty));
self.is_in_fn_syntax = was_in_fn_syntax;
return;
}
if args.lifetimes().all(|l| l.is_elided()) {
self.resolve_elided_lifetimes(args.lifetimes().collect(), true);
if generic_args.lifetimes().all(|l| l.is_elided()) {
self.resolve_elided_lifetimes(generic_args.lifetimes().collect(), true);
} else {
for l in args.lifetimes() {
for l in generic_args.lifetimes() {
self.visit_lifetime(l);
}
}
@ -1686,13 +1687,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
} else {
Some(Region::Static)
},
Set1::One(r) => r.subst(args.lifetimes(), map),
Set1::One(r) => r.subst(generic_args.lifetimes(), map),
Set1::Many => None,
})
.collect()
});
for (i, ty) in args.types().enumerate() {
for (i, ty) in generic_args.types().enumerate() {
if let Some(&lt) = object_lifetime_defaults.get(i) {
let scope = Scope::ObjectLifetimeDefault {
lifetime: lt,
@ -1704,7 +1705,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
}
for b in &args.bindings {
for b in &generic_args.bindings {
self.visit_assoc_type_binding(b);
}
}

View file

@ -10,7 +10,6 @@
use hir::def_id::DefId;
use ty::{self, Ty, TypeFoldable, Substs, TyCtxt};
use ty::subst::Kind;
use traits;
use rustc_target::spec::abi::Abi;
use util::ppaux;

View file

@ -105,10 +105,6 @@ impl<'tcx> From<Ty<'tcx>> for Kind<'tcx> {
}
}
impl<'tcx> Into<Kind<'tcx>> for ty::Region<'tcx> {}
impl<'tcx> Into<Kind<'tcx>> for Ty<'tcx> {}
impl<'tcx> Kind<'tcx> {
#[inline]
pub fn unpack(self) -> UnpackedKind<'tcx> {

View file

@ -40,7 +40,6 @@ use rustc::middle::weak_lang_items;
use rustc::mir::mono::{Linkage, Visibility, Stats};
use rustc::middle::cstore::{EncodedMetadata};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::subst::Kind;
use rustc::ty::layout::{self, Align, TyLayout, LayoutOf};
use rustc::ty::query::Providers;
use rustc::dep_graph::{DepNode, DepConstructor};

View file

@ -677,7 +677,7 @@ impl<'a> ReplaceBodyWithLoop<'a> {
ast::TyKind::Paren(ref subty) => involves_impl_trait(subty),
ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()),
ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| {
match seg.args.as_ref().map(|p| &**p) {
match seg.args.as_ref().map(|generic_arg| &**generic_arg) {
None => false,
Some(&ast::GenericArgs::AngleBracketed(ref data)) =>
any_involves_impl_trait(data.types().into_iter()) ||

View file

@ -13,7 +13,6 @@ use rustc::middle::lang_items::DropInPlaceFnLangItem;
use rustc::traits;
use rustc::ty::adjustment::CustomCoerceUnsized;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::subst::Kind;
pub use rustc::ty::Instance;
pub use self::item::{MonoItem, MonoItemExt};

View file

@ -523,21 +523,21 @@ impl<'a> Visitor<'a> for NestedImplTraitVisitor<'a> {
}
fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) {
match *generic_args {
GenericArgs::AngleBracketed(ref params) => {
for type_ in params.types() {
GenericArgs::AngleBracketed(ref generic_args) => {
for type_ in generic_args.types() {
self.visit_ty(type_);
}
for type_binding in &params.bindings {
for type_binding in &generic_args.bindings {
// Type bindings such as `Item=impl Debug` in `Iterator<Item=Debug>`
// are allowed to contain nested `impl Trait`.
self.with_impl_trait(None, |this| visit::walk_ty(this, &type_binding.ty));
}
}
GenericArgs::Parenthesized(ref params) => {
for type_ in &params.inputs {
GenericArgs::Parenthesized(ref generic_args) => {
for type_ in &generic_args.inputs {
self.visit_ty(type_);
}
if let Some(ref type_) = params.output {
if let Some(ref type_) = generic_args.output {
// `-> Foo` syntax is essentially an associated type binding,
// so it is also allowed to contain nested `impl Trait`.
self.with_impl_trait(None, |this| visit::walk_ty(this, type_));

View file

@ -820,8 +820,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
// Type arguments
for seg in &path.segments {
if let Some(ref args) = seg.args {
match **args {
if let Some(ref generic_args) = seg.args {
match **generic_args {
ast::GenericArgs::AngleBracketed(ref data) => for t in data.types() {
self.visit_ty(t);
},
@ -905,8 +905,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
}
// Explicit types in the turbo-fish.
if let Some(ref args) = seg.args {
if let ast::GenericArgs::AngleBracketed(ref data) = **args {
if let Some(ref generic_args) = seg.args {
if let ast::GenericArgs::AngleBracketed(ref data) = **generic_args {
for t in data.types() {
self.visit_ty(t);
}

View file

@ -692,8 +692,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
if path.segments.len() != 1 {
return false;
}
if let Some(ref args) = path.segments[0].args {
if let ast::GenericArgs::Parenthesized(_) = **args {
if let Some(ref generic_args) = path.segments[0].args {
if let ast::GenericArgs::Parenthesized(_) = **generic_args {
return true;
}
}

View file

@ -177,11 +177,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
{
let (substs, assoc_bindings) =
item_segment.with_args(|args| {
item_segment.with_generic_args(|generic_args| {
self.create_substs_for_ast_path(
span,
def_id,
args,
generic_args,
item_segment.infer_types,
None)
});
@ -199,7 +199,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
fn create_substs_for_ast_path(&self,
span: Span,
def_id: DefId,
args: &hir::GenericArgs,
generic_args: &hir::GenericArgs,
infer_types: bool,
self_ty: Option<Ty<'tcx>>)
-> (&'tcx Substs<'tcx>, Vec<ConvertedBinding<'tcx>>)
@ -207,15 +207,15 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
let tcx = self.tcx();
debug!("create_substs_for_ast_path(def_id={:?}, self_ty={:?}, \
args={:?})",
def_id, self_ty, args);
generic_args={:?})",
def_id, self_ty, generic_args);
// If the type is parameterized by this region, then replace this
// region with the current anon region binding (in other words,
// whatever & would get replaced with).
let decl_generics = tcx.generics_of(def_id);
let ty_provided = args.types().count();
let lt_provided = args.lifetimes().count();
let ty_provided = generic_args.types().count();
let lt_provided = generic_args.lifetimes().count();
let mut lt_accepted = 0;
let mut ty_params = ParamRange { required: 0, accepted: 0 };
@ -269,7 +269,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
match param.kind {
GenericParamDefKind::Lifetime => {
let i = param.index as usize - own_self;
if let Some(lifetime) = args.lifetimes().nth(i) {
if let Some(lifetime) = generic_args.lifetimes().nth(i) {
self.ast_region_to_region(lifetime, Some(param)).into()
} else {
tcx.types.re_static.into()
@ -286,7 +286,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
let i = i - (lt_accepted + own_self);
if i < ty_provided {
// A provided type parameter.
self.ast_ty_to_ty(&args.types().nth(i).unwrap()).into()
self.ast_ty_to_ty(&generic_args.types().nth(i).unwrap()).into()
} else if infer_types {
// No type parameters were provided, we can infer all.
if !default_needs_object_self(param) {
@ -330,7 +330,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
}
});
let assoc_bindings = args.bindings.iter().map(|binding| {
let assoc_bindings = generic_args.bindings.iter().map(|binding| {
ConvertedBinding {
item_name: binding.name,
ty: self.ast_ty_to_ty(&binding.ty),
@ -451,7 +451,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
let trait_def = self.tcx().trait_def(trait_def_id);
if !self.tcx().features().unboxed_closures &&
trait_segment.with_args(|p| p.parenthesized) != trait_def.paren_sugar {
trait_segment.with_generic_args(|generic_args| generic_args.parenthesized)
!= trait_def.paren_sugar {
// For now, require that parenthetical notation be used only with `Fn()` etc.
let msg = if trait_def.paren_sugar {
"the precise format of `Fn`-family traits' type parameters is subject to change. \
@ -463,10 +464,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
span, GateIssue::Language, msg);
}
trait_segment.with_args(|parameters| {
trait_segment.with_generic_args(|generic_args| {
self.create_substs_for_ast_path(span,
trait_def_id,
parameters,
generic_args,
trait_segment.infer_types,
Some(self_ty))
})
@ -970,27 +971,36 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
pub fn prohibit_type_params(&self, segments: &[hir::PathSegment]) {
for segment in segments {
segment.with_args(|params| {
for p in &params.args {
let (mut span_err, span, kind) = match p {
segment.with_generic_args(|generic_args| {
let mut err_for_lifetime = false;
let mut err_for_type = false;
for arg in &generic_args.args {
let (mut span_err, span, kind) = match arg {
hir::GenericArg::Lifetime(lt) => {
if err_for_lifetime { continue }
err_for_lifetime = true;
(struct_span_err!(self.tcx().sess, lt.span, E0110,
"lifetime parameters are not allowed on this type"),
"lifetime parameters are not allowed on \
this type"),
lt.span,
"lifetime")
}
hir::GenericArg::Type(ty) => {
if err_for_type { continue }
err_for_type = true;
(struct_span_err!(self.tcx().sess, ty.span, E0109,
"type parameters are not allowed on this type"),
"type parameters are not allowed on this type"),
ty.span,
"type")
}
};
span_err.span_label(span, format!("{} parameter not allowed", kind))
.emit();
break;
if err_for_lifetime && err_for_type {
break;
}
}
for binding in &params.bindings {
for binding in &generic_args.bindings {
self.prohibit_projection(binding.span);
break;
}

View file

@ -4834,7 +4834,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
match param.kind {
GenericParamDefKind::Lifetime => {
let lifetimes = segment.map_or(vec![], |(s, _)| {
s.args.as_ref().map_or(vec![], |p| p.lifetimes().collect())
s.args.as_ref().map_or(vec![], |arg| arg.lifetimes().collect())
});
if let Some(lifetime) = lifetimes.get(i) {
@ -4845,7 +4845,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
GenericParamDefKind::Type {..} => {
let (types, infer_types) = segment.map_or((vec![], true), |(s, _)| {
(s.args.as_ref().map_or(vec![], |p| p.types().collect()), s.infer_types)
(s.args.as_ref().map_or(vec![], |arg| {
arg.types().collect()
}), s.infer_types)
});
// Skip over the lifetimes in the same segment.
@ -4956,16 +4958,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// Report errors if the provided parameters are too few or too many.
fn check_generic_arg_count(&self,
span: Span,
segment: &mut Option<(&hir::PathSegment, &ty::Generics)>,
is_method_call: bool,
supress_mismatch_error: bool) {
span: Span,
segment: &mut Option<(&hir::PathSegment, &ty::Generics)>,
is_method_call: bool,
supress_mismatch_error: bool) {
let (lifetimes, types, infer_types, bindings) = segment.map_or(
(vec![], vec![], true, &[][..]),
|(s, _)| s.args.as_ref().map_or(
(vec![], vec![], s.infer_types, &[][..]),
|p| (p.lifetimes().collect(), p.types().collect(),
s.infer_types, &p.bindings[..])));
|(s, _)| {
s.args.as_ref().map_or(
(vec![], vec![], s.infer_types, &[][..]),
|arg| {
(arg.lifetimes().collect(),
arg.types().collect(),
s.infer_types,
&arg.bindings[..])
}
)
});
let infer_lifetimes = lifetimes.len() == 0;
let count_lifetime_params = |n| {

View file

@ -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_args(|provided_params| {
provided_params.with_generic_args(|generic_args| {
let mut indices = GenericParamCount {
lifetimes: 0,
types: 0
@ -2859,7 +2859,7 @@ 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()
if let Some(lt) = generic_args.lifetimes()
.nth(indices.lifetimes).cloned() {
if !lt.is_elided() {
let lt_def_id =
@ -2872,7 +2872,7 @@ 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()
if let Some(ty) = generic_args.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() {
@ -3497,9 +3497,9 @@ impl Clean<GenericArgs> for hir::GenericArgs {
lifetimes: if self.lifetimes().all(|lt| lt.is_elided()) {
vec![]
} else {
self.lifetimes().map(|lp| lp.clean(cx)).collect()
self.lifetimes().map(|lt| lt.clean(cx)).collect()
},
types: self.types().map(|tp| tp.clean(cx)).collect(),
types: self.types().map(|ty| ty.clean(cx)).collect(),
bindings: self.bindings.clean(cx),
}
}
@ -3516,7 +3516,7 @@ impl Clean<PathSegment> for hir::PathSegment {
fn clean(&self, cx: &DocContext) -> PathSegment {
PathSegment {
name: self.name.clean(cx),
args: self.with_args(|args| args.clean(cx))
args: self.with_generic_args(|generic_args| generic_args.clean(cx))
}
}
}

View file

@ -188,8 +188,8 @@ pub struct AngleBracketedArgs {
impl AngleBracketedArgs {
pub fn lifetimes(&self) -> impl DoubleEndedIterator<Item = &Lifetime> {
self.args.iter().filter_map(|p| {
if let GenericArg::Lifetime(lt) = p {
self.args.iter().filter_map(|arg| {
if let GenericArg::Lifetime(lt) = arg {
Some(lt)
} else {
None
@ -198,8 +198,8 @@ impl AngleBracketedArgs {
}
pub fn types(&self) -> impl DoubleEndedIterator<Item = &P<Ty>> {
self.args.iter().filter_map(|p| {
if let GenericArg::Type(ty) = p {
self.args.iter().filter_map(|arg| {
if let GenericArg::Type(ty) = arg {
Some(ty)
} else {
None

View file

@ -31,7 +31,7 @@ pub trait AstBuilder {
fn path_all(&self, sp: Span,
global: bool,
idents: Vec<ast::Ident>,
parameters: Vec<ast::GenericArg>,
args: Vec<ast::GenericArg>,
bindings: Vec<ast::TypeBinding>)
-> ast::Path;
@ -42,7 +42,7 @@ pub trait AstBuilder {
fn qpath_all(&self, self_type: P<ast::Ty>,
trait_path: ast::Path,
ident: ast::Ident,
parameters: Vec<ast::GenericArg>,
args: Vec<ast::GenericArg>,
bindings: Vec<ast::TypeBinding>)
-> (ast::QSelf, ast::Path);
@ -302,13 +302,13 @@ pub trait AstBuilder {
impl<'a> AstBuilder for ExtCtxt<'a> {
fn path(&self, span: Span, strs: Vec<ast::Ident> ) -> ast::Path {
self.path_all(span, false, strs, Vec::new(), Vec::new())
self.path_all(span, false, strs, vec![], vec![])
}
fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path {
self.path(span, vec![id])
}
fn path_global(&self, span: Span, strs: Vec<ast::Ident> ) -> ast::Path {
self.path_all(span, true, strs, Vec::new(), Vec::new())
self.path_all(span, true, strs, vec![], vec![])
}
fn path_all(&self,
span: Span,
@ -318,7 +318,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
bindings: Vec<ast::TypeBinding> )
-> ast::Path {
let last_ident = idents.pop().unwrap();
let mut segments: Vec<ast::PathSegment> = Vec::new();
let mut segments: Vec<ast::PathSegment> = vec![];
segments.extend(idents.into_iter().map(|ident| {
ast::PathSegment::from_ident(ident.with_span_pos(span))
@ -424,7 +424,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.path_all(DUMMY_SP,
true,
self.std_path(&["option", "Option"]),
vec![ ast::GenericArg::Type(ty) ],
vec![ast::GenericArg::Type(ty)],
Vec::new()))
}

View file

@ -132,10 +132,9 @@ pub trait Folder : Sized {
noop_fold_exprs(es, self)
}
fn fold_param(&mut self, p: GenericArg) -> GenericArg {
match p {
GenericArg::Lifetime(lt) =>
GenericArg::Lifetime(self.fold_lifetime(lt)),
fn fold_generic_arg(&mut self, arg: GenericArg) -> GenericArg {
match arg {
GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.fold_lifetime(lt)),
GenericArg::Type(ty) => GenericArg::Type(self.fold_ty(ty)),
}
}
@ -441,9 +440,9 @@ pub fn noop_fold_usize<T: Folder>(i: usize, _: &mut T) -> usize {
pub fn noop_fold_path<T: Folder>(Path { segments, span }: Path, fld: &mut T) -> Path {
Path {
segments: segments.move_map(|PathSegment {ident, args}| PathSegment {
segments: segments.move_map(|PathSegment { ident, args }| PathSegment {
ident: fld.fold_ident(ident),
args: args.map(|ps| ps.map(|ps| fld.fold_generic_args(ps))),
args: args.map(|args| args.map(|args| fld.fold_generic_args(args))),
}),
span: fld.new_span(span)
}
@ -462,14 +461,15 @@ pub fn noop_fold_qpath<T: Folder>(qself: Option<QSelf>,
(qself, fld.fold_path(path))
}
pub fn noop_fold_generic_args<T: Folder>(generic_args: GenericArgs, fld: &mut T)
-> GenericArgs
pub fn noop_fold_generic_args<T: Folder>(generic_args: GenericArgs, fld: &mut T) -> GenericArgs
{
match generic_args {
GenericArgs::AngleBracketed(data) =>
GenericArgs::AngleBracketed(fld.fold_angle_bracketed_parameter_data(data)),
GenericArgs::Parenthesized(data) =>
GenericArgs::Parenthesized(fld.fold_parenthesized_parameter_data(data)),
GenericArgs::AngleBracketed(data) => {
GenericArgs::AngleBracketed(fld.fold_angle_bracketed_parameter_data(data))
}
GenericArgs::Parenthesized(data) => {
GenericArgs::Parenthesized(fld.fold_parenthesized_parameter_data(data))
}
}
}
@ -478,9 +478,11 @@ pub fn noop_fold_angle_bracketed_parameter_data<T: Folder>(data: AngleBracketedA
-> AngleBracketedArgs
{
let AngleBracketedArgs { args, bindings, span } = data;
AngleBracketedArgs { args: args.move_map(|p| fld.fold_param(p)),
bindings: bindings.move_map(|b| fld.fold_ty_binding(b)),
span: fld.new_span(span) }
AngleBracketedArgs {
args: args.move_map(|arg| fld.fold_generic_arg(arg)),
bindings: bindings.move_map(|b| fld.fold_ty_binding(b)),
span: fld.new_span(span)
}
}
pub fn noop_fold_parenthesized_parameter_data<T: Folder>(data: ParenthesizedArgData,
@ -488,9 +490,11 @@ pub fn noop_fold_parenthesized_parameter_data<T: Folder>(data: ParenthesizedArgD
-> ParenthesizedArgData
{
let ParenthesizedArgData { inputs, output, span } = data;
ParenthesizedArgData { inputs: inputs.move_map(|ty| fld.fold_ty(ty)),
output: output.map(|ty| fld.fold_ty(ty)),
span: fld.new_span(span) }
ParenthesizedArgData {
inputs: inputs.move_map(|ty| fld.fold_ty(ty)),
output: output.map(|ty| fld.fold_ty(ty)),
span: fld.new_span(span)
}
}
pub fn noop_fold_local<T: Folder>(l: P<Local>, fld: &mut T) -> P<Local> {
@ -1191,8 +1195,8 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
ExprKind::MethodCall(
PathSegment {
ident: folder.fold_ident(seg.ident),
args: seg.args.map(|ps| {
ps.map(|ps| folder.fold_generic_args(ps))
args: seg.args.map(|args| {
args.map(|args| folder.fold_generic_args(args))
}),
},
folder.fold_exprs(args))

View file

@ -1017,8 +1017,8 @@ impl<'a> State<'a> {
Ok(())
}
pub fn print_param(&mut self, param: &GenericArg) -> io::Result<()> {
match param {
pub fn print_generic_arg(&mut self, generic_arg: &GenericArg) -> io::Result<()> {
match generic_arg {
GenericArg::Lifetime(lt) => self.print_lifetime(lt),
GenericArg::Type(ty) => self.print_type(ty),
}
@ -2469,9 +2469,9 @@ impl<'a> State<'a> {
}
fn print_generic_args(&mut self,
args: &ast::GenericArgs,
colons_before_params: bool)
-> io::Result<()>
args: &ast::GenericArgs,
colons_before_params: bool)
-> io::Result<()>
{
if colons_before_params {
self.s.word("::")?
@ -2481,7 +2481,9 @@ impl<'a> State<'a> {
ast::GenericArgs::AngleBracketed(ref data) => {
self.s.word("<")?;
self.commasep(Inconsistent, &data.args, |s, p| s.print_param(p))?;
self.commasep(Inconsistent, &data.args, |s, generic_arg| {
s.print_generic_arg(generic_arg)
})?;
let mut comma = data.args.len() != 0;

View file

@ -131,8 +131,8 @@ pub trait Visitor<'ast>: Sized {
fn visit_generic_args(&mut self, path_span: Span, generic_args: &'ast GenericArgs) {
walk_generic_args(self, path_span, generic_args)
}
fn visit_angle_bracketed_param(&mut self, param: &'ast GenericArg) {
match param {
fn visit_generic_arg(&mut self, generic_arg: &'ast GenericArg) {
match generic_arg {
GenericArg::Lifetime(lt) => self.visit_lifetime(lt),
GenericArg::Type(ty) => self.visit_ty(ty),
}
@ -393,7 +393,7 @@ pub fn walk_generic_args<'a, V>(visitor: &mut V,
{
match *generic_args {
GenericArgs::AngleBracketed(ref data) => {
walk_list!(visitor, visit_angle_bracketed_param, &data.args);
walk_list!(visitor, visit_generic_arg, &data.args);
walk_list!(visitor, visit_assoc_type_binding, &data.bindings);
}
GenericArgs::Parenthesized(ref data) => {

View file

@ -2,7 +2,7 @@ error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/E0110.rs:11:14
|
LL | type X = u32<'static>; //~ ERROR E0110
| ^^^^^^^ lifetime parameter not allowed on this type
| ^^^^^^^ lifetime parameter not allowed
error: aborting due to previous error

View file

@ -20,13 +20,13 @@ error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/collections.rs:33:50
|
LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter>;
| ^^^^^ lifetime parameter not allowed on this type
| ^^^^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/collections.rs:59:50
|
LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter> {
| ^^^^^ lifetime parameter not allowed on this type
| ^^^^^ lifetime parameter not allowed
error: aborting due to 5 previous errors

View file

@ -2,19 +2,19 @@ error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/construct_with_other_type.rs:26:46
|
LL | type Baa<'a>: Deref<Target = <Self::Quux<'a> as Foo>::Bar<'a, 'static>>;
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/construct_with_other_type.rs:26:63
|
LL | type Baa<'a>: Deref<Target = <Self::Quux<'a> as Foo>::Bar<'a, 'static>>;
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/construct_with_other_type.rs:34:40
|
LL | type Baa<'a> = &'a <T as Foo>::Bar<'a, 'static>;
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error: aborting due to 3 previous errors

View file

@ -14,19 +14,19 @@ error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:20:47
|
LL | type Iter<'a>: Iterator<Item = Self::Item<'a>>
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37
|
LL | + Deref<Target = Self::Item<'b>>;
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
| ^^^^^^^^^^^ lifetime parameter not allowed on this type
| ^^^^^^^^^^^ lifetime parameter not allowed
error: aborting due to 5 previous errors

View file

@ -2,37 +2,37 @@ error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:20:47
|
LL | type Iter<'a>: Iterator<Item = Self::Item<'a>>;
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:49:53
|
LL | fn make_iter<'a, I: Iterable>(it: &'a I) -> I::Iter<'a> {
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:54:60
|
LL | fn get_first<'a, I: Iterable>(it: &'a I) -> Option<I::Item<'a>> {
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:23:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'a>;
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:32:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'a> {
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:43:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'a> {
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error: aborting due to 6 previous errors

View file

@ -1,20 +1,26 @@
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/parameter_number_and_kind.rs:26:27
|
LL | type FOk<T> = Self::E<'static, T>;
| ^^^^^^^ lifetime parameter not allowed
error[E0109]: type parameters are not allowed on this type
--> $DIR/parameter_number_and_kind.rs:26:36
|
LL | type FOk<T> = Self::E<'static, T>;
| ^ type parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/parameter_number_and_kind.rs:26:27
|
LL | type FOk<T> = Self::E<'static, T>;
| ^^^^^^^ lifetime parameter not allowed on this type
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/parameter_number_and_kind.rs:29:26
|
LL | type FErr1 = Self::E<'static, 'static>; // Error
| ^^^^^^^ lifetime parameter not allowed on this type
| ^^^^^^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/parameter_number_and_kind.rs:31:29
|
LL | type FErr2<T> = Self::E<'static, T, u32>; // Error
| ^^^^^^^ lifetime parameter not allowed
error[E0109]: type parameters are not allowed on this type
--> $DIR/parameter_number_and_kind.rs:31:38
@ -22,12 +28,6 @@ error[E0109]: type parameters are not allowed on this type
LL | type FErr2<T> = Self::E<'static, T, u32>; // Error
| ^ type parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/parameter_number_and_kind.rs:31:29
|
LL | type FErr2<T> = Self::E<'static, T, u32>; // Error
| ^^^^^^^ lifetime parameter not allowed on this type
error: aborting due to 5 previous errors
Some errors occurred: E0109, E0110.

View file

@ -10,7 +10,7 @@
#![feature(generic_associated_types)]
//FIXME(#44265): "lifetime parameter not allowed" errors will be addressed in a
//FIXME(#44265): "lifetime parameter not allowed on this type" errors will be addressed in a
// follow-up PR
use std::fmt::Display;

View file

@ -2,31 +2,31 @@ error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/streaming_iterator.rs:27:41
|
LL | bar: <T as StreamingIterator>::Item<'static>,
| ^^^^^^^ lifetime parameter not allowed on this type
| ^^^^^^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/streaming_iterator.rs:35:64
|
LL | fn foo<T>(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ }
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/streaming_iterator.rs:21:48
|
LL | fn next<'a>(&'a self) -> Option<Self::Item<'a>>;
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/streaming_iterator.rs:47:37
|
LL | type Item<'a> = (usize, I::Item<'a>);
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/streaming_iterator.rs:49:48
|
LL | fn next<'a>(&'a self) -> Option<Self::Item<'a>> {
| ^^ lifetime parameter not allowed on this type
| ^^ lifetime parameter not allowed
error: aborting due to 5 previous errors