Skip to content

Commit d6f7035

Browse files
committed
rustc_back: remove slice module in favor of std::slice::from_ref.
1 parent fdfbcf8 commit d6f7035

File tree

17 files changed

+28
-54
lines changed

17 files changed

+28
-54
lines changed

src/Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#![feature(const_fn)]
4747
#![feature(core_intrinsics)]
4848
#![feature(drain_filter)]
49+
#![feature(from_ref)]
4950
#![feature(i128)]
5051
#![feature(i128_type)]
5152
#![feature(inclusive_range)]

src/librustc/lint/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
use self::TargetLint::*;
2828

29-
use rustc_back::slice;
29+
use std::slice;
3030
use lint::{EarlyLintPassObject, LateLintPassObject};
3131
use lint::{Level, Lint, LintId, LintPass, LintBuffer};
3232
use lint::levels::{LintLevelSets, LintLevelsBuilder};
@@ -308,7 +308,7 @@ impl LintStore {
308308
Some(ids) => CheckLintNameResult::Ok(&ids.0),
309309
}
310310
}
311-
Some(&Id(ref id)) => CheckLintNameResult::Ok(slice::ref_slice(id)),
311+
Some(&Id(ref id)) => CheckLintNameResult::Ok(slice::from_ref(id)),
312312
}
313313
}
314314
}

src/librustc/middle/resolve_lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax_pos::Span;
3131
use errors::DiagnosticBuilder;
3232
use util::common::ErrorReported;
3333
use util::nodemap::{NodeMap, NodeSet, FxHashSet, FxHashMap, DefIdMap};
34-
use rustc_back::slice;
34+
use std::slice;
3535

3636
use hir;
3737
use hir::intravisit::{self, Visitor, NestedVisitorMap};
@@ -530,7 +530,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
530530

531531
fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
532532
if lifetime_ref.is_elided() {
533-
self.resolve_elided_lifetimes(slice::ref_slice(lifetime_ref));
533+
self.resolve_elided_lifetimes(slice::from_ref(lifetime_ref));
534534
return;
535535
}
536536
if lifetime_ref.is_static() {

src/librustc/mir/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use ty::subst::{Subst, Substs};
2525
use ty::{self, AdtDef, ClosureSubsts, Region, Ty, TyCtxt, GeneratorInterior};
2626
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
2727
use util::ppaux;
28-
use rustc_back::slice;
28+
use std::slice;
2929
use hir::{self, InlineAsm};
3030
use std::ascii;
3131
use std::borrow::{Cow};
@@ -754,28 +754,28 @@ impl<'tcx> TerminatorKind<'tcx> {
754754
pub fn successors(&self) -> Cow<[BasicBlock]> {
755755
use self::TerminatorKind::*;
756756
match *self {
757-
Goto { target: ref b } => slice::ref_slice(b).into_cow(),
757+
Goto { target: ref b } => slice::from_ref(b).into_cow(),
758758
SwitchInt { targets: ref b, .. } => b[..].into_cow(),
759759
Resume | GeneratorDrop => (&[]).into_cow(),
760760
Return => (&[]).into_cow(),
761761
Unreachable => (&[]).into_cow(),
762762
Call { destination: Some((_, t)), cleanup: Some(c), .. } => vec![t, c].into_cow(),
763763
Call { destination: Some((_, ref t)), cleanup: None, .. } =>
764-
slice::ref_slice(t).into_cow(),
765-
Call { destination: None, cleanup: Some(ref c), .. } => slice::ref_slice(c).into_cow(),
764+
slice::from_ref(t).into_cow(),
765+
Call { destination: None, cleanup: Some(ref c), .. } => slice::from_ref(c).into_cow(),
766766
Call { destination: None, cleanup: None, .. } => (&[]).into_cow(),
767767
Yield { resume: t, drop: Some(c), .. } => vec![t, c].into_cow(),
768-
Yield { resume: ref t, drop: None, .. } => slice::ref_slice(t).into_cow(),
768+
Yield { resume: ref t, drop: None, .. } => slice::from_ref(t).into_cow(),
769769
DropAndReplace { target, unwind: Some(unwind), .. } |
770770
Drop { target, unwind: Some(unwind), .. } => {
771771
vec![target, unwind].into_cow()
772772
}
773773
DropAndReplace { ref target, unwind: None, .. } |
774774
Drop { ref target, unwind: None, .. } => {
775-
slice::ref_slice(target).into_cow()
775+
slice::from_ref(target).into_cow()
776776
}
777777
Assert { target, cleanup: Some(unwind), .. } => vec![target, unwind].into_cow(),
778-
Assert { ref target, .. } => slice::ref_slice(target).into_cow(),
778+
Assert { ref target, .. } => slice::from_ref(target).into_cow(),
779779
FalseEdges { ref real_target, ref imaginary_targets } => {
780780
let mut s = vec![*real_target];
781781
s.extend_from_slice(imaginary_targets);

src/librustc_back/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ extern crate serialize as rustc_serialize; // used by deriving
4040

4141
pub mod tempdir;
4242
pub mod target;
43-
pub mod slice;
4443
pub mod dynamic_lib;
4544

4645
use std::str::FromStr;

src/librustc_back/slice.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/librustc_borrowck/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ syntax = { path = "../libsyntax" }
1515
syntax_pos = { path = "../libsyntax_pos" }
1616
graphviz = { path = "../libgraphviz" }
1717
rustc = { path = "../librustc" }
18-
rustc_back = { path = "../librustc_back" }
1918
rustc_mir = { path = "../librustc_mir" }
2019
rustc_errors = { path = "../librustc_errors" }

src/librustc_borrowck/borrowck/unused.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc::hir::{self, HirId};
1313
use rustc::lint::builtin::UNUSED_MUT;
1414
use rustc::ty;
1515
use rustc::util::nodemap::{FxHashMap, FxHashSet};
16-
use rustc_back::slice;
16+
use std::slice;
1717
use syntax::ptr::P;
1818

1919
use borrowck::BorrowckCtxt;
@@ -26,7 +26,7 @@ pub fn check<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: &'tcx hir::Body) {
2626
}.visit_expr(&body.value);
2727
let mut cx = UnusedMutCx { bccx, used_mut };
2828
for arg in body.arguments.iter() {
29-
cx.check_unused_mut_pat(slice::ref_slice(&arg.pat));
29+
cx.check_unused_mut_pat(slice::from_ref(&arg.pat));
3030
}
3131
cx.visit_expr(&body.value);
3232
}
@@ -101,7 +101,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> {
101101
}
102102

103103
fn visit_local(&mut self, local: &hir::Local) {
104-
self.check_unused_mut_pat(slice::ref_slice(&local.pat));
104+
self.check_unused_mut_pat(slice::from_ref(&local.pat));
105105
}
106106
}
107107

src/librustc_borrowck/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515

1616
#![allow(non_camel_case_types)]
1717

18+
#![feature(from_ref)]
1819
#![feature(match_default_bindings)]
1920
#![feature(quote)]
2021

2122
#[macro_use] extern crate log;
2223
extern crate syntax;
2324
extern crate syntax_pos;
2425
extern crate rustc_errors as errors;
25-
extern crate rustc_back;
2626

2727
// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
2828
// refers to the borrowck-specific graphviz adapter traits.

src/librustc_const_eval/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ crate-type = ["dylib"]
1212
arena = { path = "../libarena" }
1313
log = "0.3"
1414
rustc = { path = "../librustc" }
15-
rustc_back = { path = "../librustc_back" }
1615
rustc_const_math = { path = "../librustc_const_math" }
1716
rustc_data_structures = { path = "../librustc_data_structures" }
1817
rustc_errors = { path = "../librustc_errors" }

src/librustc_const_eval/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc::hir::def_id::DefId;
3131
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
3232
use rustc::hir::{self, Pat, PatKind};
3333

34-
use rustc_back::slice;
34+
use std::slice;
3535

3636
use syntax::ast;
3737
use syntax::ptr::P;
@@ -114,15 +114,15 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> {
114114
});
115115

116116
// Check legality of move bindings and `@` patterns.
117-
self.check_patterns(false, slice::ref_slice(&loc.pat));
117+
self.check_patterns(false, slice::from_ref(&loc.pat));
118118
}
119119

120120
fn visit_body(&mut self, body: &'tcx hir::Body) {
121121
intravisit::walk_body(self, body);
122122

123123
for arg in &body.arguments {
124124
self.check_irrefutable(&arg.pat, "function argument");
125-
self.check_patterns(false, slice::ref_slice(&arg.pat));
125+
self.check_patterns(false, slice::from_ref(&arg.pat));
126126
}
127127
}
128128
}

src/librustc_const_eval/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
#![feature(box_patterns)]
2525
#![feature(box_syntax)]
2626
#![feature(i128_type)]
27+
#![feature(from_ref)]
2728

2829
extern crate arena;
2930
#[macro_use] extern crate syntax;
3031
#[macro_use] extern crate log;
3132
#[macro_use] extern crate rustc;
32-
extern crate rustc_back;
3333
extern crate rustc_const_math;
3434
extern crate rustc_data_structures;
3535
extern crate rustc_errors;

src/librustc_typeck/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ syntax = { path = "../libsyntax" }
1515
arena = { path = "../libarena" }
1616
fmt_macros = { path = "../libfmt_macros" }
1717
rustc = { path = "../librustc" }
18-
rustc_back = { path = "../librustc_back" }
1918
rustc_const_math = { path = "../librustc_const_math" }
2019
rustc_data_structures = { path = "../librustc_data_structures" }
2120
rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" }

src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc::ty::subst::{Kind, Subst, Substs};
2323
use rustc::traits;
2424
use rustc::ty::{self, RegionKind, Ty, TyCtxt, ToPredicate, TypeFoldable};
2525
use rustc::ty::wf::object_region_bounds;
26-
use rustc_back::slice;
26+
use std::slice;
2727
use require_c_abi_if_variadic;
2828
use util::common::ErrorReported;
2929
use util::nodemap::FxHashSet;
@@ -782,7 +782,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
782782

783783
debug!("associated_path_def_to_ty: {:?}::{}", ty, assoc_name);
784784

785-
self.prohibit_type_params(slice::ref_slice(item_segment));
785+
self.prohibit_type_params(slice::from_ref(item_segment));
786786

787787
// Find the type of the associated item, and the trait where the associated
788788
// item is declared.
@@ -859,7 +859,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
859859
let tcx = self.tcx();
860860
let trait_def_id = tcx.parent_def_id(item_def_id).unwrap();
861861

862-
self.prohibit_type_params(slice::ref_slice(item_segment));
862+
self.prohibit_type_params(slice::from_ref(item_segment));
863863

864864
let self_ty = if let Some(ty) = opt_self_ty {
865865
ty

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ use self::TupleArgumentsFlag::*;
8787
use astconv::AstConv;
8888
use hir::def::{Def, CtorKind};
8989
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
90-
use rustc_back::slice::ref_slice;
90+
use std::slice;
9191
use namespace::Namespace;
9292
use rustc::infer::{self, InferCtxt, InferOk, RegionVariableOrigin};
9393
use rustc::infer::type_variable::{TypeVariableOrigin};
@@ -130,7 +130,6 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
130130
use rustc::hir::map::Node;
131131
use rustc::hir::{self, PatKind};
132132
use rustc::middle::lang_items;
133-
use rustc_back::slice;
134133
use rustc_const_math::ConstInt;
135134

136135
mod autoderef;
@@ -4168,7 +4167,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
41684167
if let Some(cached_def) = self.tables.borrow().type_dependent_defs().get(hir_id) {
41694168
// Return directly on cache hit. This is useful to avoid doubly reporting
41704169
// errors with default match binding modes. See #44614.
4171-
return (*cached_def, Some(ty), slice::ref_slice(&**item_segment))
4170+
return (*cached_def, Some(ty), slice::from_ref(&**item_segment))
41724171
}
41734172
let item_name = item_segment.name;
41744173
let def = match self.resolve_ufcs(span, item_name, ty, node_id) {
@@ -4187,7 +4186,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
41874186

41884187
// Write back the new resolution.
41894188
self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, def);
4190-
(def, Some(ty), slice::ref_slice(&**item_segment))
4189+
(def, Some(ty), slice::from_ref(&**item_segment))
41914190
}
41924191

41934192
pub fn check_decl_initializer(&self,
@@ -4325,7 +4324,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
43254324
CoerceMany::new(coerce_to_ty)
43264325
} else {
43274326
let tail_expr: &[P<hir::Expr>] = match tail_expr {
4328-
Some(e) => ref_slice(e),
4327+
Some(e) => slice::from_ref(e),
43294328
None => &[],
43304329
};
43314330
CoerceMany::with_coercion_sites(coerce_to_ty, tail_expr)

src/librustc_typeck/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ This API is completely unstable and subject to change.
7777
#![feature(box_syntax)]
7878
#![feature(crate_visibility_modifier)]
7979
#![feature(conservative_impl_trait)]
80+
#![feature(from_ref)]
8081
#![feature(match_default_bindings)]
8182
#![feature(never_type)]
8283
#![feature(quote)]
@@ -90,7 +91,6 @@ extern crate syntax_pos;
9091
extern crate arena;
9192
#[macro_use] extern crate rustc;
9293
extern crate rustc_platform_intrinsics as intrinsics;
93-
extern crate rustc_back;
9494
extern crate rustc_const_math;
9595
extern crate rustc_data_structures;
9696
extern crate rustc_errors as errors;

0 commit comments

Comments
 (0)