Minor fixups based on @eddyb's feedback
Mainly, remove mk_empty() method and replace with tcx.types.empty
This commit is contained in:
parent
5096a8c5c0
commit
f0a8b6d43f
14 changed files with 30 additions and 33 deletions
|
|
@ -701,7 +701,7 @@ mod impls {
|
|||
|
||||
// Note: This macro is a temporary hack that can be remove once we are building with a compiler
|
||||
// that supports `!`
|
||||
macro_rules! argh {
|
||||
macro_rules! not_stage0 {
|
||||
() => {
|
||||
#[unstable(feature = "bang_type", issue = "35121")]
|
||||
impl PartialEq for ! {
|
||||
|
|
@ -730,7 +730,7 @@ mod impls {
|
|||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
argh!();
|
||||
not_stage0!();
|
||||
|
||||
// & pointers
|
||||
|
||||
|
|
|
|||
|
|
@ -1365,7 +1365,7 @@ fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperEx
|
|||
|
||||
// Note: This macro is a temporary hack that can be remove once we are building with a compiler
|
||||
// that supports `!`
|
||||
macro_rules! argh {
|
||||
macro_rules! not_stage0 {
|
||||
() => {
|
||||
#[unstable(feature = "bang_type", issue = "35121")]
|
||||
impl Debug for ! {
|
||||
|
|
@ -1384,7 +1384,7 @@ macro_rules! argh {
|
|||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
argh!();
|
||||
not_stage0!();
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl Debug for bool {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@
|
|||
#![feature(staged_api)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(question_mark)]
|
||||
|
||||
// NOTE: remove the cfg_attr next snapshot
|
||||
#![cfg_attr(not(stage0), feature(bang_type))]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ use self::VarKind::*;
|
|||
use dep_graph::DepNode;
|
||||
use hir::def::*;
|
||||
use hir::pat_util;
|
||||
use ty::{self, TyCtxt, ParameterEnvironment};
|
||||
use ty::{self, Ty, TyCtxt, ParameterEnvironment};
|
||||
use traits::{self, Reveal};
|
||||
use ty::subst::Subst;
|
||||
use lint;
|
||||
|
|
@ -1454,7 +1454,7 @@ fn check_fn(_v: &Liveness,
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
fn fn_ret(&self, id: NodeId) -> ty::Binder<ty::Ty<'tcx>> {
|
||||
fn fn_ret(&self, id: NodeId) -> ty::Binder<Ty<'tcx>> {
|
||||
let fn_ty = self.ir.tcx.node_id_to_type(id);
|
||||
match fn_ty.sty {
|
||||
ty::TyClosure(closure_def_id, substs) =>
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ pub struct AutoDerefRef<'tcx> {
|
|||
impl<'tcx> AutoAdjustment<'tcx> {
|
||||
pub fn is_identity(&self) -> bool {
|
||||
match *self {
|
||||
AdjustEmptyToAny(ref ty) => match ty.sty {
|
||||
AdjustEmptyToAny(ty) => match ty.sty {
|
||||
TypeVariants::TyEmpty => true,
|
||||
_ => false,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1258,10 +1258,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
self.mk_ty(TySlice(ty))
|
||||
}
|
||||
|
||||
pub fn mk_empty(&self) -> Ty<'tcx> {
|
||||
self.mk_ty(TyEmpty)
|
||||
}
|
||||
|
||||
pub fn mk_tup(self, ts: Vec<Ty<'tcx>>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyTuple(self.mk_type_list(ts)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
// unreachable block. Don't bother to terminate it and create a new one.
|
||||
if is_call {
|
||||
block.unit()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
|
||||
let end_block = this.cfg.start_new_block();
|
||||
end_block.unit()
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ macro_rules! unpack {
|
|||
pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
fn_id: ast::NodeId,
|
||||
arguments: A,
|
||||
return_ty: ty::Ty<'gcx>,
|
||||
return_ty: Ty<'gcx>,
|
||||
ast_block: &'gcx hir::Block)
|
||||
-> (Mir<'tcx>, ScopeAuxiliaryVec)
|
||||
where A: Iterator<Item=(Ty<'gcx>, Option<&'gcx hir::Pat>)>
|
||||
|
|
@ -287,7 +287,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
fn finish(self,
|
||||
upvar_decls: Vec<UpvarDecl>,
|
||||
arg_decls: IndexVec<Arg, ArgDecl<'tcx>>,
|
||||
return_ty: ty::Ty<'tcx>)
|
||||
return_ty: Ty<'tcx>)
|
||||
-> (Mir<'tcx>, ScopeAuxiliaryVec) {
|
||||
for (index, block) in self.cfg.basic_blocks.iter().enumerate() {
|
||||
if block.terminator.is_none() {
|
||||
|
|
@ -309,7 +309,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn args_and_body<A>(&mut self,
|
||||
mut block: BasicBlock,
|
||||
return_ty: ty::Ty<'tcx>,
|
||||
return_ty: Ty<'tcx>,
|
||||
arguments: A,
|
||||
argument_extent: CodeExtent,
|
||||
ast_block: &'gcx hir::Block)
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
|
|||
abi: Abi::C,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![tcx.mk_mut_ptr(tcx.types.u8)],
|
||||
output: tcx.mk_empty(),
|
||||
output: tcx.types.empty,
|
||||
variadic: false
|
||||
}),
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -1221,7 +1221,7 @@ fn trans_gnu_try<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
fn gen_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
|
||||
name: &str,
|
||||
inputs: Vec<Ty<'tcx>>,
|
||||
output: ty::Ty<'tcx>,
|
||||
output: Ty<'tcx>,
|
||||
trans: &mut for<'b> FnMut(Block<'b, 'tcx>))
|
||||
-> ValueRef {
|
||||
let ccx = fcx.ccx;
|
||||
|
|
|
|||
|
|
@ -1701,7 +1701,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
|||
tcx.mk_ref(tcx.mk_region(r), ty::TypeAndMut {ty: t, mutbl: mt.mutbl})
|
||||
}
|
||||
hir::TyEmpty => {
|
||||
tcx.mk_empty()
|
||||
tcx.types.empty
|
||||
},
|
||||
hir::TyTup(ref fields) => {
|
||||
let flds = fields.iter()
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
it: &hir::ForeignItem,
|
||||
n_tps: usize,
|
||||
abi: Abi,
|
||||
inputs: Vec<ty::Ty<'tcx>>,
|
||||
output: ty::Ty<'tcx>) {
|
||||
inputs: Vec<Ty<'tcx>>,
|
||||
output: Ty<'tcx>) {
|
||||
let tcx = ccx.tcx;
|
||||
let def_id = tcx.map.local_def_id(it.id);
|
||||
let i_ty = tcx.lookup_item_type(def_id);
|
||||
|
|
@ -106,7 +106,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
|
|||
};
|
||||
(n_tps, inputs, output)
|
||||
} else if &name[..] == "abort" || &name[..] == "unreachable" {
|
||||
(0, Vec::new(), tcx.mk_empty())
|
||||
(0, Vec::new(), tcx.types.empty)
|
||||
} else {
|
||||
let (n_tps, inputs, output) = match &name[..] {
|
||||
"breakpoint" => (0, Vec::new(), tcx.mk_nil()),
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
|||
// expects the types within the function to be consistent.
|
||||
err_count_on_creation: usize,
|
||||
|
||||
ret_ty: ty::Ty<'tcx>,
|
||||
ret_ty: Ty<'tcx>,
|
||||
|
||||
ps: RefCell<UnsafetyState>,
|
||||
|
||||
|
|
@ -1457,7 +1457,7 @@ enum TupleArgumentsFlag {
|
|||
|
||||
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn new(inh: &'a Inherited<'a, 'gcx, 'tcx>,
|
||||
rty: ty::Ty<'tcx>,
|
||||
rty: Ty<'tcx>,
|
||||
body_id: ast::NodeId)
|
||||
-> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
FnCtxt {
|
||||
|
|
@ -1733,7 +1733,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn write_empty(&self, node_id: ast::NodeId) {
|
||||
self.write_ty_expr(node_id, self.tcx.mk_empty());
|
||||
self.write_ty_expr(node_id, self.tcx.types.empty);
|
||||
}
|
||||
|
||||
pub fn write_error(&self, node_id: ast::NodeId) {
|
||||
|
|
@ -1977,7 +1977,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
if self.type_var_diverges(resolved) {
|
||||
debug!("default_type_parameters: defaulting `{:?}` to `!` because it diverges",
|
||||
resolved);
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.mk_empty());
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty);
|
||||
} else {
|
||||
match self.type_is_unconstrained_numeric(resolved) {
|
||||
UnconstrainedInt => {
|
||||
|
|
@ -2051,7 +2051,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
for ty in &unsolved_variables {
|
||||
let resolved = self.resolve_type_vars_if_possible(ty);
|
||||
if self.type_var_diverges(resolved) {
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.mk_empty());
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty);
|
||||
} else {
|
||||
match self.type_is_unconstrained_numeric(resolved) {
|
||||
UnconstrainedInt | UnconstrainedFloat => {
|
||||
|
|
@ -2109,7 +2109,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let _ = self.commit_if_ok(|_: &infer::CombinedSnapshot| {
|
||||
for ty in &unbound_tyvars {
|
||||
if self.type_var_diverges(ty) {
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.mk_empty());
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty);
|
||||
} else {
|
||||
match self.type_is_unconstrained_numeric(ty) {
|
||||
UnconstrainedInt => {
|
||||
|
|
@ -2205,7 +2205,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
// reporting for more then one conflict.
|
||||
for ty in &unbound_tyvars {
|
||||
if self.type_var_diverges(ty) {
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.mk_empty());
|
||||
self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty);
|
||||
} else {
|
||||
match self.type_is_unconstrained_numeric(ty) {
|
||||
UnconstrainedInt => {
|
||||
|
|
@ -2409,7 +2409,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
args_no_rcvr: &'gcx [P<hir::Expr>],
|
||||
tuple_arguments: TupleArgumentsFlag,
|
||||
expected: Expectation<'tcx>)
|
||||
-> ty::Ty<'tcx> {
|
||||
-> Ty<'tcx> {
|
||||
if method_fn_ty.references_error() {
|
||||
let err_inputs = self.err_args(args_no_rcvr.len());
|
||||
|
||||
|
|
@ -2680,7 +2680,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn write_call(&self,
|
||||
call_expr: &hir::Expr,
|
||||
output: ty::Ty<'tcx>) {
|
||||
output: Ty<'tcx>) {
|
||||
self.write_ty_expr(call_expr.id, output);
|
||||
}
|
||||
|
||||
|
|
@ -2804,7 +2804,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
fn expected_types_for_fn_args(&self,
|
||||
call_span: Span,
|
||||
expected_ret: Expectation<'tcx>,
|
||||
formal_ret: ty::Ty<'tcx>,
|
||||
formal_ret: Ty<'tcx>,
|
||||
formal_args: &[Ty<'tcx>])
|
||||
-> Vec<Ty<'tcx>> {
|
||||
let expected_args = expected_ret.only_has_type(self).and_then(|ret_ty| {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl<'a, 'gcx, 'tcx> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
|
|||
let id = self.id;
|
||||
let span = self.span;
|
||||
self.inherited.enter(|inh| {
|
||||
let fcx = FnCtxt::new(&inh, inh.ccx.tcx.mk_empty(), id);
|
||||
let fcx = FnCtxt::new(&inh, inh.ccx.tcx.types.empty, id);
|
||||
let wf_tys = f(&fcx, &mut CheckTypeWellFormedVisitor {
|
||||
ccx: fcx.ccx,
|
||||
code: code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue