提交 d6f70359 编写于 作者: I Irina-Gabriela Popa

rustc_back: remove slice module in favor of std::slice::from_ref.

上级 fdfbcf85
......@@ -1687,7 +1687,6 @@ dependencies = [
"graphviz 0.0.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_errors 0.0.0",
"rustc_mir 0.0.0",
"syntax 0.0.0",
......@@ -1701,7 +1700,6 @@ dependencies = [
"arena 0.0.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_const_math 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
......@@ -1999,7 +1997,6 @@ dependencies = [
"fmt_macros 0.0.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_const_math 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
......
......@@ -46,6 +46,7 @@
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![feature(from_ref)]
#![feature(i128)]
#![feature(i128_type)]
#![feature(inclusive_range)]
......
......@@ -26,7 +26,7 @@
use self::TargetLint::*;
use rustc_back::slice;
use std::slice;
use lint::{EarlyLintPassObject, LateLintPassObject};
use lint::{Level, Lint, LintId, LintPass, LintBuffer};
use lint::levels::{LintLevelSets, LintLevelsBuilder};
......@@ -308,7 +308,7 @@ pub fn check_lint_name(&self, lint_name: &str) -> CheckLintNameResult {
Some(ids) => CheckLintNameResult::Ok(&ids.0),
}
}
Some(&Id(ref id)) => CheckLintNameResult::Ok(slice::ref_slice(id)),
Some(&Id(ref id)) => CheckLintNameResult::Ok(slice::from_ref(id)),
}
}
}
......
......@@ -31,7 +31,7 @@
use errors::DiagnosticBuilder;
use util::common::ErrorReported;
use util::nodemap::{NodeMap, NodeSet, FxHashSet, FxHashMap, DefIdMap};
use rustc_back::slice;
use std::slice;
use hir;
use hir::intravisit::{self, Visitor, NestedVisitorMap};
......@@ -530,7 +530,7 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
if lifetime_ref.is_elided() {
self.resolve_elided_lifetimes(slice::ref_slice(lifetime_ref));
self.resolve_elided_lifetimes(slice::from_ref(lifetime_ref));
return;
}
if lifetime_ref.is_static() {
......
......@@ -25,7 +25,7 @@
use ty::{self, AdtDef, ClosureSubsts, Region, Ty, TyCtxt, GeneratorInterior};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use util::ppaux;
use rustc_back::slice;
use std::slice;
use hir::{self, InlineAsm};
use std::ascii;
use std::borrow::{Cow};
......@@ -754,28 +754,28 @@ pub fn if_<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, cond: Operand<'tcx>,
pub fn successors(&self) -> Cow<[BasicBlock]> {
use self::TerminatorKind::*;
match *self {
Goto { target: ref b } => slice::ref_slice(b).into_cow(),
Goto { target: ref b } => slice::from_ref(b).into_cow(),
SwitchInt { targets: ref b, .. } => b[..].into_cow(),
Resume | GeneratorDrop => (&[]).into_cow(),
Return => (&[]).into_cow(),
Unreachable => (&[]).into_cow(),
Call { destination: Some((_, t)), cleanup: Some(c), .. } => vec![t, c].into_cow(),
Call { destination: Some((_, ref t)), cleanup: None, .. } =>
slice::ref_slice(t).into_cow(),
Call { destination: None, cleanup: Some(ref c), .. } => slice::ref_slice(c).into_cow(),
slice::from_ref(t).into_cow(),
Call { destination: None, cleanup: Some(ref c), .. } => slice::from_ref(c).into_cow(),
Call { destination: None, cleanup: None, .. } => (&[]).into_cow(),
Yield { resume: t, drop: Some(c), .. } => vec![t, c].into_cow(),
Yield { resume: ref t, drop: None, .. } => slice::ref_slice(t).into_cow(),
Yield { resume: ref t, drop: None, .. } => slice::from_ref(t).into_cow(),
DropAndReplace { target, unwind: Some(unwind), .. } |
Drop { target, unwind: Some(unwind), .. } => {
vec![target, unwind].into_cow()
}
DropAndReplace { ref target, unwind: None, .. } |
Drop { ref target, unwind: None, .. } => {
slice::ref_slice(target).into_cow()
slice::from_ref(target).into_cow()
}
Assert { target, cleanup: Some(unwind), .. } => vec![target, unwind].into_cow(),
Assert { ref target, .. } => slice::ref_slice(target).into_cow(),
Assert { ref target, .. } => slice::from_ref(target).into_cow(),
FalseEdges { ref real_target, ref imaginary_targets } => {
let mut s = vec![*real_target];
s.extend_from_slice(imaginary_targets);
......
......@@ -40,7 +40,6 @@
pub mod tempdir;
pub mod target;
pub mod slice;
pub mod dynamic_lib;
use std::str::FromStr;
......
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::mem;
pub fn ref_slice<T>(ptr: &T) -> &[T; 1] {
unsafe { mem::transmute(ptr) }
}
pub fn mut_ref_slice<T>(ptr: &mut T) -> &mut [T; 1] {
unsafe { mem::transmute(ptr) }
}
......@@ -15,6 +15,5 @@ syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
graphviz = { path = "../libgraphviz" }
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_mir = { path = "../librustc_mir" }
rustc_errors = { path = "../librustc_errors" }
......@@ -13,7 +13,7 @@
use rustc::lint::builtin::UNUSED_MUT;
use rustc::ty;
use rustc::util::nodemap::{FxHashMap, FxHashSet};
use rustc_back::slice;
use std::slice;
use syntax::ptr::P;
use borrowck::BorrowckCtxt;
......@@ -26,7 +26,7 @@ pub fn check<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: &'tcx hir::Body) {
}.visit_expr(&body.value);
let mut cx = UnusedMutCx { bccx, used_mut };
for arg in body.arguments.iter() {
cx.check_unused_mut_pat(slice::ref_slice(&arg.pat));
cx.check_unused_mut_pat(slice::from_ref(&arg.pat));
}
cx.visit_expr(&body.value);
}
......@@ -101,7 +101,7 @@ fn visit_arm(&mut self, arm: &hir::Arm) {
}
fn visit_local(&mut self, local: &hir::Local) {
self.check_unused_mut_pat(slice::ref_slice(&local.pat));
self.check_unused_mut_pat(slice::from_ref(&local.pat));
}
}
......
......@@ -15,6 +15,7 @@
#![allow(non_camel_case_types)]
#![feature(from_ref)]
#![feature(match_default_bindings)]
#![feature(quote)]
......@@ -22,7 +23,6 @@
extern crate syntax;
extern crate syntax_pos;
extern crate rustc_errors as errors;
extern crate rustc_back;
// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
// refers to the borrowck-specific graphviz adapter traits.
......
......@@ -12,7 +12,6 @@ crate-type = ["dylib"]
arena = { path = "../libarena" }
log = "0.3"
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_const_math = { path = "../librustc_const_math" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
......
......@@ -31,7 +31,7 @@
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
use rustc::hir::{self, Pat, PatKind};
use rustc_back::slice;
use std::slice;
use syntax::ast;
use syntax::ptr::P;
......@@ -114,7 +114,7 @@ fn visit_local(&mut self, loc: &'tcx hir::Local) {
});
// Check legality of move bindings and `@` patterns.
self.check_patterns(false, slice::ref_slice(&loc.pat));
self.check_patterns(false, slice::from_ref(&loc.pat));
}
fn visit_body(&mut self, body: &'tcx hir::Body) {
......@@ -122,7 +122,7 @@ fn visit_body(&mut self, body: &'tcx hir::Body) {
for arg in &body.arguments {
self.check_irrefutable(&arg.pat, "function argument");
self.check_patterns(false, slice::ref_slice(&arg.pat));
self.check_patterns(false, slice::from_ref(&arg.pat));
}
}
}
......
......@@ -24,12 +24,12 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(i128_type)]
#![feature(from_ref)]
extern crate arena;
#[macro_use] extern crate syntax;
#[macro_use] extern crate log;
#[macro_use] extern crate rustc;
extern crate rustc_back;
extern crate rustc_const_math;
extern crate rustc_data_structures;
extern crate rustc_errors;
......
......@@ -15,7 +15,6 @@ syntax = { path = "../libsyntax" }
arena = { path = "../libarena" }
fmt_macros = { path = "../libfmt_macros" }
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_const_math = { path = "../librustc_const_math" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" }
......
......@@ -23,7 +23,7 @@
use rustc::traits;
use rustc::ty::{self, RegionKind, Ty, TyCtxt, ToPredicate, TypeFoldable};
use rustc::ty::wf::object_region_bounds;
use rustc_back::slice;
use std::slice;
use require_c_abi_if_variadic;
use util::common::ErrorReported;
use util::nodemap::FxHashSet;
......@@ -782,7 +782,7 @@ pub fn associated_path_def_to_ty(&self,
debug!("associated_path_def_to_ty: {:?}::{}", ty, assoc_name);
self.prohibit_type_params(slice::ref_slice(item_segment));
self.prohibit_type_params(slice::from_ref(item_segment));
// Find the type of the associated item, and the trait where the associated
// item is declared.
......@@ -859,7 +859,7 @@ fn qpath_to_ty(&self,
let tcx = self.tcx();
let trait_def_id = tcx.parent_def_id(item_def_id).unwrap();
self.prohibit_type_params(slice::ref_slice(item_segment));
self.prohibit_type_params(slice::from_ref(item_segment));
let self_ty = if let Some(ty) = opt_self_ty {
ty
......
......@@ -87,7 +87,7 @@
use astconv::AstConv;
use hir::def::{Def, CtorKind};
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc_back::slice::ref_slice;
use std::slice;
use namespace::Namespace;
use rustc::infer::{self, InferCtxt, InferOk, RegionVariableOrigin};
use rustc::infer::type_variable::{TypeVariableOrigin};
......@@ -130,7 +130,6 @@
use rustc::hir::map::Node;
use rustc::hir::{self, PatKind};
use rustc::middle::lang_items;
use rustc_back::slice;
use rustc_const_math::ConstInt;
mod autoderef;
......@@ -4168,7 +4167,7 @@ pub fn resolve_ty_and_def_ufcs<'b>(&self,
if let Some(cached_def) = self.tables.borrow().type_dependent_defs().get(hir_id) {
// Return directly on cache hit. This is useful to avoid doubly reporting
// errors with default match binding modes. See #44614.
return (*cached_def, Some(ty), slice::ref_slice(&**item_segment))
return (*cached_def, Some(ty), slice::from_ref(&**item_segment))
}
let item_name = item_segment.name;
let def = match self.resolve_ufcs(span, item_name, ty, node_id) {
......@@ -4187,7 +4186,7 @@ pub fn resolve_ty_and_def_ufcs<'b>(&self,
// Write back the new resolution.
self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, def);
(def, Some(ty), slice::ref_slice(&**item_segment))
(def, Some(ty), slice::from_ref(&**item_segment))
}
pub fn check_decl_initializer(&self,
......@@ -4325,7 +4324,7 @@ fn check_block_with_expected(&self,
CoerceMany::new(coerce_to_ty)
} else {
let tail_expr: &[P<hir::Expr>] = match tail_expr {
Some(e) => ref_slice(e),
Some(e) => slice::from_ref(e),
None => &[],
};
CoerceMany::with_coercion_sites(coerce_to_ty, tail_expr)
......
......@@ -77,6 +77,7 @@
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)]
#![feature(conservative_impl_trait)]
#![feature(from_ref)]
#![feature(match_default_bindings)]
#![feature(never_type)]
#![feature(quote)]
......@@ -90,7 +91,6 @@
extern crate arena;
#[macro_use] extern crate rustc;
extern crate rustc_platform_intrinsics as intrinsics;
extern crate rustc_back;
extern crate rustc_const_math;
extern crate rustc_data_structures;
extern crate rustc_errors as errors;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册