From 2363852fc69f4ca0699c8fce394105f955054b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 11 Jan 2019 06:31:17 +0100 Subject: [PATCH] fixes --- Cargo.lock | 14 ++++++++++++++ src/librustc/hir/mod.rs | 4 +++- src/librustc/ich/impls_hir.rs | 9 --------- .../nice_region_error/find_anon_type.rs | 4 ++-- src/librustc/ty/context.rs | 3 ++- src/librustc/ty/sty.rs | 3 ++- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 9 ++++++--- 9 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fde5ac8cb15a..652a8c6d9f156 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,6 +47,7 @@ name = "arena" version = "0.0.0" dependencies = [ "rustc_data_structures 0.0.0", + "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2081,6 +2082,7 @@ dependencies = [ "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", "rustc_fs_util 0.0.0", + "rustc_macros 0.1.0", "rustc_target 0.0.0", "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serialize 0.0.0", @@ -2328,6 +2330,7 @@ dependencies = [ "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_llvm 0.0.0", + "rustc_macros 0.1.0", ] [[package]] @@ -2499,6 +2502,16 @@ dependencies = [ "core 0.0.0", ] +[[package]] +name = "rustc_macros" +version = "0.1.0" +dependencies = [ + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustc_metadata" version = "0.0.0" @@ -2700,6 +2713,7 @@ dependencies = [ "minifier 0.0.20 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_macros 0.1.0", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 8b6c1bd19c3d0..003c6eeccb2e5 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -125,7 +125,9 @@ mod item_local_id_inner { /// an "item-like" to something else can be implement by a `Vec` instead of a /// tree or hash map. newtype_index! { - pub struct ItemLocalId { .. } + pub struct ItemLocalId { + derive [HashStable] + } } } diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 28a689426392f..2cb6f998237ae 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -69,15 +69,6 @@ impl<'a> ToStableHashKey> for CrateNum { } } -impl<'a> HashStable> for hir::ItemLocalId { - #[inline] - fn hash_stable(&self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) { - self.as_u32().hash_stable(hcx, hasher); - } -} - impl<'a> ToStableHashKey> for hir::ItemLocalId { type KeyType = hir::ItemLocalId; diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index e9a89d3edcdd3..ab451ceb9e123 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -25,7 +25,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { &self, region: Region<'tcx>, br: &ty::BoundRegion, - ) -> Option<(&hir::Ty, &hir::FnDecl)> { + ) -> Option<(&'gcx hir::Ty<'gcx>, &'gcx hir::FnDecl<'gcx>)> { if let Some(anon_reg) = self.tcx.is_suitable_region(region) { let def_id = anon_reg.def_id; if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) { @@ -62,7 +62,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { &self, arg: &'gcx hir::Ty, br: &ty::BoundRegion, - ) -> Option<(&'gcx hir::Ty)> { + ) -> Option<(&'gcx hir::Ty<'gcx>)> { let mut nested_visitor = FindNestedTypeVisitor { tcx: self.tcx, bound_region: *br, diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b07abd4007d94..bb6b651900e1f 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -789,6 +789,7 @@ impl<'a, 'gcx> HashStable> for TypeckTables<'gcx> { newtype_index! { pub struct UserTypeAnnotationIndex { + derive [HashStable] DEBUG_FORMAT = "UserTypeAnnotation({})", const START_INDEX = 0, } @@ -841,7 +842,7 @@ impl CanonicalUserTypeAnnotation<'gcx> { /// A user-given type annotation attached to a constant. These arise /// from constants that are named via paths, like `Foo::::new` and /// so forth. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)] pub enum UserTypeAnnotation<'tcx> { Ty(Ty<'tcx>), diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index aecf61912b23e..f72987f8d8a71 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -2066,7 +2066,8 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } -#[derive(Copy, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Copy, Clone, Debug, Hash, HashStable, + RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)] /// Used in the HIR by using `Unevaluated` everywhere and later normalizing to `Evaluated` if the /// code is monomorphic enough for that. pub enum LazyConst<'tcx> { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index e2626c63143f3..ef650f43b64a8 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1444,7 +1444,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { pub fn prohibit_generics<'a, T: IntoIterator>>( &self, segments: T - ) + ) -> bool where 'gcx: 'a { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 23bcd88d6afb5..fb666ceb1b91c 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -676,8 +676,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { #[derive(Copy, Clone)] pub enum SelfSource<'a> { - QPath(&'a hir::Ty), - MethodCall(&'a hir::Expr /* rcvr */), + QPath(&'a hir::Ty<'a>), + MethodCall(&'a hir::Expr<'a> /* rcvr */), } #[derive(Copy, Clone)] diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 48b7d6f2ef904..1bc85ddee939f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4930,13 +4930,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } /// Given a function block's `NodeId`, return its `FnDecl` if it exists, or `None` otherwise. - fn get_parent_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, ast::Ident)> { + fn get_parent_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl<'gcx>, ast::Ident)> { let parent = self.tcx.hir().get(self.tcx.hir().get_parent(blk_id)); self.get_node_fn_decl(parent).map(|(fn_decl, ident, _)| (fn_decl, ident)) } /// Given a function `Node`, return its `FnDecl` if it exists, or `None` otherwise. - fn get_node_fn_decl(&self, node: Node) -> Option<(hir::FnDecl, ast::Ident, bool)> { + fn get_node_fn_decl<'hir>( + &self, + node: Node<'hir> + ) -> Option<(hir::FnDecl<'hir>, ast::Ident, bool)> { match node { Node::Item(&hir::Item { ident, node: hir::ItemKind::Fn(ref decl, ..), .. @@ -4962,7 +4965,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether a /// suggestion can be made, `None` otherwise. - pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> { + pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl<'gcx>, bool)> { // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or // `while` before reaching it, as block tail returns are not available in them. self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {