rust_typeck: remove unnecessary typing of &[] as &'static [T; 0].

This commit is contained in:
Eduard Burtescu 2015-01-29 13:50:19 +02:00
parent bd9c67e181
commit 5918d33fef
3 changed files with 2 additions and 24 deletions

View file

@ -1435,7 +1435,6 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
infer::MiscVariable(_) => "".to_string(),
infer::PatternRegion(_) => " for pattern".to_string(),
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
infer::AddrOfSlice(_) => " for slice expression".to_string(),
infer::Autoref(_) => " for autoref".to_string(),
infer::Coercion(_) => " for automatic coercion".to_string(),
infer::LateBoundRegion(_, br, infer::FnCall) => {

View file

@ -247,9 +247,6 @@ pub enum RegionVariableOrigin<'tcx> {
// Regions created by `&` operator
AddrOfRegion(Span),
// Regions created by `&[...]` literal
AddrOfSlice(Span),
// Regions created as part of an autoref of a method receiver
Autoref(Span),
@ -1273,7 +1270,6 @@ impl<'tcx> RegionVariableOrigin<'tcx> {
MiscVariable(a) => a,
PatternRegion(a) => a,
AddrOfRegion(a) => a,
AddrOfSlice(a) => a,
Autoref(a) => a,
Coercion(ref a) => a.span(),
EarlyBoundRegion(a, _) => a,
@ -1296,7 +1292,6 @@ impl<'tcx> Repr<'tcx> for RegionVariableOrigin<'tcx> {
AddrOfRegion(a) => {
format!("AddrOfRegion({})", a.repr(tcx))
}
AddrOfSlice(a) => format!("AddrOfSlice({})", a.repr(tcx)),
Autoref(a) => format!("Autoref({})", a.repr(tcx)),
Coercion(ref a) => format!("Coercion({})", a.repr(tcx)),
EarlyBoundRegion(a, b) => {

View file

@ -3586,24 +3586,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
// Finally, borrowck is charged with guaranteeing that the
// value whose address was taken can actually be made to live
// as long as it needs to live.
match oprnd.node {
// String literals are already, implicitly converted to slices.
//ast::ExprLit(lit) if ast_util::lit_is_str(lit) => fcx.expr_ty(oprnd),
// Empty slices live in static memory.
ast::ExprVec(ref elements) if elements.len() == 0 => {
// Note: we do not assign a lifetime of
// static. This is because the resulting type
// `&'static [T]` would require that T outlives
// `'static`!
let region = fcx.infcx().next_region_var(
infer::AddrOfSlice(expr.span));
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
}
_ => {
let region = fcx.infcx().next_region_var(infer::AddrOfRegion(expr.span));
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
}
}
let region = fcx.infcx().next_region_var(infer::AddrOfRegion(expr.span));
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
};
fcx.write_ty(id, oprnd_t);
}