diff options
| -rw-r--r-- | src/librustc/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/check/regionck.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/check/upvar.rs | 6 | ||||
| -rw-r--r-- | src/librustc_typeck/expr_use_visitor.rs (renamed from src/librustc/middle/expr_use_visitor.rs) | 29 | ||||
| -rw-r--r-- | src/librustc_typeck/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustc_typeck/mem_categorization.rs (renamed from src/librustc/middle/mem_categorization.rs) | 40 |
6 files changed, 44 insertions, 39 deletions
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 1fc157eca3e..481ae3b9329 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -96,7 +96,6 @@ pub mod infer; pub mod lint; pub mod middle { - pub mod expr_use_visitor; pub mod cstore; pub mod dependency_format; pub mod diagnostic_items; @@ -104,7 +103,6 @@ pub mod middle { pub mod free_region; pub mod lib_features; pub mod lang_items; - pub mod mem_categorization; pub mod privacy; pub mod reachable; pub mod region; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 7666db3ecd0..8ceb2174852 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -74,7 +74,7 @@ use crate::check::dropck; use crate::check::FnCtxt; -use crate::middle::mem_categorization as mc; +use crate::mem_categorization as mc; use crate::middle::region; use rustc::hir::def_id::DefId; use rustc::infer::outlives::env::OutlivesEnvironment; diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index daaa21202ac..3002459d56f 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -32,9 +32,9 @@ use super::FnCtxt; -use crate::middle::expr_use_visitor as euv; -use crate::middle::mem_categorization as mc; -use crate::middle::mem_categorization::PlaceBase; +use crate::expr_use_visitor as euv; +use crate::mem_categorization as mc; +use crate::mem_categorization::PlaceBase; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::hir::def_id::LocalDefId; diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc_typeck/expr_use_visitor.rs index 5ad381ef6b2..03d7ab2d633 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc_typeck/expr_use_visitor.rs @@ -5,14 +5,17 @@ pub use self::ConsumeMode::*; use self::OverloadedCallType::*; -use crate::hir::def::Res; -use crate::hir::def_id::DefId; -use crate::hir::ptr::P; -use crate::infer::InferCtxt; -use crate::middle::mem_categorization as mc; -use crate::ty::{self, TyCtxt, adjustment}; - -use crate::hir::{self, PatKind}; +// Export these here so that Clippy can use them. +pub use mc::{PlaceBase, Place, Projection}; + +use rustc::hir::{self, PatKind}; +use rustc::hir::def::Res; +use rustc::hir::def_id::DefId; +use rustc::hir::ptr::P; +use rustc::infer::InferCtxt; +use rustc::ty::{self, TyCtxt, adjustment}; + +use crate::mem_categorization as mc; use syntax_pos::Span; /////////////////////////////////////////////////////////////////////////// @@ -147,7 +150,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.mc.tcx() } - fn delegate_consume(&mut self, place: &mc::Place<'tcx>) { + fn delegate_consume(&mut self, place: &Place<'tcx>) { debug!("delegate_consume(place={:?})", place); let mode = copy_or_move(&self.mc, place); @@ -516,7 +519,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } } - fn walk_arm(&mut self, discr_place: &mc::Place<'tcx>, arm: &hir::Arm) { + fn walk_arm(&mut self, discr_place: &Place<'tcx>, arm: &hir::Arm) { self.walk_pat(discr_place, &arm.pat); if let Some(hir::Guard::If(ref e)) = arm.guard { @@ -528,13 +531,13 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { /// Walks a pat that occurs in isolation (i.e., top-level of fn argument or /// let binding, and *not* a match arm or nested pat.) - fn walk_irrefutable_pat(&mut self, discr_place: &mc::Place<'tcx>, pat: &hir::Pat) { + fn walk_irrefutable_pat(&mut self, discr_place: &Place<'tcx>, pat: &hir::Pat) { self.walk_pat(discr_place, pat); } /// The core driver for walking a pattern - fn walk_pat(&mut self, discr_place: &mc::Place<'tcx>, pat: &hir::Pat) { + fn walk_pat(&mut self, discr_place: &Place<'tcx>, pat: &hir::Pat) { debug!("walk_pat(discr_place={:?}, pat={:?})", discr_place, pat); let tcx = self.tcx(); @@ -622,7 +625,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { fn copy_or_move<'a, 'tcx>( mc: &mc::MemCategorizationContext<'a, 'tcx>, - place: &mc::Place<'tcx>, + place: &Place<'tcx>, ) -> ConsumeMode { if !mc.type_is_copy_modulo_regions(place.ty, place.span) { Move diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 0f147f92b5f..c606feab087 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -75,6 +75,9 @@ This API is completely unstable and subject to change. #[macro_use] extern crate rustc; +// This is used by Clippy. +pub mod expr_use_visitor; + mod astconv; mod check; mod check_unused; @@ -83,6 +86,7 @@ mod collect; mod constrained_generic_params; mod structured_errors; mod impl_wf_check; +mod mem_categorization; mod namespace; mod outlives; mod variance; diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc_typeck/mem_categorization.rs index 9b0a12234a7..84e5d234da9 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc_typeck/mem_categorization.rs @@ -48,15 +48,15 @@ //! result of `*x'`, effectively, where `x'` is a `Categorization::Upvar` reference //! tied to `x`. The type of `x'` will be a borrowed pointer. -use crate::hir::def_id::DefId; -use crate::infer::InferCtxt; -use crate::hir::def::{Res, DefKind}; -use crate::ty::adjustment; -use crate::ty::{self, Ty, TyCtxt}; -use crate::ty::fold::TypeFoldable; - -use crate::hir::PatKind; -use crate::hir; +use rustc::hir; +use rustc::hir::PatKind; +use rustc::hir::def_id::DefId; +use rustc::hir::def::{Res, DefKind}; +use rustc::infer::InferCtxt; +use rustc::ty::adjustment; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::fold::TypeFoldable; + use syntax_pos::Span; use rustc_data_structures::fx::FxIndexMap; @@ -105,7 +105,7 @@ impl<'tcx> Place<'tcx> { /// The types are in the reverse order that they are applied. So if /// `x: &*const u32` and the `Place` is `**x`, then the types returned are ///`*const u32` then `&*const u32`. - pub fn deref_tys(&self) -> impl Iterator<Item=Ty<'tcx>> + '_ { + crate fn deref_tys(&self) -> impl Iterator<Item=Ty<'tcx>> + '_ { self.projections.iter().rev().filter_map(|proj| if let Projection::Deref(deref_ty) = *proj { Some(deref_ty) } else { @@ -114,7 +114,7 @@ impl<'tcx> Place<'tcx> { } } -pub trait HirNode { +crate trait HirNode { fn hir_id(&self) -> hir::HirId; fn span(&self) -> Span; } @@ -130,19 +130,19 @@ impl HirNode for hir::Pat { } #[derive(Clone)] -pub struct MemCategorizationContext<'a, 'tcx> { - pub tables: &'a ty::TypeckTables<'tcx>, +crate struct MemCategorizationContext<'a, 'tcx> { + crate tables: &'a ty::TypeckTables<'tcx>, infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_owner: DefId, upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>, } -pub type McResult<T> = Result<T, ()>; +crate type McResult<T> = Result<T, ()>; impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { /// Creates a `MemCategorizationContext`. - pub fn new( + crate fn new( infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_owner: DefId, @@ -276,7 +276,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { Ok(ret_ty) } - pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> { + crate fn cat_expr(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> { // This recursion helper avoids going through *too many* // adjustments, since *only* non-overloaded deref recurses. fn helper<'a, 'tcx>( @@ -295,7 +295,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { helper(self, expr, self.tables.expr_adjustments(expr)) } - pub fn cat_expr_adjusted(&self, expr: &hir::Expr, + crate fn cat_expr_adjusted(&self, expr: &hir::Expr, previous: Place<'tcx>, adjustment: &adjustment::Adjustment<'tcx>) -> McResult<Place<'tcx>> { @@ -334,7 +334,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { } } - pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> { + crate fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> { debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr); let expr_ty = self.expr_ty(expr)?; @@ -475,7 +475,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { Ok(ret) } - pub fn cat_rvalue(&self, hir_id: hir::HirId, span: Span, expr_ty: Ty<'tcx>) -> Place<'tcx> { + crate fn cat_rvalue(&self, hir_id: hir::HirId, span: Span, expr_ty: Ty<'tcx>) -> Place<'tcx> { debug!("cat_rvalue hir_id={:?}, expr_ty={:?}, span={:?}", hir_id, expr_ty, span); let ret = Place { hir_id, @@ -562,7 +562,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { Ok(ret) } - pub fn cat_pattern<F>(&self, place: Place<'tcx>, pat: &hir::Pat, mut op: F) -> McResult<()> + crate fn cat_pattern<F>(&self, place: Place<'tcx>, pat: &hir::Pat, mut op: F) -> McResult<()> where F: FnMut(&Place<'tcx>, &hir::Pat), { self.cat_pattern_(place, pat, &mut op) |
