Stop re-exporting PathParameters's variants.

This commit is contained in:
Ms2ger 2015-12-22 16:56:13 +01:00
parent 42c3ef8f9f
commit 2359ab0dc9
8 changed files with 36 additions and 35 deletions

View File

@ -319,9 +319,9 @@ pub fn lower_path_parameters(lctx: &LoweringContext,
path_parameters: &PathParameters)
-> hir::PathParameters {
match *path_parameters {
AngleBracketedParameters(ref data) =>
PathParameters::AngleBracketed(ref data) =>
hir::AngleBracketedParameters(lower_angle_bracketed_parameter_data(lctx, data)),
ParenthesizedParameters(ref data) =>
PathParameters::Parenthesized(ref data) =>
hir::ParenthesizedParameters(lower_parenthesized_parameter_data(lctx, data)),
}
}

View File

@ -250,14 +250,14 @@ pub struct PathSegment {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum PathParameters {
/// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>`
AngleBracketedParameters(AngleBracketedParameterData),
AngleBracketed(AngleBracketedParameterData),
/// The `(A,B)` and `C` in `Foo(A,B) -> C`
ParenthesizedParameters(ParenthesizedParameterData),
Parenthesized(ParenthesizedParameterData),
}
impl PathParameters {
pub fn none() -> PathParameters {
AngleBracketedParameters(AngleBracketedParameterData {
PathParameters::AngleBracketed(AngleBracketedParameterData {
lifetimes: Vec::new(),
types: P::empty(),
bindings: P::empty(),
@ -266,25 +266,25 @@ impl PathParameters {
pub fn is_empty(&self) -> bool {
match *self {
AngleBracketedParameters(ref data) => data.is_empty(),
PathParameters::AngleBracketed(ref data) => data.is_empty(),
// Even if the user supplied no types, something like
// `X()` is equivalent to `X<(),()>`.
ParenthesizedParameters(..) => false,
PathParameters::Parenthesized(..) => false,
}
}
pub fn has_lifetimes(&self) -> bool {
match *self {
AngleBracketedParameters(ref data) => !data.lifetimes.is_empty(),
ParenthesizedParameters(_) => false,
PathParameters::AngleBracketed(ref data) => !data.lifetimes.is_empty(),
PathParameters::Parenthesized(_) => false,
}
}
pub fn has_types(&self) -> bool {
match *self {
AngleBracketedParameters(ref data) => !data.types.is_empty(),
ParenthesizedParameters(..) => true,
PathParameters::AngleBracketed(ref data) => !data.types.is_empty(),
PathParameters::Parenthesized(..) => true,
}
}
@ -292,10 +292,10 @@ impl PathParameters {
/// parameters in the parenthesized case.
pub fn types(&self) -> Vec<&P<Ty>> {
match *self {
AngleBracketedParameters(ref data) => {
PathParameters::AngleBracketed(ref data) => {
data.types.iter().collect()
}
ParenthesizedParameters(ref data) => {
PathParameters::Parenthesized(ref data) => {
data.inputs.iter()
.chain(data.output.iter())
.collect()
@ -305,10 +305,10 @@ impl PathParameters {
pub fn lifetimes(&self) -> Vec<&Lifetime> {
match *self {
AngleBracketedParameters(ref data) => {
PathParameters::AngleBracketed(ref data) => {
data.lifetimes.iter().collect()
}
ParenthesizedParameters(_) => {
PathParameters::Parenthesized(_) => {
Vec::new()
}
}
@ -316,10 +316,10 @@ impl PathParameters {
pub fn bindings(&self) -> Vec<&P<TypeBinding>> {
match *self {
AngleBracketedParameters(ref data) => {
PathParameters::AngleBracketed(ref data) => {
data.bindings.iter().collect()
}
ParenthesizedParameters(_) => {
PathParameters::Parenthesized(_) => {
Vec::new()
}
}

View File

@ -40,7 +40,7 @@ pub fn ident_to_path(s: Span, identifier: Ident) -> Path {
segments: vec!(
ast::PathSegment {
identifier: identifier,
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
parameters: ast::PathParameters::AngleBracketed(ast::AngleBracketedParameterData {
lifetimes: Vec::new(),
types: P::empty(),
bindings: P::empty(),

View File

@ -328,7 +328,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
}).collect();
segments.push(ast::PathSegment {
identifier: last_identifier,
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
parameters: ast::PathParameters::AngleBracketed(ast::AngleBracketedParameterData {
lifetimes: lifetimes,
types: P::from_vec(types),
bindings: P::from_vec(bindings),
@ -366,7 +366,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
let mut path = trait_path;
path.segments.push(ast::PathSegment {
identifier: ident,
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
parameters: ast::PathParameters::AngleBracketed(ast::AngleBracketedParameterData {
lifetimes: lifetimes,
types: P::from_vec(types),
bindings: P::from_vec(bindings),

View File

@ -469,10 +469,10 @@ pub fn noop_fold_path_parameters<T: Folder>(path_parameters: PathParameters, fld
-> PathParameters
{
match path_parameters {
AngleBracketedParameters(data) =>
AngleBracketedParameters(fld.fold_angle_bracketed_parameter_data(data)),
ParenthesizedParameters(data) =>
ParenthesizedParameters(fld.fold_parenthesized_parameter_data(data)),
PathParameters::AngleBracketed(data) =>
PathParameters::AngleBracketed(fld.fold_angle_bracketed_parameter_data(data)),
PathParameters::Parenthesized(data) =>
PathParameters::Parenthesized(fld.fold_parenthesized_parameter_data(data)),
}
}

View File

@ -1706,7 +1706,7 @@ impl<'a> Parser<'a> {
let parameters = if try!(self.eat_lt() ){
let (lifetimes, types, bindings) = try!(self.parse_generic_values_after_lt());
ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
ast::PathParameters::AngleBracketed(ast::AngleBracketedParameterData {
lifetimes: lifetimes,
types: P::from_vec(types),
bindings: P::from_vec(bindings),
@ -1727,7 +1727,7 @@ impl<'a> Parser<'a> {
let hi = self.last_span.hi;
ast::ParenthesizedParameters(ast::ParenthesizedParameterData {
ast::PathParameters::Parenthesized(ast::ParenthesizedParameterData {
span: mk_sp(lo, hi),
inputs: inputs,
output: output_ty,
@ -1768,13 +1768,14 @@ impl<'a> Parser<'a> {
if try!(self.eat_lt() ){
// Consumed `a::b::<`, go look for types
let (lifetimes, types, bindings) = try!(self.parse_generic_values_after_lt());
let parameters = ast::AngleBracketedParameterData {
lifetimes: lifetimes,
types: P::from_vec(types),
bindings: P::from_vec(bindings),
};
segments.push(ast::PathSegment {
identifier: identifier,
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
lifetimes: lifetimes,
types: P::from_vec(types),
bindings: P::from_vec(bindings),
}),
parameters: ast::PathParameters::AngleBracketed(parameters),
});
// Consumed `a::b::<T,U>`, check for `::` before proceeding

View File

@ -2403,7 +2403,7 @@ impl<'a> State<'a> {
}
match *parameters {
ast::AngleBracketedParameters(ref data) => {
ast::PathParameters::AngleBracketed(ref data) => {
try!(word(&mut self.s, "<"));
let mut comma = false;
@ -2440,7 +2440,7 @@ impl<'a> State<'a> {
try!(word(&mut self.s, ">"))
}
ast::ParenthesizedParameters(ref data) => {
ast::PathParameters::Parenthesized(ref data) => {
try!(word(&mut self.s, "("));
try!(self.commasep(
Inconsistent,

View File

@ -399,12 +399,12 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
_path_span: Span,
path_parameters: &'v PathParameters) {
match *path_parameters {
AngleBracketedParameters(ref data) => {
PathParameters::AngleBracketed(ref data) => {
walk_list!(visitor, visit_ty, &data.types);
walk_list!(visitor, visit_lifetime, &data.lifetimes);
walk_list!(visitor, visit_assoc_type_binding, &data.bindings);
}
ParenthesizedParameters(ref data) => {
PathParameters::Parenthesized(ref data) => {
walk_list!(visitor, visit_ty, &data.inputs);
walk_list!(visitor, visit_ty, &data.output);
}