]> git.lizzy.rs Git - rust.git/commitdiff
Automatically generate imports for newtype_index `Deserialize` impls
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 19 Nov 2018 14:24:03 +0000 (15:24 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Tue, 4 Dec 2018 09:17:37 +0000 (10:17 +0100)
15 files changed:
src/librustc/dep_graph/graph.rs
src/librustc/dep_graph/serialized.rs
src/librustc/hir/mod.rs
src/librustc/middle/region.rs
src/librustc/mir/mod.rs
src/librustc/ty/mod.rs
src/librustc/ty/sty.rs
src/librustc_data_structures/indexed_vec.rs
src/librustc_mir/borrow_check/location.rs
src/librustc_mir/borrow_check/nll/constraints/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/values.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs
src/librustc_mir/build/mod.rs
src/librustc_target/abi/mod.rs

index 06287bda63a494e84b3b725d52ad9d4d8b99bc7a..4c94c993ab40595131f83168c737a4c2b5292806 100644 (file)
@@ -18,7 +18,6 @@
 use std::hash::Hash;
 use ty::{self, TyCtxt};
 use util::common::{ProfileQueriesMsg, profq_msg};
-use serialize::{Decodable, Decoder};
 
 use ich::{StableHashingContext, StableHashingContextProvider, Fingerprint};
 
index 992ebd0efb15f48bcadfa76a191700a6bcd4a63c..0c6c224fa914c9009a5b1546d0cc125301a09337 100644 (file)
@@ -13,7 +13,6 @@
 use dep_graph::DepNode;
 use ich::Fingerprint;
 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
-use serialize::{Decodable, Decoder};
 
 newtype_index! {
     pub struct SerializedDepNodeIndex { .. }
index 597a7738217035f42677e8cb2308fe92559ed2eb..1674320165e65f7fa0260eba170ae4cab3e5b35e 100644 (file)
@@ -122,7 +122,6 @@ fn default_decode<D: Decoder>(d: &mut D) -> Result<HirId, D::Error> {
 // hack to ensure that we don't try to access the private parts of `ItemLocalId` in this module
 mod item_local_id_inner {
     use rustc_data_structures::indexed_vec::Idx;
-    use serialize::{Decodable, Decoder};
     /// An `ItemLocalId` uniquely identifies something within a given "item-like",
     /// that is within a hir::Item, hir::TraitItem, or hir::ImplItem. There is no
     /// guarantee that the numerical value of a given `ItemLocalId` corresponds to
index 1440d91b47e639d1677d5ea447f8aaa7c1ddd477..35d1a4dd2cb7c5e691ede2c7d72cf258cfa4c0c8 100644 (file)
@@ -28,7 +28,6 @@
 use syntax_pos::{Span, DUMMY_SP};
 use ty::TyCtxt;
 use ty::query::Providers;
-use serialize::{Decodable, Decoder};
 
 use hir;
 use hir::Node;
index 09b344cd38d258f2fb72453c88461c116a553594..4a463c0d5a394dd82080b9aa36a841e2fb39d34c 100644 (file)
@@ -25,7 +25,7 @@
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 use rustc_data_structures::sync::Lrc;
 use rustc_data_structures::sync::MappedReadGuard;
-use rustc_serialize::{self as serialize, Decodable, Decoder};
+use rustc_serialize::{self as serialize};
 use smallvec::SmallVec;
 use std::borrow::Cow;
 use std::fmt::{self, Debug, Formatter, Write};
index 8ff93cee250221191b8acf8542d808a06e622807..4633ab11663472df322e5b73b54b364889150771 100644 (file)
@@ -41,7 +41,7 @@
 use arena::SyncDroplessArena;
 use session::DataTypeKind;
 
-use serialize::{self, Encodable, Encoder, Decodable, Decoder};
+use serialize::{self, Encodable, Encoder};
 use std::cell::RefCell;
 use std::cmp::{self, Ordering};
 use std::fmt;
index fa45b8c7768377f439e4023048906e21b40b153a..1416cb17feaedf9832f70e4783a9d5ecd0f5f9a1 100644 (file)
@@ -29,7 +29,7 @@
 use syntax::ast::{self, Ident};
 use syntax::symbol::{keywords, InternedString};
 
-use serialize::{self, Decodable, Decoder};
+use serialize;
 
 use hir;
 
index c35490ce35b4f0488474aed6422d47e7fde34060..6522dbe117994d75ead05ff1a07a25e6c683672c 100644 (file)
@@ -340,11 +340,7 @@ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
             @vis          [$v]
             @debug_format [$debug_format]
                           $($tokens)*);
-        impl Decodable for $type {
-            fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {
-                d.read_u32().into()
-            }
-        }
+        newtype_index!(@decodable $type);
     );
 
     // The case where no derives are added, but encodable is overridden. Don't
@@ -377,9 +373,21 @@ fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {
             @vis          [$v]
             @debug_format [$debug_format]
                           $($tokens)*);
-        impl Decodable for $type {
-            fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {
-                d.read_u32().map(Self::from)
+        newtype_index!(@decodable $type);
+    );
+
+    (@decodable $type:ident) => (
+        impl $type {
+            fn __decodable__impl__hack() {
+                mod __more_hacks_because__self_doesnt_work_in_functions {
+                    extern crate serialize;
+                    use self::serialize::{Decodable, Decoder};
+                    impl Decodable for super::$type {
+                        fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {
+                            d.read_u32().map(Self::from)
+                        }
+                    }
+                }
             }
         }
     );
index 2d593d851138b1dec9ebef630127589c51aab2d5..b3e159dd84457c14b2a35ca5d7821a84024195eb 100644 (file)
@@ -10,7 +10,6 @@
 
 use rustc::mir::{BasicBlock, Location, Mir};
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use rustc_serialize::{Decodable, Decoder};
 
 /// Maps between a MIR Location, which identifies a particular
 /// statement within a basic block, to a "rich location", which
index 37b11a77184d4f018654e3388091fa83f7be2274..a873af8333a7fb0af867ae6423ed36645e4951d6 100644 (file)
@@ -13,7 +13,6 @@
 use rustc_data_structures::graph::scc::Sccs;
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 use borrow_check::nll::type_check::Locations;
-use rustc_serialize::{Decodable, Decoder};
 
 use std::fmt;
 use std::ops::Deref;
index 5ce80ca236dbb337fcffd9b8d6fa0cc5f6601a62..69e2c896d33e515b3ce77fdcb4305f8333fc65ad 100644 (file)
@@ -16,7 +16,6 @@
 use rustc_data_structures::indexed_vec::IndexVec;
 use std::fmt::Debug;
 use std::rc::Rc;
-use rustc_serialize::{Decodable, Decoder};
 
 /// Maps between a `Location` and a `PointIndex` (and vice versa).
 crate struct RegionValueElements {
index d1a1d2aea248a55460b890016b8f202ce6122338..cc176cbc40392aa733851faa605d681645fc1ee6 100644 (file)
@@ -23,7 +23,6 @@
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 use util::liveness::LiveVariableMap;
-use rustc_serialize::{Decodable, Decoder};
 
 /// Map between Local and LiveVar indices: the purpose of this
 /// map is to define the subset of local variables for which we need
index 9e0eaf61e94a4cd6fdb649d41cf1ee1e8ef8ee24..4b39d58cd96a82e3c7479aa84429241bb63908f5 100644 (file)
@@ -15,7 +15,6 @@
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 use rustc_data_structures::vec_linked_list as vll;
 use util::liveness::{categorize, DefUse, LiveVariableMap};
-use rustc_serialize::{Decodable, Decoder};
 
 /// A map that cross references each local with the locations where it
 /// is defined (assigned), used, or dropped. Used during liveness
index 1a5a089c7aa03cb4e818312d195b457034372bfa..cc927df6350bdb3cc3b93893cd8556e6c662079e 100644 (file)
@@ -32,7 +32,6 @@
 use syntax::attr::{self, UnwindAttr};
 use syntax::symbol::keywords;
 use syntax_pos::Span;
-use rustc_serialize::{Decodable, Decoder};
 use transform::MirSource;
 use util as mir_util;
 
index 27a4292543ad65352c6047aecba0c504b0e9ac65..50ce0ad6915da3c9916c1c99ad1d754932590048 100644 (file)
@@ -17,7 +17,6 @@
 use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive};
 
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use rustc_serialize::{Decodable, Decoder};
 
 pub mod call;