]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #34424 - jseyfried:breaking_batch, r=Manishearth
authorbors <bors@rust-lang.org>
Mon, 27 Jun 2016 23:42:03 +0000 (16:42 -0700)
committerGitHub <noreply@github.com>
Mon, 27 Jun 2016 23:42:03 +0000 (16:42 -0700)
Batch up libsyntax breaking changes

Batch of the following syntax-[breaking-change] changes:
 - #34213: Add a variant `Macro` to `TraitItemKind`
 - #34368: Merge the variant `QPath` of `PatKind` into the variant `PatKind::Path`
 - #34385: Move `syntax::ast::TokenTree` into a new module `syntax::tokenstream`
 - #33943:
  - Remove the type parameter from `visit::Visitor`
  - Remove `attr::WithAttrs` -- use `attr::HasAttrs` instead.
  - Change `fold_tt`/`fold_tts` to take token trees by value and avoid wrapping token trees in `Rc`.
  - Remove the field `ctxt` of `ast::Mac_`
  - Remove inherent method `attrs()` of types -- use the method `attrs` of `HasAttrs` instead.
 - #34316:
  - Remove `ast::Decl`/`ast::DeclKind` and add variants `Local` and `Item` to `StmtKind`.
  - Move the node id for statements from the `StmtKind` variants to a field of `Stmt` (making `Stmt` a struct instead of an alias for `Spanned<StmtKind>`)
  - Rename `ast::ExprKind::Again` to `Continue`.
 - #34339: Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>`
  - Use `.into()` in convert between `Vec<Attribute>` and `ThinVec<Attribute>`
  - Use autoderef instead of `.as_attr_slice()`
 - #34436: Remove the optional expression from `ast::Block` and instead use a `StmtKind::Expr` at the end of the statement list.
 - #34403: Move errors into a separate crate (unlikely to cause breakage)

1  2 
src/librustc/mir/repr.rs
src/librustc_trans/intrinsic.rs
src/librustc_typeck/check/intrinsic.rs
src/libsyntax/ext/source_util.rs

diff --combined src/librustc/mir/repr.rs
index d39ff28841851d8a2539bb419a4e3e7eccf1730b,f55afc342e3f3d07e9d281cefe0fa9cc57c1494e..62d3421770c2f2cefe0a28ce6115ac5e006e21d1
@@@ -12,9 -12,6 +12,9 @@@ use graphviz::IntoCow
  use middle::const_val::ConstVal;
  use rustc_const_math::{ConstUsize, ConstInt, ConstMathErr};
  use rustc_data_structures::indexed_vec::{IndexVec, Idx};
 +use rustc_data_structures::control_flow_graph::dominators::{Dominators, dominators};
 +use rustc_data_structures::control_flow_graph::{GraphPredecessors, GraphSuccessors};
 +use rustc_data_structures::control_flow_graph::ControlFlowGraph;
  use hir::def_id::DefId;
  use ty::subst::Substs;
  use ty::{self, AdtDef, ClosureSubsts, FnOutput, Region, Ty};
@@@ -27,9 -24,8 +27,9 @@@ use std::cell::Ref
  use std::fmt::{self, Debug, Formatter, Write};
  use std::{iter, u32};
  use std::ops::{Index, IndexMut};
 +use std::vec::IntoIter;
  use syntax::ast::{self, Name};
- use syntax::codemap::Span;
+ use syntax_pos::Span;
  
  use super::cache::Cache;
  
@@@ -58,7 -54,7 +58,7 @@@ macro_rules! newtype_index 
  }
  
  /// Lowered representation of a single function.
 -#[derive(Clone, RustcEncodable, RustcDecodable)]
 +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
  pub struct Mir<'tcx> {
      /// List of basic blocks. References to basic block use a newtyped index type `BasicBlock`
      /// that indexes into this vector.
@@@ -149,11 -145,6 +149,11 @@@ impl<'tcx> Mir<'tcx> 
          Ref::map(self.predecessors(), |p| &p[bb])
      }
  
 +    #[inline]
 +    pub fn dominators(&self) -> Dominators<BasicBlock> {
 +        dominators(self)
 +    }
 +
      /// Maps locals (Arg's, Var's, Temp's and ReturnPointer, in that order)
      /// to their index in the whole list of locals. This is useful if you
      /// want to treat all locals the same instead of repeating yourself.
@@@ -1199,33 -1190,3 +1199,33 @@@ fn node_to_string(node_id: ast::NodeId
  fn item_path_str(def_id: DefId) -> String {
      ty::tls::with(|tcx| tcx.item_path_str(def_id))
  }
 +
 +impl<'tcx> ControlFlowGraph for Mir<'tcx> {
 +
 +    type Node = BasicBlock;
 +
 +    fn num_nodes(&self) -> usize { self.basic_blocks.len() }
 +
 +    fn start_node(&self) -> Self::Node { START_BLOCK }
 +
 +    fn predecessors<'graph>(&'graph self, node: Self::Node)
 +                            -> <Self as GraphPredecessors<'graph>>::Iter
 +    {
 +        self.predecessors_for(node).clone().into_iter()
 +    }
 +    fn successors<'graph>(&'graph self, node: Self::Node)
 +                          -> <Self as GraphSuccessors<'graph>>::Iter
 +    {
 +        self.basic_blocks[node].terminator().successors().into_owned().into_iter()
 +    }
 +}
 +
 +impl<'a, 'b> GraphPredecessors<'b> for Mir<'a> {
 +    type Item = BasicBlock;
 +    type Iter = IntoIter<BasicBlock>;
 +}
 +
 +impl<'a, 'b>  GraphSuccessors<'b> for Mir<'a> {
 +    type Item = BasicBlock;
 +    type Iter = IntoIter<BasicBlock>;
 +}
index f2793c5e18a896894b51b40920a1561544b59657,bd24647edf00b4b0f349c7e60f90bbab479a2dbe..a721361fce0e3aecbbd152edb8fd663507383df3
@@@ -44,7 -44,7 +44,7 @@@ use syntax::ptr::P
  use syntax::parse::token;
  
  use rustc::session::Session;
- use syntax::codemap::{Span, DUMMY_SP};
+ use syntax_pos::{Span, DUMMY_SP};
  
  use std::cmp::Ordering;
  
@@@ -617,6 -617,18 +617,6 @@@ pub fn trans_intrinsic_call<'a, 'blk, '
  
          },
  
 -
 -        (_, "return_address") => {
 -            if !fcx.fn_ty.ret.is_indirect() {
 -                span_err!(tcx.sess, span, E0510,
 -                          "invalid use of `return_address` intrinsic: function \
 -                           does not use out pointer");
 -                C_null(Type::i8p(ccx))
 -            } else {
 -                PointerCast(bcx, llvm::get_param(fcx.llfn, 0), Type::i8p(ccx))
 -            }
 -        }
 -
          (_, "discriminant_value") => {
              let val_ty = substs.types.get(FnSpace, 0);
              match val_ty.sty {
index 9148d68f39e0b633dcdd1cca3c5770fc8c632da5,0fb08ec9855de006bebaa15071f41af6dc453d43..5a3268e9e447b25a9165c02eec623c5f6164cedd
@@@ -20,8 -20,8 +20,8 @@@ use {CrateCtxt, require_same_types}
  use std::collections::{HashMap};
  use syntax::abi::Abi;
  use syntax::ast;
- use syntax::codemap::Span;
  use syntax::parse::token;
+ use syntax_pos::Span;
  
  use rustc::hir;
  
@@@ -275,6 -275,8 +275,6 @@@ pub fn check_intrinsic_type(ccx: &Crate
              "fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" =>
                  (1, vec![param(ccx, 0), param(ccx, 0)], param(ccx, 0)),
  
 -            "return_address" => (0, vec![], tcx.mk_imm_ptr(tcx.types.u8)),
 -
              "assume" => (0, vec![tcx.types.bool], tcx.mk_nil()),
  
              "discriminant_value" => (1, vec![
index d297188a35c8c56085c60bd80c78460ef98bcf21,b4ee6fa418aaea45ebb4eae93415dcd0a2723b32..97cb09991ec40b953901517cf1726d163aaa39e1
@@@ -9,8 -9,7 +9,7 @@@
  // except according to those terms.
  
  use ast;
- use codemap::{Pos, Span};
- use codemap;
+ use syntax_pos::{self, Pos, Span};
  use ext::base::*;
  use ext::base;
  use ext::build::AstBuilder;
@@@ -18,6 -17,7 +17,7 @@@ use parse::token
  use parse;
  use print::pprust;
  use ptr::P;
+ use tokenstream;
  use util::small_vector::SmallVector;
  
  use std::fs::File;
@@@ -30,7 -30,7 +30,7 @@@ use std::rc::Rc
  // a given file into the current one.
  
  /// line!(): expands to the current line number
- pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                     -> Box<base::MacResult+'static> {
      base::check_zero_tts(cx, sp, tts, "line!");
  
@@@ -41,7 -41,7 +41,7 @@@
  }
  
  /* column!(): expands to the current column number */
- pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                    -> Box<base::MacResult+'static> {
      base::check_zero_tts(cx, sp, tts, "column!");
  
@@@ -54,7 -54,7 +54,7 @@@
  /// file!(): expands to the current filename */
  /// The filemap (`loc.file`) contains a bunch more information we could spit
  /// out if we wanted.
- pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                     -> Box<base::MacResult+'static> {
      base::check_zero_tts(cx, sp, tts, "file!");
  
      base::MacEager::expr(cx.expr_str(topmost, filename))
  }
  
- pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                          -> Box<base::MacResult+'static> {
      let s = pprust::tts_to_string(tts);
      base::MacEager::expr(cx.expr_str(sp,
                                     token::intern_and_get_ident(&s[..])))
  }
  
- pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                    -> Box<base::MacResult+'static> {
      base::check_zero_tts(cx, sp, tts, "module_path!");
      let string = cx.mod_path()
@@@ -87,7 -87,7 +87,7 @@@
  /// include! : parse the given file as an expr
  /// This is generally a bad idea because it's going to behave
  /// unhygienically.
- pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                             -> Box<base::MacResult+'cx> {
      let file = match get_single_str_from_tts(cx, sp, tts, "include!") {
          Some(f) => f,
  }
  
  // include_str! : read the given file, insert it as a literal string expr
- pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                            -> Box<base::MacResult+'static> {
      let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") {
          Some(f) => f,
      }
  }
  
- pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
+ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
                              -> Box<base::MacResult+'static> {
      let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") {
          Some(f) => f,
  
  // resolve a file-system path to an absolute file-system path (if it
  // isn't already)
- fn res_rel_file(cx: &mut ExtCtxt, sp: codemap::Span, arg: &Path) -> PathBuf {
+ fn res_rel_file(cx: &mut ExtCtxt, sp: syntax_pos::Span, arg: &Path) -> PathBuf {
      // NB: relative paths are resolved relative to the compilation unit
      if !arg.is_absolute() {
 -        let mut cu = PathBuf::from(&cx.codemap().span_to_filename(sp));
 +        let callsite = cx.codemap().source_callsite(sp);
 +        let mut cu = PathBuf::from(&cx.codemap().span_to_filename(callsite));
          cu.pop();
          cu.push(arg);
          cu