Skip to content

Commit 5918d33

Browse files
committed
rust_typeck: remove unnecessary typing of &[] as &'static [T; 0].
1 parent bd9c67e commit 5918d33

File tree

3 files changed

+2
-24
lines changed

3 files changed

+2
-24
lines changed

src/librustc/middle/infer/error_reporting.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,6 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
14351435
infer::MiscVariable(_) => "".to_string(),
14361436
infer::PatternRegion(_) => " for pattern".to_string(),
14371437
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
1438-
infer::AddrOfSlice(_) => " for slice expression".to_string(),
14391438
infer::Autoref(_) => " for autoref".to_string(),
14401439
infer::Coercion(_) => " for automatic coercion".to_string(),
14411440
infer::LateBoundRegion(_, br, infer::FnCall) => {

src/librustc/middle/infer/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ pub enum RegionVariableOrigin<'tcx> {
247247
// Regions created by `&` operator
248248
AddrOfRegion(Span),
249249

250-
// Regions created by `&[...]` literal
251-
AddrOfSlice(Span),
252-
253250
// Regions created as part of an autoref of a method receiver
254251
Autoref(Span),
255252

@@ -1273,7 +1270,6 @@ impl<'tcx> RegionVariableOrigin<'tcx> {
12731270
MiscVariable(a) => a,
12741271
PatternRegion(a) => a,
12751272
AddrOfRegion(a) => a,
1276-
AddrOfSlice(a) => a,
12771273
Autoref(a) => a,
12781274
Coercion(ref a) => a.span(),
12791275
EarlyBoundRegion(a, _) => a,
@@ -1296,7 +1292,6 @@ impl<'tcx> Repr<'tcx> for RegionVariableOrigin<'tcx> {
12961292
AddrOfRegion(a) => {
12971293
format!("AddrOfRegion({})", a.repr(tcx))
12981294
}
1299-
AddrOfSlice(a) => format!("AddrOfSlice({})", a.repr(tcx)),
13001295
Autoref(a) => format!("Autoref({})", a.repr(tcx)),
13011296
Coercion(ref a) => format!("Coercion({})", a.repr(tcx)),
13021297
EarlyBoundRegion(a, b) => {

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,24 +3586,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
35863586
// Finally, borrowck is charged with guaranteeing that the
35873587
// value whose address was taken can actually be made to live
35883588
// as long as it needs to live.
3589-
match oprnd.node {
3590-
// String literals are already, implicitly converted to slices.
3591-
//ast::ExprLit(lit) if ast_util::lit_is_str(lit) => fcx.expr_ty(oprnd),
3592-
// Empty slices live in static memory.
3593-
ast::ExprVec(ref elements) if elements.len() == 0 => {
3594-
// Note: we do not assign a lifetime of
3595-
// static. This is because the resulting type
3596-
// `&'static [T]` would require that T outlives
3597-
// `'static`!
3598-
let region = fcx.infcx().next_region_var(
3599-
infer::AddrOfSlice(expr.span));
3600-
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
3601-
}
3602-
_ => {
3603-
let region = fcx.infcx().next_region_var(infer::AddrOfRegion(expr.span));
3604-
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
3605-
}
3606-
}
3589+
let region = fcx.infcx().next_region_var(infer::AddrOfRegion(expr.span));
3590+
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
36073591
};
36083592
fcx.write_ty(id, oprnd_t);
36093593
}

0 commit comments

Comments
 (0)