Skip to content

Commit

Permalink
rustc: middle: rename ty::t to Ty and use it unqualified everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Nov 19, 2014
1 parent 21da750 commit 9706d8f
Show file tree
Hide file tree
Showing 79 changed files with 1,108 additions and 1,112 deletions.
7 changes: 4 additions & 3 deletions src/librustc/lint/builtin.rs
Expand Up @@ -28,9 +28,10 @@ use self::MethodContext::*;

use metadata::csearch;
use middle::def::*;
use middle::ty::{mod, Ty};
use middle::typeck::astconv::ast_ty_to_ty;
use middle::typeck::infer;
use middle::{typeck, ty, def, pat_util, stability};
use middle::typeck::{mod, infer};
use middle::{def, pat_util, stability};
use middle::const_eval::{eval_const_expr_partial, const_int, const_uint};
use util::ppaux::{ty_to_string};
use util::nodemap::{FnvHashMap, NodeSet};
Expand Down Expand Up @@ -473,7 +474,7 @@ declare_lint!(BOX_POINTERS, Allow,
pub struct BoxPointers;

impl BoxPointers {
fn check_heap_type(&self, cx: &Context, span: Span, ty: ty::t) {
fn check_heap_type(&self, cx: &Context, span: Span, ty: Ty) {
let mut n_uniq = 0i;
ty::fold_ty(cx.tcx, ty, |t| {
match ty::get(t).sty {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/lint/context.rs
Expand Up @@ -27,7 +27,7 @@ use self::TargetLint::*;

use middle::privacy::ExportedItems;
use middle::subst;
use middle::ty;
use middle::ty::{mod, Ty};
use middle::typeck::astconv::AstConv;
use middle::typeck::infer;
use session::{early_error, Session};
Expand Down Expand Up @@ -554,22 +554,22 @@ impl<'a, 'tcx> AstConv<'tcx> for Context<'a, 'tcx>{
ty::lookup_trait_def(self.tcx, id)
}

fn ty_infer(&self, _span: Span) -> ty::t {
fn ty_infer(&self, _span: Span) -> Ty {
infer::new_infer_ctxt(self.tcx).next_ty_var()
}

fn associated_types_of_trait_are_valid(&self, _: ty::t, _: ast::DefId)
fn associated_types_of_trait_are_valid(&self, _: Ty, _: ast::DefId)
-> bool {
// FIXME(pcwalton): This is wrong.
true
}

fn associated_type_binding(&self,
_: Span,
_: Option<ty::t>,
_: Option<Ty>,
trait_id: ast::DefId,
associated_type_id: ast::DefId)
-> ty::t {
-> Ty {
// FIXME(pcwalton): This is wrong.
let trait_def = self.get_trait_def(trait_id);
let index = ty::associated_type_parameter_index(self.tcx,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/metadata/decoder.rs
Expand Up @@ -29,7 +29,7 @@ use middle::lang_items;
use middle::resolve::{TraitItemKind, TypeTraitItemKind};
use middle::subst;
use middle::ty::{ImplContainer, TraitContainer};
use middle::ty;
use middle::ty::{mod, Ty};
use middle::typeck;
use middle::astencode::vtable_decoder_helpers;

Expand Down Expand Up @@ -224,7 +224,7 @@ fn variant_disr_val(d: rbml::Doc) -> Option<ty::Disr> {
})
}

fn doc_type(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::t {
fn doc_type(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> Ty {
let tp = reader::get_doc(doc, tag_items_data_item_type);
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|_, did| translate_def_id(cdata, did))
Expand All @@ -237,7 +237,7 @@ fn doc_method_fty(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::BareFnTy {
}

pub fn item_type(_item_id: ast::DefId, item: rbml::Doc,
tcx: &ty::ctxt, cdata: Cmd) -> ty::t {
tcx: &ty::ctxt, cdata: Cmd) -> Ty {
doc_type(item, tcx, cdata)
}

Expand Down
8 changes: 4 additions & 4 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -22,7 +22,7 @@ use metadata::cstore;
use metadata::decoder;
use metadata::tyencode;
use middle::ty::{lookup_item_type};
use middle::ty;
use middle::ty::{mod, Ty};
use middle::stability;
use middle;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
Expand Down Expand Up @@ -172,7 +172,7 @@ pub fn write_closure_type(ecx: &EncodeContext,

pub fn write_type(ecx: &EncodeContext,
rbml_w: &mut Encoder,
typ: ty::t) {
typ: Ty) {
let ty_str_ctxt = &tyencode::ctxt {
diag: ecx.diag,
ds: def_to_string,
Expand Down Expand Up @@ -223,7 +223,7 @@ fn encode_bounds(rbml_w: &mut Encoder,

fn encode_type(ecx: &EncodeContext,
rbml_w: &mut Encoder,
typ: ty::t) {
typ: Ty) {
rbml_w.start_tag(tag_items_data_item_type);
write_type(ecx, rbml_w, typ);
rbml_w.end_tag();
Expand Down Expand Up @@ -2167,7 +2167,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
}

// Get the encoded string for a type
pub fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> String {
pub fn encoded_ty(tcx: &ty::ctxt, t: Ty) -> String {
let mut wr = SeekableMemWriter::new();
tyencode::enc_ty(&mut wr, &tyencode::ctxt {
diag: tcx.sess.diagnostic(),
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/metadata/tydecode.rs
Expand Up @@ -20,7 +20,7 @@ pub use self::DefIdSource::*;

use middle::subst;
use middle::subst::VecPerParamSpace;
use middle::ty;
use middle::ty::{mod, Ty};

use std::rc::Rc;
use std::str;
Expand All @@ -29,7 +29,7 @@ use syntax::abi;
use syntax::ast;
use syntax::parse::token;

// Compact string representation for ty::t values. API ty_str &
// Compact string representation for Ty values. API ty_str &
// parse_from_str. Extra parameters are for converting to/from def_ids in the
// data buffer. Whatever format you choose should not contain pipe characters.

Expand Down Expand Up @@ -150,7 +150,7 @@ pub fn parse_ty_closure_data(data: &[u8],
}

pub fn parse_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
conv: conv_did) -> ty::t {
conv: conv_did) -> Ty {
debug!("parse_ty_data {}", data_log_string(data, pos));
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
parse_ty(&mut st, conv)
Expand Down Expand Up @@ -359,7 +359,7 @@ fn parse_trait_ref(st: &mut PState, conv: conv_did) -> ty::TraitRef {
ty::TraitRef {def_id: def, substs: substs}
}

fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
fn parse_ty(st: &mut PState, conv: conv_did) -> Ty {
match next(st) {
'b' => return ty::mk_bool(),
'i' => return ty::mk_int(),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/metadata/tyencode.rs
Expand Up @@ -18,7 +18,7 @@ use std::cell::RefCell;
use middle::subst;
use middle::subst::VecPerParamSpace;
use middle::ty::ParamTy;
use middle::ty;
use middle::ty::{mod, Ty};
use util::nodemap::FnvHashMap;

use syntax::abi::Abi;
Expand Down Expand Up @@ -46,9 +46,9 @@ pub struct ty_abbrev {
s: String
}

pub type abbrev_map = RefCell<FnvHashMap<ty::t, ty_abbrev>>;
pub type abbrev_map = RefCell<FnvHashMap<Ty, ty_abbrev>>;

pub fn enc_ty(w: &mut SeekableMemWriter, cx: &ctxt, t: ty::t) {
pub fn enc_ty(w: &mut SeekableMemWriter, cx: &ctxt, t: Ty) {
match cx.abbrevs.borrow_mut().get(&t) {
Some(a) => { w.write(a.s.as_bytes()); return; }
None => {}
Expand Down
28 changes: 14 additions & 14 deletions src/librustc/middle/astencode.rs
Expand Up @@ -26,8 +26,8 @@ use metadata::tyencode;
use middle::mem_categorization::Typer;
use middle::subst;
use middle::subst::VecPerParamSpace;
use middle::typeck::{MethodCall, MethodCallee, MethodOrigin};
use middle::{ty, typeck};
use middle::typeck::{mod, MethodCall, MethodCallee, MethodOrigin};
use middle::ty::{mod, Ty};
use util::ppaux::ty_to_string;

use syntax::{ast, ast_map, ast_util, codemap, fold};
Expand Down Expand Up @@ -831,8 +831,8 @@ trait rbml_writer_helpers {
fn emit_method_origin(&mut self,
ecx: &e::EncodeContext,
method_origin: &typeck::MethodOrigin);
fn emit_ty(&mut self, ecx: &e::EncodeContext, ty: ty::t);
fn emit_tys(&mut self, ecx: &e::EncodeContext, tys: &[ty::t]);
fn emit_ty(&mut self, ecx: &e::EncodeContext, ty: Ty);
fn emit_tys(&mut self, ecx: &e::EncodeContext, tys: &[Ty]);
fn emit_type_param_def(&mut self,
ecx: &e::EncodeContext,
type_param_def: &ty::TypeParameterDef);
Expand Down Expand Up @@ -915,11 +915,11 @@ impl<'a> rbml_writer_helpers for Encoder<'a> {
});
}

fn emit_ty(&mut self, ecx: &e::EncodeContext, ty: ty::t) {
fn emit_ty(&mut self, ecx: &e::EncodeContext, ty: Ty) {
self.emit_opaque(|this| Ok(e::write_type(ecx, this, ty)));
}

fn emit_tys(&mut self, ecx: &e::EncodeContext, tys: &[ty::t]) {
fn emit_tys(&mut self, ecx: &e::EncodeContext, tys: &[Ty]) {
self.emit_from_vec(tys, |this, ty| Ok(this.emit_ty(ecx, *ty)));
}

Expand Down Expand Up @@ -1327,8 +1327,8 @@ impl<'a> doc_decoder_helpers for rbml::Doc<'a> {

trait rbml_decoder_decoder_helpers {
fn read_method_origin(&mut self, dcx: &DecodeContext) -> typeck::MethodOrigin;
fn read_ty(&mut self, dcx: &DecodeContext) -> ty::t;
fn read_tys(&mut self, dcx: &DecodeContext) -> Vec<ty::t>;
fn read_ty(&mut self, dcx: &DecodeContext) -> Ty;
fn read_tys(&mut self, dcx: &DecodeContext) -> Vec<Ty>;
fn read_trait_ref(&mut self, dcx: &DecodeContext) -> Rc<ty::TraitRef>;
fn read_type_param_def(&mut self, dcx: &DecodeContext)
-> ty::TypeParameterDef;
Expand All @@ -1351,18 +1351,18 @@ trait rbml_decoder_decoder_helpers {
// Versions of the type reading functions that don't need the full
// DecodeContext.
fn read_ty_nodcx(&mut self,
tcx: &ty::ctxt, cdata: &cstore::crate_metadata) -> ty::t;
tcx: &ty::ctxt, cdata: &cstore::crate_metadata) -> Ty;
fn read_tys_nodcx(&mut self,
tcx: &ty::ctxt,
cdata: &cstore::crate_metadata) -> Vec<ty::t>;
cdata: &cstore::crate_metadata) -> Vec<Ty>;
fn read_substs_nodcx(&mut self, tcx: &ty::ctxt,
cdata: &cstore::crate_metadata)
-> subst::Substs;
}

impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
fn read_ty_nodcx(&mut self,
tcx: &ty::ctxt, cdata: &cstore::crate_metadata) -> ty::t {
tcx: &ty::ctxt, cdata: &cstore::crate_metadata) -> Ty {
self.read_opaque(|_, doc| {
Ok(tydecode::parse_ty_data(
doc.data,
Expand All @@ -1375,7 +1375,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {

fn read_tys_nodcx(&mut self,
tcx: &ty::ctxt,
cdata: &cstore::crate_metadata) -> Vec<ty::t> {
cdata: &cstore::crate_metadata) -> Vec<Ty> {
self.read_to_vec(|this| Ok(this.read_ty_nodcx(tcx, cdata)) )
.unwrap()
.into_iter()
Expand Down Expand Up @@ -1468,7 +1468,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
}


fn read_ty(&mut self, dcx: &DecodeContext) -> ty::t {
fn read_ty(&mut self, dcx: &DecodeContext) -> Ty {
// Note: regions types embed local node ids. In principle, we
// should translate these node ids into the new decode
// context. However, we do not bother, because region types
Expand Down Expand Up @@ -1496,7 +1496,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
}
}

fn read_tys(&mut self, dcx: &DecodeContext) -> Vec<ty::t> {
fn read_tys(&mut self, dcx: &DecodeContext) -> Vec<Ty> {
self.read_to_vec(|this| Ok(this.read_ty(dcx))).unwrap().into_iter().collect()
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/mod.rs
Expand Up @@ -24,7 +24,7 @@ use middle::dataflow::BitwiseOperator;
use middle::dataflow::DataFlowOperator;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use middle::ty::{mod, Ty};
use util::ppaux::{note_and_explain_region, Repr, UserString};

use std::rc::Rc;
Expand Down Expand Up @@ -586,7 +586,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
}

fn move_suggestion(tcx: &ty::ctxt, ty: ty::t, default_msgs: (&'static str, &'static str))
fn move_suggestion(tcx: &ty::ctxt, ty: Ty, default_msgs: (&'static str, &'static str))
-> (&'static str, &'static str) {
match ty::get(ty).sty {
ty::ty_closure(box ty::ClosureTy {
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/check_match.rs
Expand Up @@ -21,7 +21,7 @@ use middle::expr_use_visitor::{WriteAndRead};
use middle::mem_categorization::cmt;
use middle::pat_util::*;
use middle::ty::*;
use middle::ty;
use middle::ty::{mod, Ty};
use std::fmt;
use std::iter::AdditiveIterator;
use std::iter::range_inclusive;
Expand Down Expand Up @@ -403,7 +403,7 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
/// left_ty: struct X { a: (bool, &'static str), b: uint}
/// pats: [(false, "foo"), 42] => X { a: (false, "foo"), b: 42 }
fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
pats: Vec<&Pat>, left_ty: ty::t) -> P<Pat> {
pats: Vec<&Pat>, left_ty: Ty) -> P<Pat> {
let pats_len = pats.len();
let mut pats = pats.into_iter().map(|p| P((*p).clone()));
let pat = match ty::get(left_ty).sty {
Expand Down Expand Up @@ -483,7 +483,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}

fn missing_constructor(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix,
left_ty: ty::t, max_slice_length: uint) -> Option<Constructor> {
left_ty: Ty, max_slice_length: uint) -> Option<Constructor> {
let used_constructors: Vec<Constructor> = rows.iter()
.flat_map(|row| pat_constructors(cx, row[0], left_ty, max_slice_length).into_iter())
.collect();
Expand All @@ -496,7 +496,7 @@ fn missing_constructor(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix,
/// values of type `left_ty`. For vectors, this would normally be an infinite set
/// but is instead bounded by the maximum fixed length of slice patterns in
/// the column of patterns being analyzed.
fn all_constructors(cx: &MatchCheckCtxt, left_ty: ty::t,
fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
max_slice_length: uint) -> Vec<Constructor> {
match ty::get(left_ty).sty {
ty::ty_bool =>
Expand Down Expand Up @@ -616,7 +616,7 @@ fn is_useful(cx: &MatchCheckCtxt,
}

fn is_useful_specialized(cx: &MatchCheckCtxt, &Matrix(ref m): &Matrix,
v: &[&Pat], ctor: Constructor, lty: ty::t,
v: &[&Pat], ctor: Constructor, lty: Ty,
witness: WitnessPreference) -> Usefulness {
let arity = constructor_arity(cx, &ctor, lty);
let matrix = Matrix(m.iter().filter_map(|r| {
Expand All @@ -638,7 +638,7 @@ fn is_useful_specialized(cx: &MatchCheckCtxt, &Matrix(ref m): &Matrix,
/// On the other hand, a wild pattern and an identifier pattern cannot be
/// specialized in any way.
fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
left_ty: ty::t, max_slice_length: uint) -> Vec<Constructor> {
left_ty: Ty, max_slice_length: uint) -> Vec<Constructor> {
let pat = raw_pat(p);
match pat.node {
ast::PatIdent(..) =>
Expand Down Expand Up @@ -695,7 +695,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
///
/// For instance, a tuple pattern (_, 42u, Some([])) has the arity of 3.
/// A struct pattern's arity is the number of fields it contains, etc.
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) -> uint {
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> uint {
match ty::get(ty).sty {
ty::ty_tup(ref fs) => fs.len(),
ty::ty_uniq(_) => 1u,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/const_eval.rs
Expand Up @@ -18,7 +18,7 @@ use metadata::csearch;
use middle::astencode;
use middle::def;
use middle::pat_util::def_to_path;
use middle::ty;
use middle::ty::{mod, Ty};
use middle::typeck::astconv;
use middle::typeck::check;
use util::nodemap::{DefIdMap};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/effect.rs
Expand Up @@ -13,7 +13,7 @@
use self::UnsafeContext::*;

use middle::def;
use middle::ty;
use middle::ty::{mod, Ty};
use middle::typeck::MethodCall;
use util::ppaux;

Expand All @@ -30,7 +30,7 @@ enum UnsafeContext {
UnsafeBlock(ast::NodeId),
}

fn type_is_unsafe_function(ty: ty::t) -> bool {
fn type_is_unsafe_function(ty: Ty) -> bool {
match ty::get(ty).sty {
ty::ty_bare_fn(ref f) => f.fn_style == ast::UnsafeFn,
ty::ty_closure(ref f) => f.fn_style == ast::UnsafeFn,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -24,7 +24,7 @@ use middle::mem_categorization as mc;
use middle::def;
use middle::mem_categorization::Typer;
use middle::pat_util;
use middle::ty;
use middle::ty::{mod, Ty};
use middle::typeck::{MethodCall, MethodObject, MethodTraitObject};
use middle::typeck::{MethodOrigin, MethodParam, MethodTypeParam};
use middle::typeck::{MethodStatic, MethodStaticUnboxedClosure};
Expand Down Expand Up @@ -999,7 +999,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
}
}

fn copy_or_move(tcx: &ty::ctxt, ty: ty::t, move_reason: MoveReason) -> ConsumeMode {
fn copy_or_move(tcx: &ty::ctxt, ty: Ty, move_reason: MoveReason) -> ConsumeMode {
if ty::type_moves_by_default(tcx, ty) { Move(move_reason) } else { Copy }
}

0 comments on commit 9706d8f

Please sign in to comment.