Skip to content

Purge |:| notation from types and trait references, in favor of Foo() #18630

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

Merged
merged 3 commits into from
Nov 7, 2014
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
5 changes: 2 additions & 3 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ register_diagnostics!(
E0044,
E0045,
E0046,
E0047,
E0049,
E0050,
E0051,
Expand Down Expand Up @@ -111,7 +110,6 @@ register_diagnostics!(
E0108,
E0109,
E0110,
E0113,
E0116,
E0117,
E0118,
Expand Down Expand Up @@ -145,5 +143,6 @@ register_diagnostics!(
E0163,
E0164,
E0165,
E0166
E0166,
E0167
)
2 changes: 1 addition & 1 deletion src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
// to handle on-demand instantiation of functions via
// foo::<bar> in a const. Currently that is only done on
// a path in trans::callee that only works in block contexts.
if !pth.segments.iter().all(|segment| segment.types.is_empty()) {
if !pth.segments.iter().all(|segment| segment.parameters.is_empty()) {
span_err!(v.tcx.sess, e.span, E0013,
"paths in constants may only refer to items without \
type parameters");
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/middle/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::collections::HashMap;
use syntax::ast::*;
use syntax::ast_util::{walk_pat};
use syntax::codemap::{Span, DUMMY_SP};
use syntax::owned_slice::OwnedSlice;

pub type PatIdMap = HashMap<Ident, NodeId>;

Expand Down Expand Up @@ -133,8 +132,7 @@ pub fn def_to_path(tcx: &ty::ctxt, id: DefId) -> Path {
global: false,
segments: path.last().map(|elem| PathSegment {
identifier: Ident::new(elem.name()),
lifetimes: vec!(),
types: OwnedSlice::empty()
parameters: PathParameters::none(),
}).into_iter().collect(),
span: DUMMY_SP,
})
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use syntax::ast_map;
use syntax::ast_util::{is_local, local_def, PostExpansionMethod};
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::owned_slice::OwnedSlice;
use syntax::visit;
use syntax::visit::Visitor;

Expand Down Expand Up @@ -945,8 +944,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
debug!("privacy - ident item {}", id);
let seg = ast::PathSegment {
identifier: name,
lifetimes: Vec::new(),
types: OwnedSlice::empty(),
parameters: ast::PathParameters::none(),
};
let segs = vec![seg];
let path = ast::Path {
Expand Down
45 changes: 5 additions & 40 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use syntax::ast::{TupleVariantKind, Ty, TyBool, TyChar, TyClosure, TyF32};
use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt};
use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyProc, TyQPath};
use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
use syntax::ast::{TypeImplItem, UnboxedFnTyParamBound, UnnamedField};
use syntax::ast::{TypeImplItem, UnnamedField};
use syntax::ast::{Variant, ViewItem, ViewItemExternCrate};
use syntax::ast::{ViewItemUse, ViewPathGlob, ViewPathList, ViewPathSimple};
use syntax::ast::{Visibility};
Expand Down Expand Up @@ -4523,41 +4523,6 @@ impl<'a> Resolver<'a> {
TraitTyParamBound(ref tref) => {
self.resolve_trait_reference(id, tref, reference_type)
}
UnboxedFnTyParamBound(ref unboxed_function) => {
match self.resolve_path(unboxed_function.ref_id,
&unboxed_function.path,
TypeNS,
true) {
None => {
let path_str = self.path_names_to_string(
&unboxed_function.path);
self.resolve_error(unboxed_function.path.span,
format!("unresolved trait `{}`",
path_str).as_slice())
}
Some(def) => {
match def {
(DefTrait(_), _) => {
self.record_def(unboxed_function.ref_id, def);
}
_ => {
let msg =
format!("`{}` is not a trait",
self.path_names_to_string(
&unboxed_function.path));
self.resolve_error(unboxed_function.path.span,
msg.as_slice());
}
}
}
}

for argument in unboxed_function.decl.inputs.iter() {
self.resolve_type(&*argument.ty);
}

self.resolve_type(&*unboxed_function.decl.output);
}
RegionTyParamBound(..) => {}
}
}
Expand Down Expand Up @@ -4951,12 +4916,12 @@ impl<'a> Resolver<'a> {

if path.segments
.iter()
.any(|s| !s.lifetimes.is_empty()) {
.any(|s| s.parameters.has_lifetimes()) {
span_err!(self.session, path.span, E0157,
"lifetime parameters are not allowed on this type");
} else if path.segments
.iter()
.any(|s| s.types.len() > 0) {
.any(|s| !s.parameters.is_empty()) {
span_err!(self.session, path.span, E0153,
"type parameters are not allowed on this type");
}
Expand Down Expand Up @@ -5234,7 +5199,7 @@ impl<'a> Resolver<'a> {
// Check the types in the path pattern.
for ty in path.segments
.iter()
.flat_map(|s| s.types.iter()) {
.flat_map(|s| s.parameters.types().into_iter()) {
self.resolve_type(&**ty);
}
}
Expand Down Expand Up @@ -5340,7 +5305,7 @@ impl<'a> Resolver<'a> {
namespace: Namespace,
check_ribs: bool) -> Option<(Def, LastPrivate)> {
// First, resolve the types.
for ty in path.segments.iter().flat_map(|s| s.types.iter()) {
for ty in path.segments.iter().flat_map(|s| s.parameters.types().into_iter()) {
self.resolve_type(&**ty);
}

Expand Down
15 changes: 0 additions & 15 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ impl<'a> LifetimeContext<'a> {
ast::TraitTyParamBound(ref trait_ref) => {
self.visit_trait_ref(trait_ref);
}
ast::UnboxedFnTyParamBound(ref fn_decl) => {
self.visit_unboxed_fn_ty_param_bound(&**fn_decl);
}
ast::RegionTyParamBound(ref lifetime) => {
self.visit_lifetime_ref(lifetime);
}
Expand All @@ -226,18 +223,6 @@ impl<'a> LifetimeContext<'a> {
})
}

fn visit_unboxed_fn_ty_param_bound(&mut self,
bound: &ast::UnboxedFnBound) {
self.with(|scope, f| {
f(LateScope(bound.ref_id, &bound.lifetimes, scope))
}, |v| {
for argument in bound.decl.inputs.iter() {
v.visit_ty(&*argument.ty);
}
v.visit_ty(&*bound.decl.output);
})
}

/// Visits self by adding a scope and handling recursive walk over the contents with `walk`.
fn visit_fn_decl(&mut self,
n: ast::NodeId,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/save/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
ast::TraitTyParamBound(ref trait_ref) => {
trait_ref
}
ast::UnboxedFnTyParamBound(..) | ast::RegionTyParamBound(..) => {
ast::RegionTyParamBound(..) => {
continue;
}
};
Expand Down
6 changes: 1 addition & 5 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1836,11 +1836,7 @@ pub fn trans_closure(ccx: &CrateContext,
NotUnboxedClosure => monomorphized_arg_types,

// Tuple up closure argument types for the "rust-call" ABI.
IsUnboxedClosure => vec![if monomorphized_arg_types.is_empty() {
ty::mk_nil()
} else {
ty::mk_tup(ccx.tcx(), monomorphized_arg_types)
}]
IsUnboxedClosure => vec![ty::mk_tup_or_nil(ccx.tcx(), monomorphized_arg_types)]
};
for monomorphized_arg_type in monomorphized_arg_types.iter() {
debug!("trans_closure: monomorphized_arg_type: {}",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
}
ast::ExprPath(ref pth) => {
// Assert that there are no type parameters in this path.
assert!(pth.segments.iter().all(|seg| seg.types.is_empty()));
assert!(pth.segments.iter().all(|seg| !seg.parameters.has_types()));

let opt_def = cx.tcx().def_map.borrow().find_copy(&e.id);
match opt_def {
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,14 @@ pub fn mk_slice(cx: &ctxt, r: Region, tm: mt) -> t {

pub fn mk_tup(cx: &ctxt, ts: Vec<t>) -> t { mk_t(cx, ty_tup(ts)) }

pub fn mk_tup_or_nil(cx: &ctxt, ts: Vec<t>) -> t {
if ts.len() == 0 {
ty::mk_nil()
} else {
mk_t(cx, ty_tup(ts))
}
}

pub fn mk_closure(cx: &ctxt, fty: ClosureTy) -> t {
mk_t(cx, ty_closure(box fty))
}
Expand Down
Loading