Modernized a few type names in rustc and syntax

This commit is contained in:
Marvin Löbel 2013-08-31 18:13:04 +02:00
parent 617850131b
commit 539f37925c
115 changed files with 1316 additions and 1311 deletions

View File

@ -13,14 +13,14 @@ use driver::session::sess_os_to_meta_os;
use driver::session; use driver::session;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t { pub fn get_target_strs(target_triple: ~str, target_os: session::Os) -> target_strs::t {
return target_strs::t { return target_strs::t {
module_asm: ~"", module_asm: ~"",
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
data_layout: match target_os { data_layout: match target_os {
session::os_macos => { session::OsMacos => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -28,7 +28,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_win32 => { session::OsWin32 => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -36,7 +36,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_linux => { session::OsLinux => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -44,7 +44,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_android => { session::OsAndroid => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -52,7 +52,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_freebsd => { session::OsFreebsd => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +

View File

@ -814,13 +814,13 @@ pub fn mangle_internal_name_by_seq(_ccx: &mut CrateContext, flav: &str) -> ~str
} }
pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str { pub fn output_dll_filename(os: session::Os, lm: LinkMeta) -> ~str {
let (dll_prefix, dll_suffix) = match os { let (dll_prefix, dll_suffix) = match os {
session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX), session::OsWin32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
session::os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX), session::OsMacos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
session::os_linux => (linux::DLL_PREFIX, linux::DLL_SUFFIX), session::OsLinux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
session::os_android => (android::DLL_PREFIX, android::DLL_SUFFIX), session::OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
session::os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX), session::OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
}; };
fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix) fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
} }
@ -835,7 +835,7 @@ pub fn get_cc_prog(sess: Session) -> ~str {
match sess.opts.linker { match sess.opts.linker {
Some(ref linker) => linker.to_str(), Some(ref linker) => linker.to_str(),
None => match sess.targ_cfg.os { None => match sess.targ_cfg.os {
session::os_android => session::OsAndroid =>
match &sess.opts.android_cross_path { match &sess.opts.android_cross_path {
&Some(ref path) => { &Some(ref path) => {
fmt!("%s/bin/arm-linux-androideabi-gcc", *path) fmt!("%s/bin/arm-linux-androideabi-gcc", *path)
@ -845,7 +845,7 @@ pub fn get_cc_prog(sess: Session) -> ~str {
(--android-cross-path)") (--android-cross-path)")
} }
}, },
session::os_win32 => ~"g++", session::OsWin32 => ~"g++",
_ => ~"cc" _ => ~"cc"
} }
} }
@ -892,7 +892,7 @@ pub fn link_binary(sess: Session,
} }
// Clean up on Darwin // Clean up on Darwin
if sess.targ_cfg.os == session::os_macos { if sess.targ_cfg.os == session::OsMacos {
run::process_status("dsymutil", [output.to_str()]); run::process_status("dsymutil", [output.to_str()]);
} }
@ -913,7 +913,7 @@ pub fn link_args(sess: Session,
// Converts a library file-stem into a cc -l argument // Converts a library file-stem into a cc -l argument
fn unlib(config: @session::config, stem: ~str) -> ~str { fn unlib(config: @session::config, stem: ~str) -> ~str {
if stem.starts_with("lib") && if stem.starts_with("lib") &&
config.os != session::os_win32 { config.os != session::OsWin32 {
stem.slice(3, stem.len()).to_owned() stem.slice(3, stem.len()).to_owned()
} else { } else {
stem stem
@ -939,7 +939,7 @@ pub fn link_args(sess: Session,
obj_filename.to_str()]); obj_filename.to_str()]);
let lib_cmd = match sess.targ_cfg.os { let lib_cmd = match sess.targ_cfg.os {
session::os_macos => ~"-dynamiclib", session::OsMacos => ~"-dynamiclib",
_ => ~"-shared" _ => ~"-shared"
}; };
@ -995,7 +995,7 @@ pub fn link_args(sess: Session,
// On mac we need to tell the linker to let this library // On mac we need to tell the linker to let this library
// be rpathed // be rpathed
if sess.targ_cfg.os == session::os_macos { if sess.targ_cfg.os == session::OsMacos {
args.push(~"-Wl,-install_name,@rpath/" args.push(~"-Wl,-install_name,@rpath/"
+ output.filename().unwrap()); + output.filename().unwrap());
} }
@ -1003,7 +1003,7 @@ pub fn link_args(sess: Session,
// On linux librt and libdl are an indirect dependencies via rustrt, // On linux librt and libdl are an indirect dependencies via rustrt,
// and binutils 2.22+ won't add them automatically // and binutils 2.22+ won't add them automatically
if sess.targ_cfg.os == session::os_linux { if sess.targ_cfg.os == session::OsLinux {
args.push_all([~"-lrt", ~"-ldl"]); args.push_all([~"-lrt", ~"-ldl"]);
// LLVM implements the `frem` instruction as a call to `fmod`, // LLVM implements the `frem` instruction as a call to `fmod`,
@ -1011,12 +1011,12 @@ pub fn link_args(sess: Session,
// have to be explicit about linking to it. See #2510 // have to be explicit about linking to it. See #2510
args.push(~"-lm"); args.push(~"-lm");
} }
else if sess.targ_cfg.os == session::os_android { else if sess.targ_cfg.os == session::OsAndroid {
args.push_all([~"-ldl", ~"-llog", ~"-lsupc++", ~"-lgnustl_shared"]); args.push_all([~"-ldl", ~"-llog", ~"-lsupc++", ~"-lgnustl_shared"]);
args.push(~"-lm"); args.push(~"-lm");
} }
if sess.targ_cfg.os == session::os_freebsd { if sess.targ_cfg.os == session::OsFreebsd {
args.push_all([~"-pthread", ~"-lrt", args.push_all([~"-pthread", ~"-lrt",
~"-L/usr/local/lib", ~"-lexecinfo", ~"-L/usr/local/lib", ~"-lexecinfo",
~"-L/usr/local/lib/gcc46", ~"-L/usr/local/lib/gcc46",
@ -1030,7 +1030,7 @@ pub fn link_args(sess: Session,
// linker from the dwarf unwind info. Unfortunately, it does not seem to // linker from the dwarf unwind info. Unfortunately, it does not seem to
// understand how to unwind our __morestack frame, so we have to turn it // understand how to unwind our __morestack frame, so we have to turn it
// off. This has impacted some other projects like GHC. // off. This has impacted some other projects like GHC.
if sess.targ_cfg.os == session::os_macos { if sess.targ_cfg.os == session::OsMacos {
args.push(~"-Wl,-no_compact_unwind"); args.push(~"-Wl,-no_compact_unwind");
} }

View File

@ -13,14 +13,14 @@ use driver::session;
use driver::session::sess_os_to_meta_os; use driver::session::sess_os_to_meta_os;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t { pub fn get_target_strs(target_triple: ~str, target_os: session::Os) -> target_strs::t {
return target_strs::t { return target_strs::t {
module_asm: ~"", module_asm: ~"",
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
data_layout: match target_os { data_layout: match target_os {
session::os_macos => { session::OsMacos => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -28,7 +28,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_win32 => { session::OsWin32 => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -36,7 +36,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_linux => { session::OsLinux => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -44,7 +44,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_android => { session::OsAndroid => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +
@ -52,7 +52,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_st
"-a0:0:64-n32" "-a0:0:64-n32"
} }
session::os_freebsd => { session::OsFreebsd => {
~"e-p:32:32:32" + ~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" + "-f32:32:32-f64:64:64" +

View File

@ -16,8 +16,8 @@ use metadata::filesearch;
use std::hashmap::HashSet; use std::hashmap::HashSet;
use std::{os, util, vec}; use std::{os, util, vec};
fn not_win32(os: session::os) -> bool { fn not_win32(os: session::Os) -> bool {
os != session::os_win32 os != session::OsWin32
} }
pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
@ -25,7 +25,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
let os = sess.targ_cfg.os; let os = sess.targ_cfg.os;
// No rpath on windows // No rpath on windows
if os == session::os_win32 { if os == session::OsWin32 {
return ~[]; return ~[];
} }
@ -52,7 +52,7 @@ pub fn rpaths_to_flags(rpaths: &[Path]) -> ~[~str] {
rpaths.iter().map(|rpath| fmt!("-Wl,-rpath,%s",rpath.to_str())).collect() rpaths.iter().map(|rpath| fmt!("-Wl,-rpath,%s",rpath.to_str())).collect()
} }
fn get_rpaths(os: session::os, fn get_rpaths(os: session::Os,
sysroot: &Path, sysroot: &Path,
output: &Path, output: &Path,
libs: &[Path], libs: &[Path],
@ -97,13 +97,13 @@ fn get_rpaths(os: session::os,
return rpaths; return rpaths;
} }
fn get_rpaths_relative_to_output(os: session::os, fn get_rpaths_relative_to_output(os: session::Os,
output: &Path, output: &Path,
libs: &[Path]) -> ~[Path] { libs: &[Path]) -> ~[Path] {
libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect() libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect()
} }
pub fn get_rpath_relative_to_output(os: session::os, pub fn get_rpath_relative_to_output(os: session::Os,
output: &Path, output: &Path,
lib: &Path) lib: &Path)
-> Path { -> Path {
@ -113,10 +113,10 @@ pub fn get_rpath_relative_to_output(os: session::os,
// Mac doesn't appear to support $ORIGIN // Mac doesn't appear to support $ORIGIN
let prefix = match os { let prefix = match os {
session::os_android | session::os_linux | session::os_freebsd session::OsAndroid | session::OsLinux | session::OsFreebsd
=> "$ORIGIN", => "$ORIGIN",
session::os_macos => "@executable_path", session::OsMacos => "@executable_path",
session::os_win32 => util::unreachable() session::OsWin32 => util::unreachable()
}; };
Path(prefix).push_rel(&os::make_absolute(output).get_relative_to(&os::make_absolute(lib))) Path(prefix).push_rel(&os::make_absolute(output).get_relative_to(&os::make_absolute(lib)))
@ -205,7 +205,7 @@ mod test {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
fn test_rpath_relative() { fn test_rpath_relative() {
let o = session::os_linux; let o = session::OsLinux;
let res = get_rpath_relative_to_output(o, let res = get_rpath_relative_to_output(o,
&Path("bin/rustc"), &Path("lib/libstd.so")); &Path("bin/rustc"), &Path("lib/libstd.so"));
assert_eq!(res.to_str(), ~"$ORIGIN/../lib"); assert_eq!(res.to_str(), ~"$ORIGIN/../lib");
@ -214,7 +214,7 @@ mod test {
#[test] #[test]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
fn test_rpath_relative() { fn test_rpath_relative() {
let o = session::os_freebsd; let o = session::OsFreebsd;
let res = get_rpath_relative_to_output(o, let res = get_rpath_relative_to_output(o,
&Path("bin/rustc"), &Path("lib/libstd.so")); &Path("bin/rustc"), &Path("lib/libstd.so"));
assert_eq!(res.to_str(), ~"$ORIGIN/../lib"); assert_eq!(res.to_str(), ~"$ORIGIN/../lib");
@ -223,7 +223,7 @@ mod test {
#[test] #[test]
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
fn test_rpath_relative() { fn test_rpath_relative() {
let o = session::os_macos; let o = session::OsMacos;
let res = get_rpath_relative_to_output(o, let res = get_rpath_relative_to_output(o,
&Path("bin/rustc"), &Path("bin/rustc"),
&Path("lib/libstd.so")); &Path("lib/libstd.so"));

View File

@ -14,32 +14,32 @@ use driver::session::sess_os_to_meta_os;
use driver::session; use driver::session;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t { pub fn get_target_strs(target_triple: ~str, target_os: session::Os) -> target_strs::t {
return target_strs::t { return target_strs::t {
module_asm: ~"", module_asm: ~"",
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
data_layout: match target_os { data_layout: match target_os {
session::os_macos => { session::OsMacos => {
~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" +
"-i32:32:32-i64:32:64" + "-i32:32:32-i64:32:64" +
"-f32:32:32-f64:32:64-v64:64:64" + "-f32:32:32-f64:32:64-v64:64:64" +
"-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32" "-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32"
} }
session::os_win32 => { session::OsWin32 => {
~"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32" ~"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32"
} }
session::os_linux => { session::OsLinux => {
~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
} }
session::os_android => { session::OsAndroid => {
~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
} }
session::os_freebsd => { session::OsFreebsd => {
~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
} }
}, },

View File

@ -14,38 +14,38 @@ use driver::session::sess_os_to_meta_os;
use driver::session; use driver::session;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t { pub fn get_target_strs(target_triple: ~str, target_os: session::Os) -> target_strs::t {
return target_strs::t { return target_strs::t {
module_asm: ~"", module_asm: ~"",
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
data_layout: match target_os { data_layout: match target_os {
session::os_macos => { session::OsMacos => {
~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64" "s0:64:64-f80:128:128-n8:16:32:64"
} }
session::os_win32 => { session::OsWin32 => {
// FIXME: Test this. Copied from linux (#2398) // FIXME: Test this. Copied from linux (#2398)
~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64-S128" "s0:64:64-f80:128:128-n8:16:32:64-S128"
} }
session::os_linux => { session::OsLinux => {
~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64-S128" "s0:64:64-f80:128:128-n8:16:32:64-S128"
} }
session::os_android => { session::OsAndroid => {
~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64-S128" "s0:64:64-f80:128:128-n8:16:32:64-S128"
} }
session::os_freebsd => { session::OsFreebsd => {
~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64-S128" "s0:64:64-f80:128:128-n8:16:32:64-S128"

View File

@ -43,12 +43,12 @@ use syntax::parse::token;
use syntax::print::{pp, pprust}; use syntax::print::{pp, pprust};
use syntax; use syntax;
pub enum pp_mode { pub enum PpMode {
ppm_normal, PpmNormal,
ppm_expanded, PpmExpanded,
ppm_typed, PpmTyped,
ppm_identified, PpmIdentified,
ppm_expanded_identified PpmExpandedIdentified
} }
/** /**
@ -67,11 +67,11 @@ pub fn source_name(input: &input) -> @str {
pub fn default_configuration(sess: Session) -> pub fn default_configuration(sess: Session) ->
ast::CrateConfig { ast::CrateConfig {
let tos = match sess.targ_cfg.os { let tos = match sess.targ_cfg.os {
session::os_win32 => @"win32", session::OsWin32 => @"win32",
session::os_macos => @"macos", session::OsMacos => @"macos",
session::os_linux => @"linux", session::OsLinux => @"linux",
session::os_android => @"android", session::OsAndroid => @"android",
session::os_freebsd => @"freebsd" session::OsFreebsd => @"freebsd"
}; };
// ARM is bi-endian, however using NDK seems to default // ARM is bi-endian, however using NDK seems to default
@ -338,8 +338,8 @@ pub fn phase_5_run_llvm_passes(sess: Session,
// output are OK, so we generate assembly first and then run it through // output are OK, so we generate assembly first and then run it through
// an external assembler. // an external assembler.
// Same for Android. // Same for Android.
if (sess.targ_cfg.os == session::os_android || if (sess.targ_cfg.os == session::OsAndroid ||
sess.targ_cfg.os == session::os_win32) && sess.targ_cfg.os == session::OsWin32) &&
(sess.opts.output_type == link::output_type_object || (sess.opts.output_type == link::output_type_object ||
sess.opts.output_type == link::output_type_exe) { sess.opts.output_type == link::output_type_exe) {
let output_type = link::output_type_assembly; let output_type = link::output_type_assembly;
@ -439,7 +439,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
} }
pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &input, pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &input,
ppm: pp_mode) { ppm: PpMode) {
fn ann_paren_for_expr(node: pprust::ann_node) { fn ann_paren_for_expr(node: pprust::ann_node) {
match node { match node {
@ -485,20 +485,20 @@ pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &input,
let crate = phase_1_parse_input(sess, cfg.clone(), input); let crate = phase_1_parse_input(sess, cfg.clone(), input);
let (crate, is_expanded) = match ppm { let (crate, is_expanded) = match ppm {
ppm_expanded | ppm_expanded_identified | ppm_typed => { PpmExpanded | PpmExpandedIdentified | PpmTyped => {
(phase_2_configure_and_expand(sess, cfg, crate), true) (phase_2_configure_and_expand(sess, cfg, crate), true)
} }
_ => (crate, false) _ => (crate, false)
}; };
let annotation = match ppm { let annotation = match ppm {
ppm_identified | ppm_expanded_identified => { PpmIdentified | PpmExpandedIdentified => {
pprust::pp_ann { pprust::pp_ann {
pre: ann_paren_for_expr, pre: ann_paren_for_expr,
post: ann_identified_post post: ann_identified_post
} }
} }
ppm_typed => { PpmTyped => {
let analysis = phase_3_run_analysis_passes(sess, crate); let analysis = phase_3_run_analysis_passes(sess, crate);
pprust::pp_ann { pprust::pp_ann {
pre: ann_paren_for_expr, pre: ann_paren_for_expr,
@ -518,19 +518,19 @@ pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &input,
} }
} }
pub fn get_os(triple: &str) -> Option<session::os> { pub fn get_os(triple: &str) -> Option<session::Os> {
for &(name, os) in os_names.iter() { for &(name, os) in os_names.iter() {
if triple.contains(name) { return Some(os) } if triple.contains(name) { return Some(os) }
} }
None None
} }
static os_names : &'static [(&'static str, session::os)] = &'static [ static os_names : &'static [(&'static str, session::Os)] = &'static [
("mingw32", session::os_win32), ("mingw32", session::OsWin32),
("win32", session::os_win32), ("win32", session::OsWin32),
("darwin", session::os_macos), ("darwin", session::OsMacos),
("android", session::os_android), ("android", session::OsAndroid),
("linux", session::os_linux), ("linux", session::OsLinux),
("freebsd", session::os_freebsd)]; ("freebsd", session::OsFreebsd)];
pub fn get_arch(triple: &str) -> Option<abi::Architecture> { pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
for &(arch, abi) in architecture_abis.iter() { for &(arch, abi) in architecture_abis.iter() {
@ -817,13 +817,13 @@ pub fn build_session_(sopts: @session::options,
} }
} }
pub fn parse_pretty(sess: Session, name: &str) -> pp_mode { pub fn parse_pretty(sess: Session, name: &str) -> PpMode {
match name { match name {
&"normal" => ppm_normal, &"normal" => PpmNormal,
&"expanded" => ppm_expanded, &"expanded" => PpmExpanded,
&"typed" => ppm_typed, &"typed" => PpmTyped,
&"expanded,identified" => ppm_expanded_identified, &"expanded,identified" => PpmExpandedIdentified,
&"identified" => ppm_identified, &"identified" => PpmIdentified,
_ => { _ => {
sess.fatal("argument to `pretty` must be one of `normal`, \ sess.fatal("argument to `pretty` must be one of `normal`, \
`expanded`, `typed`, `identified`, \ `expanded`, `typed`, `identified`, \

View File

@ -20,7 +20,7 @@ use middle::lint;
use syntax::ast::NodeId; use syntax::ast::NodeId;
use syntax::ast::{int_ty, uint_ty, float_ty}; use syntax::ast::{int_ty, uint_ty, float_ty};
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::diagnostic; use syntax::diagnostic;
use syntax::parse::ParseSess; use syntax::parse::ParseSess;
use syntax::{ast, codemap}; use syntax::{ast, codemap};
@ -31,7 +31,7 @@ use syntax;
use std::hashmap::HashMap; use std::hashmap::HashMap;
#[deriving(Eq)] #[deriving(Eq)]
pub enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, } pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, }
#[deriving(Clone)] #[deriving(Clone)]
pub enum crate_type { pub enum crate_type {
@ -41,7 +41,7 @@ pub enum crate_type {
} }
pub struct config { pub struct config {
os: os, os: Os,
arch: abi::Architecture, arch: abi::Architecture,
target_strs: target_strs::t, target_strs: target_strs::t,
int_type: int_ty, int_type: int_ty,
@ -209,25 +209,25 @@ pub struct Session_ {
parse_sess: @mut ParseSess, parse_sess: @mut ParseSess,
codemap: @codemap::CodeMap, codemap: @codemap::CodeMap,
// For a library crate, this is always none // For a library crate, this is always none
entry_fn: @mut Option<(NodeId, codemap::span)>, entry_fn: @mut Option<(NodeId, codemap::Span)>,
entry_type: @mut Option<EntryFnType>, entry_type: @mut Option<EntryFnType>,
span_diagnostic: @mut diagnostic::span_handler, span_diagnostic: @mut diagnostic::span_handler,
filesearch: @filesearch::FileSearch, filesearch: @filesearch::FileSearch,
building_library: @mut bool, building_library: @mut bool,
working_dir: Path, working_dir: Path,
lints: @mut HashMap<ast::NodeId, ~[(lint::lint, codemap::span, ~str)]>, lints: @mut HashMap<ast::NodeId, ~[(lint::lint, codemap::Span, ~str)]>,
} }
pub type Session = @Session_; pub type Session = @Session_;
impl Session_ { impl Session_ {
pub fn span_fatal(@self, sp: span, msg: &str) -> ! { pub fn span_fatal(@self, sp: Span, msg: &str) -> ! {
self.span_diagnostic.span_fatal(sp, msg) self.span_diagnostic.span_fatal(sp, msg)
} }
pub fn fatal(@self, msg: &str) -> ! { pub fn fatal(@self, msg: &str) -> ! {
self.span_diagnostic.handler().fatal(msg) self.span_diagnostic.handler().fatal(msg)
} }
pub fn span_err(@self, sp: span, msg: &str) { pub fn span_err(@self, sp: Span, msg: &str) {
self.span_diagnostic.span_err(sp, msg) self.span_diagnostic.span_err(sp, msg)
} }
pub fn err(@self, msg: &str) { pub fn err(@self, msg: &str) {
@ -242,25 +242,25 @@ impl Session_ {
pub fn abort_if_errors(@self) { pub fn abort_if_errors(@self) {
self.span_diagnostic.handler().abort_if_errors() self.span_diagnostic.handler().abort_if_errors()
} }
pub fn span_warn(@self, sp: span, msg: &str) { pub fn span_warn(@self, sp: Span, msg: &str) {
self.span_diagnostic.span_warn(sp, msg) self.span_diagnostic.span_warn(sp, msg)
} }
pub fn warn(@self, msg: &str) { pub fn warn(@self, msg: &str) {
self.span_diagnostic.handler().warn(msg) self.span_diagnostic.handler().warn(msg)
} }
pub fn span_note(@self, sp: span, msg: &str) { pub fn span_note(@self, sp: Span, msg: &str) {
self.span_diagnostic.span_note(sp, msg) self.span_diagnostic.span_note(sp, msg)
} }
pub fn note(@self, msg: &str) { pub fn note(@self, msg: &str) {
self.span_diagnostic.handler().note(msg) self.span_diagnostic.handler().note(msg)
} }
pub fn span_bug(@self, sp: span, msg: &str) -> ! { pub fn span_bug(@self, sp: Span, msg: &str) -> ! {
self.span_diagnostic.span_bug(sp, msg) self.span_diagnostic.span_bug(sp, msg)
} }
pub fn bug(@self, msg: &str) -> ! { pub fn bug(@self, msg: &str) -> ! {
self.span_diagnostic.handler().bug(msg) self.span_diagnostic.handler().bug(msg)
} }
pub fn span_unimpl(@self, sp: span, msg: &str) -> ! { pub fn span_unimpl(@self, sp: Span, msg: &str) -> ! {
self.span_diagnostic.span_unimpl(sp, msg) self.span_diagnostic.span_unimpl(sp, msg)
} }
pub fn unimpl(@self, msg: &str) -> ! { pub fn unimpl(@self, msg: &str) -> ! {
@ -269,7 +269,7 @@ impl Session_ {
pub fn add_lint(@self, pub fn add_lint(@self,
lint: lint::lint, lint: lint::lint,
id: ast::NodeId, id: ast::NodeId,
sp: span, sp: Span,
msg: ~str) { msg: ~str) {
match self.lints.find_mut(&id) { match self.lints.find_mut(&id) {
Some(arr) => { arr.push((lint, sp, msg)); return; } Some(arr) => { arr.push((lint, sp, msg)); return; }
@ -288,7 +288,7 @@ impl Session_ {
} }
// This exists to help with refactoring to eliminate impossible // This exists to help with refactoring to eliminate impossible
// cases later on // cases later on
pub fn impossible_case(@self, sp: span, msg: &str) -> ! { pub fn impossible_case(@self, sp: Span, msg: &str) -> ! {
self.span_bug(sp, fmt!("Impossible case reached: %s", msg)); self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
} }
pub fn verbose(@self) -> bool { self.debugging_opt(verbose) } pub fn verbose(@self) -> bool { self.debugging_opt(verbose) }
@ -411,15 +411,15 @@ pub fn building_library(req_crate_type: crate_type,
} }
} }
pub fn sess_os_to_meta_os(os: os) -> metadata::loader::os { pub fn sess_os_to_meta_os(os: Os) -> metadata::loader::Os {
use metadata::loader; use metadata::loader;
match os { match os {
os_win32 => loader::os_win32, OsWin32 => loader::OsWin32,
os_linux => loader::os_linux, OsLinux => loader::OsLinux,
os_android => loader::os_android, OsAndroid => loader::OsAndroid,
os_macos => loader::os_macos, OsMacos => loader::OsMacos,
os_freebsd => loader::os_freebsd OsFreebsd => loader::OsFreebsd
} }
} }

View File

@ -39,8 +39,8 @@ fn no_prelude(attrs: &[ast::Attribute]) -> bool {
} }
fn inject_libstd_ref(sess: Session, crate: &ast::Crate) -> @ast::Crate { fn inject_libstd_ref(sess: Session, crate: &ast::Crate) -> @ast::Crate {
fn spanned<T>(x: T) -> codemap::spanned<T> { fn spanned<T>(x: T) -> codemap::Spanned<T> {
codemap::spanned { node: x, span: dummy_sp() } codemap::Spanned { node: x, span: dummy_sp() }
} }
let precursor = @fold::AstFoldFns { let precursor = @fold::AstFoldFns {

View File

@ -18,7 +18,7 @@ use std::vec;
use syntax::ast_util::*; use syntax::ast_util::*;
use syntax::attr::AttrMetaMethods; use syntax::attr::AttrMetaMethods;
use syntax::attr; use syntax::attr;
use syntax::codemap::{dummy_sp, span, ExpnInfo, NameAndSpan}; use syntax::codemap::{dummy_sp, Span, ExpnInfo, NameAndSpan};
use syntax::codemap; use syntax::codemap;
use syntax::ext::base::ExtCtxt; use syntax::ext::base::ExtCtxt;
use syntax::fold; use syntax::fold;
@ -29,7 +29,7 @@ use syntax::{ast, ast_util};
type node_id_gen = @fn() -> ast::NodeId; type node_id_gen = @fn() -> ast::NodeId;
struct Test { struct Test {
span: span, span: Span,
path: ~[ast::ident], path: ~[ast::ident],
bench: bool, bench: bool,
ignore: bool, ignore: bool,
@ -379,8 +379,8 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
return @item; return @item;
} }
fn nospan<T>(t: T) -> codemap::spanned<T> { fn nospan<T>(t: T) -> codemap::Spanned<T> {
codemap::spanned { node: t, span: dummy_sp() } codemap::Spanned { node: t, span: dummy_sp() }
} }
fn path_node(ids: ~[ast::ident]) -> ast::Path { fn path_node(ids: ~[ast::ident]) -> ast::Path {

View File

@ -21,7 +21,7 @@ use syntax::ast;
use std::vec; use std::vec;
use syntax::attr; use syntax::attr;
use syntax::attr::AttrMetaMethods; use syntax::attr::AttrMetaMethods;
use syntax::codemap::{span, dummy_sp}; use syntax::codemap::{Span, dummy_sp};
use syntax::diagnostic::span_handler; use syntax::diagnostic::span_handler;
use syntax::parse::token; use syntax::parse::token;
use syntax::parse::token::ident_interner; use syntax::parse::token::ident_interner;
@ -33,7 +33,7 @@ pub fn read_crates(diag: @mut span_handler,
crate: &ast::Crate, crate: &ast::Crate,
cstore: @mut cstore::CStore, cstore: @mut cstore::CStore,
filesearch: @FileSearch, filesearch: @FileSearch,
os: loader::os, os: loader::Os,
statik: bool, statik: bool,
intr: @ident_interner) { intr: @ident_interner) {
let e = @mut Env { let e = @mut Env {
@ -68,7 +68,7 @@ impl visit::Visitor<()> for ReadCrateVisitor {
#[deriving(Clone)] #[deriving(Clone)]
struct cache_entry { struct cache_entry {
cnum: int, cnum: int,
span: span, span: Span,
hash: @str, hash: @str,
metas: @~[@ast::MetaItem] metas: @~[@ast::MetaItem]
} }
@ -116,7 +116,7 @@ struct Env {
diag: @mut span_handler, diag: @mut span_handler,
filesearch: @FileSearch, filesearch: @FileSearch,
cstore: @mut cstore::CStore, cstore: @mut cstore::CStore,
os: loader::os, os: loader::Os,
statik: bool, statik: bool,
crate_cache: @mut ~[cache_entry], crate_cache: @mut ~[cache_entry],
next_crate_num: ast::CrateNum, next_crate_num: ast::CrateNum,
@ -252,7 +252,7 @@ fn resolve_crate(e: @mut Env,
ident: @str, ident: @str,
metas: ~[@ast::MetaItem], metas: ~[@ast::MetaItem],
hash: @str, hash: @str,
span: span) span: Span)
-> ast::CrateNum { -> ast::CrateNum {
let metas = metas_with_ident(ident, metas); let metas = metas_with_ident(ident, metas);

View File

@ -52,7 +52,7 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
/// Iterates over each child of the given item. /// Iterates over each child of the given item.
pub fn each_child_of_item(cstore: @mut cstore::CStore, pub fn each_child_of_item(cstore: @mut cstore::CStore,
def_id: ast::def_id, def_id: ast::def_id,
callback: &fn(decoder::def_like, ast::ident)) { callback: &fn(decoder::DefLike, ast::ident)) {
let crate_data = cstore::get_crate_data(cstore, def_id.crate); let crate_data = cstore::get_crate_data(cstore, def_id.crate);
let get_crate_data: decoder::GetCrateDataCb = |cnum| { let get_crate_data: decoder::GetCrateDataCb = |cnum| {
cstore::get_crate_data(cstore, cnum) cstore::get_crate_data(cstore, cnum)
@ -67,7 +67,7 @@ pub fn each_child_of_item(cstore: @mut cstore::CStore,
/// Iterates over each top-level crate item. /// Iterates over each top-level crate item.
pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore, pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore,
cnum: ast::CrateNum, cnum: ast::CrateNum,
callback: &fn(decoder::def_like, callback: &fn(decoder::DefLike,
ast::ident)) { ast::ident)) {
let crate_data = cstore::get_crate_data(cstore, cnum); let crate_data = cstore::get_crate_data(cstore, cnum);
let get_crate_data: decoder::GetCrateDataCb = |cnum| { let get_crate_data: decoder::GetCrateDataCb = |cnum| {

View File

@ -43,7 +43,7 @@ use syntax::ast;
use syntax::codemap; use syntax::codemap;
use syntax::parse::token; use syntax::parse::token;
type cmd = @crate_metadata; type Cmd = @crate_metadata;
// A function that takes a def_id relative to the crate being searched and // A function that takes a def_id relative to the crate being searched and
// returns a def_id relative to the compilation environment, i.e. if we hit a // returns a def_id relative to the compilation environment, i.e. if we hit a
@ -74,7 +74,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: &fn(x:&[u8]) -> bool, hash: u64) ->
ret ret
} }
pub type GetCrateDataCb<'self> = &'self fn(ast::CrateNum) -> cmd; pub type GetCrateDataCb<'self> = &'self fn(ast::CrateNum) -> Cmd;
pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> { pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
fn eq_item(bytes: &[u8], item_id: int) -> bool { fn eq_item(bytes: &[u8], item_id: int) -> bool {
@ -192,12 +192,12 @@ fn item_reqd_and_translated_parent_item(cnum: ast::CrateNum,
ast::def_id { crate: cnum, node: trait_did.node } ast::def_id { crate: cnum, node: trait_did.node }
} }
fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id { fn item_def_id(d: ebml::Doc, cdata: Cmd) -> ast::def_id {
let tagdoc = reader::get_doc(d, tag_def_id); let tagdoc = reader::get_doc(d, tag_def_id);
return translate_def_id(cdata, reader::with_doc_data(tagdoc, parse_def_id)); return translate_def_id(cdata, reader::with_doc_data(tagdoc, parse_def_id));
} }
fn get_provided_source(d: ebml::Doc, cdata: cmd) -> Option<ast::def_id> { fn get_provided_source(d: ebml::Doc, cdata: Cmd) -> Option<ast::def_id> {
do reader::maybe_get_doc(d, tag_item_method_provided_source).map_move |doc| { do reader::maybe_get_doc(d, tag_item_method_provided_source).map_move |doc| {
translate_def_id(cdata, reader::with_doc_data(doc, parse_def_id)) translate_def_id(cdata, reader::with_doc_data(doc, parse_def_id))
} }
@ -213,13 +213,13 @@ fn variant_disr_val(d: ebml::Doc) -> Option<ty::Disr> {
} }
} }
fn doc_type(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::t { fn doc_type(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::t {
let tp = reader::get_doc(doc, tag_items_data_item_type); let tp = reader::get_doc(doc, tag_items_data_item_type);
parse_ty_data(*tp.data, cdata.cnum, tp.start, tcx, parse_ty_data(*tp.data, cdata.cnum, tp.start, tcx,
|_, did| translate_def_id(cdata, did)) |_, did| translate_def_id(cdata, did))
} }
fn doc_method_fty(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::BareFnTy { fn doc_method_fty(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::BareFnTy {
let tp = reader::get_doc(doc, tag_item_method_fty); let tp = reader::get_doc(doc, tag_item_method_fty);
parse_bare_fn_ty_data(*tp.data, cdata.cnum, tp.start, tcx, parse_bare_fn_ty_data(*tp.data, cdata.cnum, tp.start, tcx,
|_, did| translate_def_id(cdata, did)) |_, did| translate_def_id(cdata, did))
@ -227,7 +227,7 @@ fn doc_method_fty(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::BareFnTy {
fn doc_transformed_self_ty(doc: ebml::Doc, fn doc_transformed_self_ty(doc: ebml::Doc,
tcx: ty::ctxt, tcx: ty::ctxt,
cdata: cmd) -> Option<ty::t> cdata: Cmd) -> Option<ty::t>
{ {
do reader::maybe_get_doc(doc, tag_item_method_transformed_self_ty).map |tp| { do reader::maybe_get_doc(doc, tag_item_method_transformed_self_ty).map |tp| {
parse_ty_data(*tp.data, cdata.cnum, tp.start, tcx, parse_ty_data(*tp.data, cdata.cnum, tp.start, tcx,
@ -236,21 +236,21 @@ fn doc_transformed_self_ty(doc: ebml::Doc,
} }
pub fn item_type(_item_id: ast::def_id, item: ebml::Doc, pub fn item_type(_item_id: ast::def_id, item: ebml::Doc,
tcx: ty::ctxt, cdata: cmd) -> ty::t { tcx: ty::ctxt, cdata: Cmd) -> ty::t {
doc_type(item, tcx, cdata) doc_type(item, tcx, cdata)
} }
fn doc_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::TraitRef { fn doc_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::TraitRef {
parse_trait_ref_data(*doc.data, cdata.cnum, doc.start, tcx, parse_trait_ref_data(*doc.data, cdata.cnum, doc.start, tcx,
|_, did| translate_def_id(cdata, did)) |_, did| translate_def_id(cdata, did))
} }
fn item_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::TraitRef { fn item_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::TraitRef {
let tp = reader::get_doc(doc, tag_item_trait_ref); let tp = reader::get_doc(doc, tag_item_trait_ref);
doc_trait_ref(tp, tcx, cdata) doc_trait_ref(tp, tcx, cdata)
} }
fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd, fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: Cmd,
tag: uint) tag: uint)
-> @~[ty::TypeParameterDef] { -> @~[ty::TypeParameterDef] {
let mut bounds = ~[]; let mut bounds = ~[];
@ -278,7 +278,7 @@ fn item_ty_param_count(item: ebml::Doc) -> uint {
n n
} }
fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] { fn enum_variant_ids(item: ebml::Doc, cdata: Cmd) -> ~[ast::def_id] {
let mut ids: ~[ast::def_id] = ~[]; let mut ids: ~[ast::def_id] = ~[];
let v = tag_items_data_item_variant; let v = tag_items_data_item_variant;
do reader::tagged_docs(item, v) |p| { do reader::tagged_docs(item, v) |p| {
@ -322,15 +322,15 @@ fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident {
} }
fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::CrateNum) fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::CrateNum)
-> def_like { -> DefLike {
let fam = item_family(item); let fam = item_family(item);
match fam { match fam {
ImmStatic => dl_def(ast::def_static(did, false)), ImmStatic => DlDef(ast::def_static(did, false)),
MutStatic => dl_def(ast::def_static(did, true)), MutStatic => DlDef(ast::def_static(did, true)),
Struct => dl_def(ast::def_struct(did)), Struct => DlDef(ast::def_struct(did)),
UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)), UnsafeFn => DlDef(ast::def_fn(did, ast::unsafe_fn)),
Fn => dl_def(ast::def_fn(did, ast::impure_fn)), Fn => DlDef(ast::def_fn(did, ast::impure_fn)),
ForeignFn => dl_def(ast::def_fn(did, ast::extern_fn)), ForeignFn => DlDef(ast::def_fn(did, ast::extern_fn)),
StaticMethod | UnsafeStaticMethod => { StaticMethod | UnsafeStaticMethod => {
let purity = if fam == UnsafeStaticMethod { ast::unsafe_fn } else let purity = if fam == UnsafeStaticMethod { ast::unsafe_fn } else
{ ast::impure_fn }; { ast::impure_fn };
@ -347,19 +347,19 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::CrateNum)
ast::FromImpl(item_reqd_and_translated_parent_item(cnum, ast::FromImpl(item_reqd_and_translated_parent_item(cnum,
item)) item))
}; };
dl_def(ast::def_static_method(did, provenance, purity)) DlDef(ast::def_static_method(did, provenance, purity))
} }
Type | ForeignType => dl_def(ast::def_ty(did)), Type | ForeignType => DlDef(ast::def_ty(did)),
Mod => dl_def(ast::def_mod(did)), Mod => DlDef(ast::def_mod(did)),
ForeignMod => dl_def(ast::def_foreign_mod(did)), ForeignMod => DlDef(ast::def_foreign_mod(did)),
Variant => { Variant => {
let enum_did = item_reqd_and_translated_parent_item(cnum, item); let enum_did = item_reqd_and_translated_parent_item(cnum, item);
dl_def(ast::def_variant(enum_did, did)) DlDef(ast::def_variant(enum_did, did))
} }
Trait => dl_def(ast::def_trait(did)), Trait => DlDef(ast::def_trait(did)),
Enum => dl_def(ast::def_ty(did)), Enum => DlDef(ast::def_ty(did)),
Impl => dl_impl(did), Impl => DlImpl(did),
PublicField | PrivateField | InheritedField => dl_field, PublicField | PrivateField | InheritedField => DlField,
} }
} }
@ -371,7 +371,7 @@ pub fn lookup_def(cnum: ast::CrateNum, data: @~[u8], did_: ast::def_id) ->
return def_like_to_def(item_to_def_like(item, did, cnum)); return def_like_to_def(item_to_def_like(item, did, cnum));
} }
pub fn get_trait_def(cdata: cmd, pub fn get_trait_def(cdata: Cmd,
item_id: ast::NodeId, item_id: ast::NodeId,
tcx: ty::ctxt) -> ty::TraitDef tcx: ty::ctxt) -> ty::TraitDef
{ {
@ -398,7 +398,7 @@ pub fn get_trait_def(cdata: cmd,
} }
} }
pub fn get_type(cdata: cmd, id: ast::NodeId, tcx: ty::ctxt) pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt)
-> ty::ty_param_bounds_and_ty { -> ty::ty_param_bounds_and_ty {
let item = lookup_item(id, cdata.data); let item = lookup_item(id, cdata.data);
@ -415,7 +415,7 @@ pub fn get_type(cdata: cmd, id: ast::NodeId, tcx: ty::ctxt)
} }
} }
pub fn get_region_param(cdata: cmd, id: ast::NodeId) pub fn get_region_param(cdata: Cmd, id: ast::NodeId)
-> Option<ty::region_variance> { -> Option<ty::region_variance> {
let item = lookup_item(id, cdata.data); let item = lookup_item(id, cdata.data);
@ -426,7 +426,7 @@ pub fn get_type_param_count(data: @~[u8], id: ast::NodeId) -> uint {
item_ty_param_count(lookup_item(id, data)) item_ty_param_count(lookup_item(id, data))
} }
pub fn get_impl_trait(cdata: cmd, pub fn get_impl_trait(cdata: Cmd,
id: ast::NodeId, id: ast::NodeId,
tcx: ty::ctxt) -> Option<@ty::TraitRef> tcx: ty::ctxt) -> Option<@ty::TraitRef>
{ {
@ -436,7 +436,7 @@ pub fn get_impl_trait(cdata: cmd,
} }
} }
pub fn get_impl_vtables(cdata: cmd, pub fn get_impl_vtables(cdata: Cmd,
id: ast::NodeId, id: ast::NodeId,
tcx: ty::ctxt) -> typeck::impl_res tcx: ty::ctxt) -> typeck::impl_res
{ {
@ -451,7 +451,7 @@ pub fn get_impl_vtables(cdata: cmd,
} }
pub fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::NodeId, pub fn get_impl_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId,
name: ast::ident) -> Option<ast::def_id> { name: ast::ident) -> Option<ast::def_id> {
let items = reader::get_doc(reader::Doc(cdata.data), tag_items); let items = reader::get_doc(reader::Doc(cdata.data), tag_items);
let mut found = None; let mut found = None;
@ -470,22 +470,22 @@ pub fn get_symbol(data: @~[u8], id: ast::NodeId) -> ~str {
} }
// Something that a name can resolve to. // Something that a name can resolve to.
pub enum def_like { pub enum DefLike {
dl_def(ast::def), DlDef(ast::def),
dl_impl(ast::def_id), DlImpl(ast::def_id),
dl_field DlField
} }
fn def_like_to_def(def_like: def_like) -> ast::def { fn def_like_to_def(def_like: DefLike) -> ast::def {
match def_like { match def_like {
dl_def(def) => return def, DlDef(def) => return def,
dl_impl(*) => fail!("found impl in def_like_to_def"), DlImpl(*) => fail!("found impl in def_like_to_def"),
dl_field => fail!("found field in def_like_to_def") DlField => fail!("found field in def_like_to_def")
} }
} }
/// Iterates over the language items in the given crate. /// Iterates over the language items in the given crate.
pub fn each_lang_item(cdata: cmd, f: &fn(ast::NodeId, uint) -> bool) -> bool { pub fn each_lang_item(cdata: Cmd, f: &fn(ast::NodeId, uint) -> bool) -> bool {
let root = reader::Doc(cdata.data); let root = reader::Doc(cdata.data);
let lang_items = reader::get_doc(root, tag_lang_items); let lang_items = reader::get_doc(root, tag_lang_items);
do reader::tagged_docs(lang_items, tag_lang_items_item) |item_doc| { do reader::tagged_docs(lang_items, tag_lang_items_item) |item_doc| {
@ -501,10 +501,10 @@ pub fn each_lang_item(cdata: cmd, f: &fn(ast::NodeId, uint) -> bool) -> bool {
struct EachItemContext<'self> { struct EachItemContext<'self> {
intr: @ident_interner, intr: @ident_interner,
cdata: cmd, cdata: Cmd,
get_crate_data: GetCrateDataCb<'self>, get_crate_data: GetCrateDataCb<'self>,
path_builder: &'self mut ~str, path_builder: &'self mut ~str,
callback: &'self fn(&str, def_like, ast::visibility) -> bool, callback: &'self fn(&str, DefLike, ast::visibility) -> bool,
} }
impl<'self> EachItemContext<'self> { impl<'self> EachItemContext<'self> {
@ -533,7 +533,7 @@ impl<'self> EachItemContext<'self> {
-> bool { -> bool {
let def_like = item_to_def_like(doc, def_id, self.cdata.cnum); let def_like = item_to_def_like(doc, def_id, self.cdata.cnum);
match def_like { match def_like {
dl_def(def) => { DlDef(def) => {
debug!("(iterating over each item of a module) processing \ debug!("(iterating over each item of a module) processing \
`%s` (def %?)", `%s` (def %?)",
*self.path_builder, *self.path_builder,
@ -703,10 +703,10 @@ impl<'self> EachItemContext<'self> {
} }
fn each_child_of_item_or_crate(intr: @ident_interner, fn each_child_of_item_or_crate(intr: @ident_interner,
cdata: cmd, cdata: Cmd,
item_doc: ebml::Doc, item_doc: ebml::Doc,
get_crate_data: GetCrateDataCb, get_crate_data: GetCrateDataCb,
callback: &fn(def_like, ast::ident)) { callback: &fn(DefLike, ast::ident)) {
// Iterate over all children. // Iterate over all children.
let _ = do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| { let _ = do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| {
let child_def_id = reader::with_doc_data(child_info_doc, let child_def_id = reader::with_doc_data(child_info_doc,
@ -826,10 +826,10 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
/// Iterates over each child of the given item. /// Iterates over each child of the given item.
pub fn each_child_of_item(intr: @ident_interner, pub fn each_child_of_item(intr: @ident_interner,
cdata: cmd, cdata: Cmd,
id: ast::NodeId, id: ast::NodeId,
get_crate_data: GetCrateDataCb, get_crate_data: GetCrateDataCb,
callback: &fn(def_like, ast::ident)) { callback: &fn(DefLike, ast::ident)) {
// Find the item. // Find the item.
let root_doc = reader::Doc(cdata.data); let root_doc = reader::Doc(cdata.data);
let items = reader::get_doc(root_doc, tag_items); let items = reader::get_doc(root_doc, tag_items);
@ -847,9 +847,9 @@ pub fn each_child_of_item(intr: @ident_interner,
/// Iterates over all the top-level crate items. /// Iterates over all the top-level crate items.
pub fn each_top_level_item_of_crate(intr: @ident_interner, pub fn each_top_level_item_of_crate(intr: @ident_interner,
cdata: cmd, cdata: Cmd,
get_crate_data: GetCrateDataCb, get_crate_data: GetCrateDataCb,
callback: &fn(def_like, ast::ident)) { callback: &fn(DefLike, ast::ident)) {
let root_doc = reader::Doc(cdata.data); let root_doc = reader::Doc(cdata.data);
let misc_info_doc = reader::get_doc(root_doc, tag_misc_info); let misc_info_doc = reader::get_doc(root_doc, tag_misc_info);
let crate_items_doc = reader::get_doc(misc_info_doc, let crate_items_doc = reader::get_doc(misc_info_doc,
@ -862,7 +862,7 @@ pub fn each_top_level_item_of_crate(intr: @ident_interner,
callback) callback)
} }
pub fn get_item_path(cdata: cmd, id: ast::NodeId) -> ast_map::path { pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> ast_map::path {
item_path(lookup_item(id, cdata.data)) item_path(lookup_item(id, cdata.data))
} }
@ -872,7 +872,7 @@ pub type decode_inlined_item<'self> = &'self fn(
path: ast_map::path, path: ast_map::path,
par_doc: ebml::Doc) -> Option<ast::inlined_item>; par_doc: ebml::Doc) -> Option<ast::inlined_item>;
pub fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt, pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt,
id: ast::NodeId, id: ast::NodeId,
decode_inlined_item: decode_inlined_item) decode_inlined_item: decode_inlined_item)
-> csearch::found_ast { -> csearch::found_ast {
@ -900,7 +900,7 @@ pub fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
} }
} }
pub fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::NodeId, pub fn get_enum_variants(intr: @ident_interner, cdata: Cmd, id: ast::NodeId,
tcx: ty::ctxt) -> ~[@ty::VariantInfo] { tcx: ty::ctxt) -> ~[@ty::VariantInfo] {
let data = cdata.data; let data = cdata.data;
let items = reader::get_doc(reader::Doc(data), tag_items); let items = reader::get_doc(reader::Doc(data), tag_items);
@ -964,7 +964,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
} }
} }
fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, fn item_impl_methods(intr: @ident_interner, cdata: Cmd, item: ebml::Doc,
tcx: ty::ctxt) -> ~[@ty::Method] { tcx: ty::ctxt) -> ~[@ty::Method] {
let mut rslt = ~[]; let mut rslt = ~[];
do reader::tagged_docs(item, tag_item_impl_method) |doc| { do reader::tagged_docs(item, tag_item_impl_method) |doc| {
@ -977,7 +977,7 @@ fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc,
} }
/// Returns information about the given implementation. /// Returns information about the given implementation.
pub fn get_impl(intr: @ident_interner, cdata: cmd, impl_id: ast::NodeId, pub fn get_impl(intr: @ident_interner, cdata: Cmd, impl_id: ast::NodeId,
tcx: ty::ctxt) tcx: ty::ctxt)
-> ty::Impl { -> ty::Impl {
let data = cdata.data; let data = cdata.data;
@ -994,7 +994,7 @@ pub fn get_impl(intr: @ident_interner, cdata: cmd, impl_id: ast::NodeId,
pub fn get_method_name_and_explicit_self( pub fn get_method_name_and_explicit_self(
intr: @ident_interner, intr: @ident_interner,
cdata: cmd, cdata: Cmd,
id: ast::NodeId) -> (ast::ident, ast::explicit_self_) id: ast::NodeId) -> (ast::ident, ast::explicit_self_)
{ {
let method_doc = lookup_item(id, cdata.data); let method_doc = lookup_item(id, cdata.data);
@ -1003,7 +1003,7 @@ pub fn get_method_name_and_explicit_self(
(name, explicit_self) (name, explicit_self)
} }
pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::NodeId, pub fn get_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId,
tcx: ty::ctxt) -> ty::Method tcx: ty::ctxt) -> ty::Method
{ {
let method_doc = lookup_item(id, cdata.data); let method_doc = lookup_item(id, cdata.data);
@ -1042,7 +1042,7 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::NodeId,
) )
} }
pub fn get_trait_method_def_ids(cdata: cmd, pub fn get_trait_method_def_ids(cdata: Cmd,
id: ast::NodeId) -> ~[ast::def_id] { id: ast::NodeId) -> ~[ast::def_id] {
let data = cdata.data; let data = cdata.data;
let item = lookup_item(id, data); let item = lookup_item(id, data);
@ -1054,7 +1054,7 @@ pub fn get_trait_method_def_ids(cdata: cmd,
result result
} }
pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd, pub fn get_provided_trait_methods(intr: @ident_interner, cdata: Cmd,
id: ast::NodeId, tcx: ty::ctxt) -> id: ast::NodeId, tcx: ty::ctxt) ->
~[@ty::Method] { ~[@ty::Method] {
let data = cdata.data; let data = cdata.data;
@ -1075,7 +1075,7 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
} }
/// Returns the supertraits of the given trait. /// Returns the supertraits of the given trait.
pub fn get_supertraits(cdata: cmd, id: ast::NodeId, tcx: ty::ctxt) pub fn get_supertraits(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt)
-> ~[@ty::TraitRef] { -> ~[@ty::TraitRef] {
let mut results = ~[]; let mut results = ~[];
let item_doc = lookup_item(id, cdata.data); let item_doc = lookup_item(id, cdata.data);
@ -1092,7 +1092,7 @@ pub fn get_supertraits(cdata: cmd, id: ast::NodeId, tcx: ty::ctxt)
return results; return results;
} }
pub fn get_type_name_if_impl(cdata: cmd, pub fn get_type_name_if_impl(cdata: Cmd,
node_id: ast::NodeId) -> Option<ast::ident> { node_id: ast::NodeId) -> Option<ast::ident> {
let item = lookup_item(node_id, cdata.data); let item = lookup_item(node_id, cdata.data);
if item_family(item) != Impl { if item_family(item) != Impl {
@ -1109,7 +1109,7 @@ pub fn get_type_name_if_impl(cdata: cmd,
} }
pub fn get_static_methods_if_impl(intr: @ident_interner, pub fn get_static_methods_if_impl(intr: @ident_interner,
cdata: cmd, cdata: Cmd,
node_id: ast::NodeId) node_id: ast::NodeId)
-> Option<~[StaticMethodInfo]> { -> Option<~[StaticMethodInfo]> {
let item = lookup_item(node_id, cdata.data); let item = lookup_item(node_id, cdata.data);
@ -1156,7 +1156,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
return Some(static_impl_methods); return Some(static_impl_methods);
} }
pub fn get_item_attrs(cdata: cmd, pub fn get_item_attrs(cdata: Cmd,
node_id: ast::NodeId, node_id: ast::NodeId,
f: &fn(~[@ast::MetaItem])) { f: &fn(~[@ast::MetaItem])) {
@ -1179,7 +1179,7 @@ fn struct_field_family_to_visibility(family: Family) -> ast::visibility {
} }
} }
pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::NodeId) pub fn get_struct_fields(intr: @ident_interner, cdata: Cmd, id: ast::NodeId)
-> ~[ty::field_ty] { -> ~[ty::field_ty] {
let data = cdata.data; let data = cdata.data;
let item = lookup_item(id, data); let item = lookup_item(id, data);
@ -1209,7 +1209,7 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::NodeId)
result result
} }
pub fn get_item_visibility(cdata: cmd, id: ast::NodeId) pub fn get_item_visibility(cdata: Cmd, id: ast::NodeId)
-> ast::visibility { -> ast::visibility {
item_visibility(lookup_item(id, cdata.data)) item_visibility(lookup_item(id, cdata.data))
} }
@ -1308,7 +1308,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::Attribute] {
assert_eq!(meta_items.len(), 1u); assert_eq!(meta_items.len(), 1u);
let meta_item = meta_items[0]; let meta_item = meta_items[0];
attrs.push( attrs.push(
codemap::spanned { codemap::Spanned {
node: ast::Attribute_ { node: ast::Attribute_ {
style: ast::AttrOuter, style: ast::AttrOuter,
value: meta_item, value: meta_item,
@ -1350,15 +1350,15 @@ pub fn get_crate_attributes(data: @~[u8]) -> ~[ast::Attribute] {
} }
#[deriving(Clone)] #[deriving(Clone)]
pub struct crate_dep { pub struct CrateDep {
cnum: ast::CrateNum, cnum: ast::CrateNum,
name: ast::ident, name: ast::ident,
vers: @str, vers: @str,
hash: @str hash: @str
} }
pub fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] { pub fn get_crate_deps(data: @~[u8]) -> ~[CrateDep] {
let mut deps: ~[crate_dep] = ~[]; let mut deps: ~[CrateDep] = ~[];
let cratedoc = reader::Doc(data); let cratedoc = reader::Doc(data);
let depsdoc = reader::get_doc(cratedoc, tag_crate_deps); let depsdoc = reader::get_doc(cratedoc, tag_crate_deps);
let mut crate_num = 1; let mut crate_num = 1;
@ -1367,7 +1367,7 @@ pub fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] {
d.as_str_slice().to_managed() d.as_str_slice().to_managed()
} }
do reader::tagged_docs(depsdoc, tag_crate_dep) |depdoc| { do reader::tagged_docs(depsdoc, tag_crate_dep) |depdoc| {
deps.push(crate_dep {cnum: crate_num, deps.push(CrateDep {cnum: crate_num,
name: token::str_to_ident(docstr(depdoc, tag_crate_dep_name)), name: token::str_to_ident(docstr(depdoc, tag_crate_dep_name)),
vers: docstr(depdoc, tag_crate_dep_vers), vers: docstr(depdoc, tag_crate_dep_vers),
hash: docstr(depdoc, tag_crate_dep_hash)}); hash: docstr(depdoc, tag_crate_dep_hash)});
@ -1419,7 +1419,7 @@ pub fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8],
// external crates - if those types further refer to types in other crates // external crates - if those types further refer to types in other crates
// then we must translate the crate number from that encoded in the external // then we must translate the crate number from that encoded in the external
// crate to the correct local crate number. // crate to the correct local crate number.
pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { pub fn translate_def_id(cdata: Cmd, did: ast::def_id) -> ast::def_id {
if did.crate == ast::LOCAL_CRATE { if did.crate == ast::LOCAL_CRATE {
return ast::def_id { crate: cdata.cnum, node: did.node }; return ast::def_id { crate: cdata.cnum, node: did.node };
} }
@ -1430,7 +1430,7 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
} }
} }
pub fn get_link_args_for_crate(cdata: cmd) -> ~[~str] { pub fn get_link_args_for_crate(cdata: Cmd) -> ~[~str] {
let link_args = reader::get_doc(reader::Doc(cdata.data), tag_link_args); let link_args = reader::get_doc(reader::Doc(cdata.data), tag_link_args);
let mut result = ~[]; let mut result = ~[];
do reader::tagged_docs(link_args, tag_link_args_arg) |arg_doc| { do reader::tagged_docs(link_args, tag_link_args_arg) |arg_doc| {
@ -1440,7 +1440,7 @@ pub fn get_link_args_for_crate(cdata: cmd) -> ~[~str] {
result result
} }
pub fn each_impl(cdata: cmd, callback: &fn(ast::def_id)) { pub fn each_impl(cdata: Cmd, callback: &fn(ast::def_id)) {
let impls_doc = reader::get_doc(reader::Doc(cdata.data), tag_impls); let impls_doc = reader::get_doc(reader::Doc(cdata.data), tag_impls);
let _ = do reader::tagged_docs(impls_doc, tag_impls_impl) |impl_doc| { let _ = do reader::tagged_docs(impls_doc, tag_impls_impl) |impl_doc| {
callback(item_def_id(impl_doc, cdata)); callback(item_def_id(impl_doc, cdata));
@ -1448,7 +1448,7 @@ pub fn each_impl(cdata: cmd, callback: &fn(ast::def_id)) {
}; };
} }
pub fn each_implementation_for_type(cdata: cmd, pub fn each_implementation_for_type(cdata: Cmd,
id: ast::NodeId, id: ast::NodeId,
callback: &fn(ast::def_id)) { callback: &fn(ast::def_id)) {
let item_doc = lookup_item(id, cdata.data); let item_doc = lookup_item(id, cdata.data);
@ -1460,7 +1460,7 @@ pub fn each_implementation_for_type(cdata: cmd,
}; };
} }
pub fn each_implementation_for_trait(cdata: cmd, pub fn each_implementation_for_trait(cdata: Cmd,
id: ast::NodeId, id: ast::NodeId,
callback: &fn(ast::def_id)) { callback: &fn(ast::def_id)) {
let item_doc = lookup_item(id, cdata.data); let item_doc = lookup_item(id, cdata.data);
@ -1474,7 +1474,7 @@ pub fn each_implementation_for_trait(cdata: cmd,
}; };
} }
pub fn get_trait_of_method(cdata: cmd, id: ast::NodeId, tcx: ty::ctxt) pub fn get_trait_of_method(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt)
-> Option<ast::def_id> { -> Option<ast::def_id> {
let item_doc = lookup_item(id, cdata.data); let item_doc = lookup_item(id, cdata.data);
let parent_item_id = match item_parent_item(item_doc) { let parent_item_id = match item_parent_item(item_doc) {

View File

@ -1488,13 +1488,13 @@ fn encode_crate_deps(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder, ebml_w: &mut writer::Encoder,
cstore: &cstore::CStore) { cstore: &cstore::CStore) {
fn get_ordered_deps(ecx: &EncodeContext, cstore: &cstore::CStore) fn get_ordered_deps(ecx: &EncodeContext, cstore: &cstore::CStore)
-> ~[decoder::crate_dep] { -> ~[decoder::CrateDep] {
type numdep = decoder::crate_dep; type numdep = decoder::CrateDep;
// Pull the cnums and name,vers,hash out of cstore // Pull the cnums and name,vers,hash out of cstore
let mut deps = ~[]; let mut deps = ~[];
do cstore::iter_crate_data(cstore) |key, val| { do cstore::iter_crate_data(cstore) |key, val| {
let dep = decoder::crate_dep {cnum: key, let dep = decoder::CrateDep {cnum: key,
name: ecx.tcx.sess.ident_of(val.name), name: ecx.tcx.sess.ident_of(val.name),
vers: decoder::get_crate_vers(val.data), vers: decoder::get_crate_vers(val.data),
hash: decoder::get_crate_hash(val.data)}; hash: decoder::get_crate_hash(val.data)};
@ -1645,7 +1645,7 @@ fn encode_misc_info(ecx: &EncodeContext,
fn encode_crate_dep(ecx: &EncodeContext, fn encode_crate_dep(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder, ebml_w: &mut writer::Encoder,
dep: decoder::crate_dep) { dep: decoder::CrateDep) {
ebml_w.start_tag(tag_crate_dep); ebml_w.start_tag(tag_crate_dep);
ebml_w.start_tag(tag_crate_dep_name); ebml_w.start_tag(tag_crate_dep_name);
let s = ecx.tcx.sess.str_of(dep.name); let s = ecx.tcx.sess.str_of(dep.name);

View File

@ -16,7 +16,7 @@ use metadata::decoder;
use metadata::encoder; use metadata::encoder;
use metadata::filesearch::{FileSearch, FileMatch, FileMatches, FileDoesntMatch}; use metadata::filesearch::{FileSearch, FileMatch, FileMatches, FileDoesntMatch};
use metadata::filesearch; use metadata::filesearch;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::diagnostic::span_handler; use syntax::diagnostic::span_handler;
use syntax::parse::token::ident_interner; use syntax::parse::token::ident_interner;
use syntax::print::pprust; use syntax::print::pprust;
@ -34,22 +34,22 @@ use std::str;
use std::vec; use std::vec;
use extra::flate; use extra::flate;
pub enum os { pub enum Os {
os_macos, OsMacos,
os_win32, OsWin32,
os_linux, OsLinux,
os_android, OsAndroid,
os_freebsd OsFreebsd
} }
pub struct Context { pub struct Context {
diag: @mut span_handler, diag: @mut span_handler,
filesearch: @FileSearch, filesearch: @FileSearch,
span: span, span: Span,
ident: @str, ident: @str,
metas: ~[@ast::MetaItem], metas: ~[@ast::MetaItem],
hash: @str, hash: @str,
os: os, os: Os,
is_static: bool, is_static: bool,
intr: @ident_interner intr: @ident_interner
} }
@ -73,11 +73,11 @@ fn find_library_crate(cx: &Context) -> Option<(~str, @~[u8])> {
fn libname(cx: &Context) -> (~str, ~str) { fn libname(cx: &Context) -> (~str, ~str) {
if cx.is_static { return (~"lib", ~".rlib"); } if cx.is_static { return (~"lib", ~".rlib"); }
let (dll_prefix, dll_suffix) = match cx.os { let (dll_prefix, dll_suffix) = match cx.os {
os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX), OsWin32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX), OsMacos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
os_linux => (linux::DLL_PREFIX, linux::DLL_SUFFIX), OsLinux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
os_android => (android::DLL_PREFIX, android::DLL_SUFFIX), OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX), OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
}; };
(dll_prefix.to_owned(), dll_suffix.to_owned()) (dll_prefix.to_owned(), dll_suffix.to_owned())
@ -196,7 +196,7 @@ pub fn metadata_matches(extern_metas: &[@ast::MetaItem],
} }
} }
fn get_metadata_section(os: os, fn get_metadata_section(os: Os,
filename: &Path) -> Option<@~[u8]> { filename: &Path) -> Option<@~[u8]> {
unsafe { unsafe {
let mb = do filename.with_c_str |buf| { let mb = do filename.with_c_str |buf| {
@ -212,7 +212,7 @@ fn get_metadata_section(os: os,
let name_buf = llvm::LLVMGetSectionName(si.llsi); let name_buf = llvm::LLVMGetSectionName(si.llsi);
let name = str::raw::from_c_str(name_buf); let name = str::raw::from_c_str(name_buf);
debug!("get_metadata_section: name %s", name); debug!("get_metadata_section: name %s", name);
if name == read_meta_section_name(os) { if read_meta_section_name(os) == name {
let cbuf = llvm::LLVMGetSectionContents(si.llsi); let cbuf = llvm::LLVMGetSectionContents(si.llsi);
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint; let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
let mut found = None; let mut found = None;
@ -245,29 +245,29 @@ fn get_metadata_section(os: os,
} }
} }
pub fn meta_section_name(os: os) -> ~str { pub fn meta_section_name(os: Os) -> &'static str {
match os { match os {
os_macos => ~"__DATA,__note.rustc", OsMacos => "__DATA,__note.rustc",
os_win32 => ~".note.rustc", OsWin32 => ".note.rustc",
os_linux => ~".note.rustc", OsLinux => ".note.rustc",
os_android => ~".note.rustc", OsAndroid => ".note.rustc",
os_freebsd => ~".note.rustc" OsFreebsd => ".note.rustc"
} }
} }
pub fn read_meta_section_name(os: os) -> ~str { pub fn read_meta_section_name(os: Os) -> &'static str {
match os { match os {
os_macos => ~"__note.rustc", OsMacos => "__note.rustc",
os_win32 => ~".note.rustc", OsWin32 => ".note.rustc",
os_linux => ~".note.rustc", OsLinux => ".note.rustc",
os_android => ~".note.rustc", OsAndroid => ".note.rustc",
os_freebsd => ~".note.rustc" OsFreebsd => ".note.rustc"
} }
} }
// A diagnostic function for dumping crate metadata to an output stream // A diagnostic function for dumping crate metadata to an output stream
pub fn list_file_metadata(intr: @ident_interner, pub fn list_file_metadata(intr: @ident_interner,
os: os, os: Os,
path: &Path, path: &Path,
out: @io::Writer) { out: @io::Writer) {
match get_metadata_section(os, path) { match get_metadata_section(os, path) {

View File

@ -33,7 +33,7 @@ use syntax::ast;
use syntax::ast_map; use syntax::ast_map;
use syntax::ast_util::inlined_item_utils; use syntax::ast_util::inlined_item_utils;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::codemap; use syntax::codemap;
use syntax::fold::*; use syntax::fold::*;
use syntax::fold; use syntax::fold;
@ -214,7 +214,7 @@ impl ExtendedDecodeContext {
assert_eq!(did.crate, ast::LOCAL_CRATE); assert_eq!(did.crate, ast::LOCAL_CRATE);
ast::def_id { crate: ast::LOCAL_CRATE, node: self.tr_id(did.node) } ast::def_id { crate: ast::LOCAL_CRATE, node: self.tr_id(did.node) }
} }
pub fn tr_span(&self, _span: span) -> span { pub fn tr_span(&self, _span: Span) -> Span {
codemap::dummy_sp() // FIXME (#1972): handle span properly codemap::dummy_sp() // FIXME (#1972): handle span properly
} }
} }
@ -231,8 +231,8 @@ impl tr for ast::def_id {
} }
} }
impl tr for span { impl tr for Span {
fn tr(&self, xcx: @ExtendedDecodeContext) -> span { fn tr(&self, xcx: @ExtendedDecodeContext) -> Span {
xcx.tr_span(*self) xcx.tr_span(*self)
} }
} }
@ -302,9 +302,9 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
let stmts_sans_items = do blk.stmts.iter().filter_map |stmt| { let stmts_sans_items = do blk.stmts.iter().filter_map |stmt| {
match stmt.node { match stmt.node {
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) | ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_), span: _}, _) ast::stmt_decl(@codemap::Spanned { node: ast::decl_local(_), span: _}, _)
=> Some(*stmt), => Some(*stmt),
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_), span: _}, _) ast::stmt_decl(@codemap::Spanned { node: ast::decl_item(_), span: _}, _)
=> None, => None,
ast::stmt_mac(*) => fail!("unexpanded macro in astencode") ast::stmt_mac(*) => fail!("unexpanded macro in astencode")
} }
@ -1255,7 +1255,7 @@ fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
trait fake_ext_ctxt { trait fake_ext_ctxt {
fn cfg(&self) -> ast::CrateConfig; fn cfg(&self) -> ast::CrateConfig;
fn parse_sess(&self) -> @mut parse::ParseSess; fn parse_sess(&self) -> @mut parse::ParseSess;
fn call_site(&self) -> span; fn call_site(&self) -> Span;
fn ident_of(&self, st: &str) -> ast::ident; fn ident_of(&self, st: &str) -> ast::ident;
} }
@ -1266,8 +1266,8 @@ type fake_session = @mut parse::ParseSess;
impl fake_ext_ctxt for fake_session { impl fake_ext_ctxt for fake_session {
fn cfg(&self) -> ast::CrateConfig { ~[] } fn cfg(&self) -> ast::CrateConfig { ~[] }
fn parse_sess(&self) -> @mut parse::ParseSess { *self } fn parse_sess(&self) -> @mut parse::ParseSess { *self }
fn call_site(&self) -> span { fn call_site(&self) -> Span {
codemap::span { codemap::Span {
lo: codemap::BytePos(0), lo: codemap::BytePos(0),
hi: codemap::BytePos(0), hi: codemap::BytePos(0),
expn_info: None expn_info: None

View File

@ -26,7 +26,7 @@ use middle::ty;
use syntax::ast::{m_imm, m_mutbl}; use syntax::ast::{m_imm, m_mutbl};
use syntax::ast; use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::visit::Visitor; use syntax::visit::Visitor;
use syntax::visit; use syntax::visit;
use util::ppaux::Repr; use util::ppaux::Repr;
@ -56,7 +56,7 @@ impl<'self> Visitor<CheckLoanCtxt<'self>> for CheckLoanVisitor {
check_loans_in_pat(self, p, e); check_loans_in_pat(self, p, e);
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:CheckLoanCtxt) { b:&ast::Block, s:Span, n:ast::NodeId, e:CheckLoanCtxt) {
check_loans_in_fn(self, fk, fd, b, s, n, e); check_loans_in_fn(self, fk, fd, b, s, n, e);
} }
} }
@ -82,7 +82,7 @@ pub fn check_loans(bccx: @BorrowckCtxt,
enum MoveError { enum MoveError {
MoveOk, MoveOk,
MoveWhileBorrowed(/*loan*/@LoanPath, /*loan*/span) MoveWhileBorrowed(/*loan*/@LoanPath, /*loan*/Span)
} }
impl<'self> CheckLoanCtxt<'self> { impl<'self> CheckLoanCtxt<'self> {
@ -107,7 +107,7 @@ impl<'self> CheckLoanCtxt<'self> {
} }
} }
fn check_captured_variables(&self, closure_id: ast::NodeId, span: span) { fn check_captured_variables(&self, closure_id: ast::NodeId, span: Span) {
let cap_vars = self.bccx.capture_map.get(&closure_id); let cap_vars = self.bccx.capture_map.get(&closure_id);
for cap_var in cap_vars.iter() { for cap_var in cap_vars.iter() {
let var_id = ast_util::def_id_of_def(cap_var.def).node; let var_id = ast_util::def_id_of_def(cap_var.def).node;
@ -311,7 +311,7 @@ impl<'self> CheckLoanCtxt<'self> {
pub fn check_if_path_is_moved(&self, pub fn check_if_path_is_moved(&self,
id: ast::NodeId, id: ast::NodeId,
span: span, span: Span,
use_kind: MovedValueUseKind, use_kind: MovedValueUseKind,
lp: @LoanPath) { lp: @LoanPath) {
/*! /*!
@ -669,7 +669,7 @@ impl<'self> CheckLoanCtxt<'self> {
} }
} }
fn check_move_out_from_id(&self, id: ast::NodeId, span: span) { fn check_move_out_from_id(&self, id: ast::NodeId, span: Span) {
do self.move_data.each_path_moved_by(id) |_, move_path| { do self.move_data.each_path_moved_by(id) |_, move_path| {
match self.analyze_move_out_from(id, move_path) { match self.analyze_move_out_from(id, move_path) {
MoveOk => {} MoveOk => {}
@ -713,7 +713,7 @@ impl<'self> CheckLoanCtxt<'self> {
_expr: @ast::expr, _expr: @ast::expr,
_callee: Option<@ast::expr>, _callee: Option<@ast::expr>,
_callee_id: ast::NodeId, _callee_id: ast::NodeId,
_callee_span: span, _callee_span: Span,
_args: &[@ast::expr]) { _args: &[@ast::expr]) {
// NB: This call to check for conflicting loans is not truly // NB: This call to check for conflicting loans is not truly
// necessary, because the callee_id never issues new loans. // necessary, because the callee_id never issues new loans.
@ -729,7 +729,7 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &ast::fn_decl, decl: &ast::fn_decl,
body: &ast::Block, body: &ast::Block,
sp: span, sp: Span,
id: ast::NodeId, id: ast::NodeId,
this: CheckLoanCtxt<'a>) { this: CheckLoanCtxt<'a>) {
match *fk { match *fk {
@ -749,7 +749,7 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
fn check_captured_variables(this: CheckLoanCtxt, fn check_captured_variables(this: CheckLoanCtxt,
closure_id: ast::NodeId, closure_id: ast::NodeId,
span: span) { span: Span) {
let cap_vars = this.bccx.capture_map.get(&closure_id); let cap_vars = this.bccx.capture_map.get(&closure_id);
for cap_var in cap_vars.iter() { for cap_var in cap_vars.iter() {
let var_id = ast_util::def_id_of_def(cap_var.def).node; let var_id = ast_util::def_id_of_def(cap_var.def).node;

View File

@ -19,13 +19,13 @@ use middle::moves;
use middle::ty; use middle::ty;
use syntax::ast; use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
use util::ppaux::{UserString}; use util::ppaux::{UserString};
pub fn gather_decl(bccx: @BorrowckCtxt, pub fn gather_decl(bccx: @BorrowckCtxt,
move_data: &mut MoveData, move_data: &mut MoveData,
decl_id: ast::NodeId, decl_id: ast::NodeId,
_decl_span: span, _decl_span: Span,
var_id: ast::NodeId) { var_id: ast::NodeId) {
let loan_path = @LpVar(var_id); let loan_path = @LpVar(var_id);
move_data.add_move(bccx.tcx, loan_path, decl_id, Declared); move_data.add_move(bccx.tcx, loan_path, decl_id, Declared);
@ -86,7 +86,7 @@ pub fn gather_captures(bccx: @BorrowckCtxt,
pub fn gather_assignment(bccx: @BorrowckCtxt, pub fn gather_assignment(bccx: @BorrowckCtxt,
move_data: &mut MoveData, move_data: &mut MoveData,
assignment_id: ast::NodeId, assignment_id: ast::NodeId,
assignment_span: span, assignment_span: Span,
assignee_loan_path: @LoanPath, assignee_loan_path: @LoanPath,
assignee_id: ast::NodeId) { assignee_id: ast::NodeId) {
move_data.add_assignment(bccx.tcx, move_data.add_assignment(bccx.tcx,

View File

@ -17,13 +17,13 @@ use mc = middle::mem_categorization;
use middle::ty; use middle::ty;
use syntax::ast::{m_imm, m_mutbl}; use syntax::ast::{m_imm, m_mutbl};
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use util::ppaux::{note_and_explain_region}; use util::ppaux::{note_and_explain_region};
pub fn guarantee_lifetime(bccx: @BorrowckCtxt, pub fn guarantee_lifetime(bccx: @BorrowckCtxt,
item_scope_id: ast::NodeId, item_scope_id: ast::NodeId,
root_scope_id: ast::NodeId, root_scope_id: ast::NodeId,
span: span, span: Span,
cmt: mc::cmt, cmt: mc::cmt,
loan_region: ty::Region, loan_region: ty::Region,
loan_mutbl: LoanMutability) { loan_mutbl: LoanMutability) {
@ -52,7 +52,7 @@ struct GuaranteeLifetimeContext {
// longest scope for which we can root managed boxes // longest scope for which we can root managed boxes
root_scope_id: ast::NodeId, root_scope_id: ast::NodeId,
span: span, span: Span,
loan_region: ty::Region, loan_region: ty::Region,
loan_mutbl: LoanMutability, loan_mutbl: LoanMutability,
cmt_original: mc::cmt cmt_original: mc::cmt

View File

@ -28,7 +28,7 @@ use util::ppaux::{Repr};
use syntax::ast; use syntax::ast;
use syntax::ast_util::id_range; use syntax::ast_util::id_range;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::print::pprust; use syntax::print::pprust;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -83,7 +83,7 @@ impl visit::Visitor<@mut GatherLoanCtxt> for GatherLoanVisitor {
gather_loans_in_block(self, b, e); gather_loans_in_block(self, b, e);
} }
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block,
s:span, n:NodeId, e:@mut GatherLoanCtxt) { s:Span, n:NodeId, e:@mut GatherLoanCtxt) {
gather_loans_in_fn(self, fk, fd, b, s, n, e); gather_loans_in_fn(self, fk, fd, b, s, n, e);
} }
fn visit_stmt(&mut self, s:@stmt, e:@mut GatherLoanCtxt) { fn visit_stmt(&mut self, s:@stmt, e:@mut GatherLoanCtxt) {
@ -131,7 +131,7 @@ fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
fk: &fn_kind, fk: &fn_kind,
decl: &ast::fn_decl, decl: &ast::fn_decl,
body: &ast::Block, body: &ast::Block,
sp: span, sp: Span,
id: ast::NodeId, id: ast::NodeId,
this: @mut GatherLoanCtxt) { this: @mut GatherLoanCtxt) {
match fk { match fk {
@ -413,7 +413,7 @@ impl GatherLoanCtxt {
// dynamically that they are not freed. // dynamically that they are not freed.
pub fn guarantee_valid(&mut self, pub fn guarantee_valid(&mut self,
borrow_id: ast::NodeId, borrow_id: ast::NodeId,
borrow_span: span, borrow_span: Span,
cmt: mc::cmt, cmt: mc::cmt,
req_mutbl: LoanMutability, req_mutbl: LoanMutability,
loan_region: ty::Region) { loan_region: ty::Region) {
@ -538,7 +538,7 @@ impl GatherLoanCtxt {
// } // }
fn check_mutability(bccx: @BorrowckCtxt, fn check_mutability(bccx: @BorrowckCtxt,
borrow_span: span, borrow_span: Span,
cmt: mc::cmt, cmt: mc::cmt,
req_mutbl: LoanMutability) { req_mutbl: LoanMutability) {
//! Implements the M-* rules in doc.rs. //! Implements the M-* rules in doc.rs.

View File

@ -16,7 +16,7 @@ use middle::borrowck::*;
use mc = middle::mem_categorization; use mc = middle::mem_categorization;
use middle::ty; use middle::ty;
use syntax::ast::{m_imm, m_mutbl}; use syntax::ast::{m_imm, m_mutbl};
use syntax::codemap::span; use syntax::codemap::Span;
pub enum RestrictionResult { pub enum RestrictionResult {
Safe, Safe,
@ -24,7 +24,7 @@ pub enum RestrictionResult {
} }
pub fn compute_restrictions(bccx: @BorrowckCtxt, pub fn compute_restrictions(bccx: @BorrowckCtxt,
span: span, span: Span,
cmt: mc::cmt, cmt: mc::cmt,
restr: RestrictionSet) -> RestrictionResult { restr: RestrictionSet) -> RestrictionResult {
let ctxt = RestrictionsContext { let ctxt = RestrictionsContext {
@ -41,7 +41,7 @@ pub fn compute_restrictions(bccx: @BorrowckCtxt,
struct RestrictionsContext { struct RestrictionsContext {
bccx: @BorrowckCtxt, bccx: @BorrowckCtxt,
span: span, span: Span,
cmt_original: mc::cmt cmt_original: mc::cmt
} }

View File

@ -26,7 +26,7 @@ use std::ops::{BitOr, BitAnd};
use std::result::{Result}; use std::result::{Result};
use syntax::ast; use syntax::ast;
use syntax::ast_map; use syntax::ast_map;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token; use syntax::parse::token;
use syntax::visit; use syntax::visit;
use syntax::visit::{Visitor,fn_kind}; use syntax::visit::{Visitor,fn_kind};
@ -65,7 +65,7 @@ struct BorrowckVisitor;
impl Visitor<@BorrowckCtxt> for BorrowckVisitor { impl Visitor<@BorrowckCtxt> for BorrowckVisitor {
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl,
b:&Block, s:span, n:NodeId, e:@BorrowckCtxt) { b:&Block, s:Span, n:NodeId, e:@BorrowckCtxt) {
borrowck_fn(self, fk, fd, b, s, n, e); borrowck_fn(self, fk, fd, b, s, n, e);
} }
} }
@ -127,7 +127,7 @@ fn borrowck_fn(v: &mut BorrowckVisitor,
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &ast::fn_decl, decl: &ast::fn_decl,
body: &ast::Block, body: &ast::Block,
sp: span, sp: Span,
id: ast::NodeId, id: ast::NodeId,
this: @BorrowckCtxt) { this: @BorrowckCtxt) {
match fk { match fk {
@ -277,7 +277,7 @@ pub struct Loan {
restrictions: ~[Restriction], restrictions: ~[Restriction],
gen_scope: ast::NodeId, gen_scope: ast::NodeId,
kill_scope: ast::NodeId, kill_scope: ast::NodeId,
span: span, span: Span,
} }
#[deriving(Eq, IterBytes)] #[deriving(Eq, IterBytes)]
@ -454,7 +454,7 @@ pub enum bckerr_code {
// that caused it // that caused it
#[deriving(Eq)] #[deriving(Eq)]
pub struct BckError { pub struct BckError {
span: span, span: Span,
cmt: mc::cmt, cmt: mc::cmt,
code: bckerr_code code: bckerr_code
} }
@ -516,7 +516,7 @@ impl BorrowckCtxt {
pub fn cat_def(&self, pub fn cat_def(&self,
id: ast::NodeId, id: ast::NodeId,
span: span, span: Span,
ty: ty::t, ty: ty::t,
def: ast::def) def: ast::def)
-> mc::cmt { -> mc::cmt {
@ -550,7 +550,7 @@ impl BorrowckCtxt {
} }
pub fn report_use_of_moved_value(&self, pub fn report_use_of_moved_value(&self,
use_span: span, use_span: Span,
use_kind: MovedValueUseKind, use_kind: MovedValueUseKind,
lp: &LoanPath, lp: &LoanPath,
move: &move_data::Move, move: &move_data::Move,
@ -631,7 +631,7 @@ impl BorrowckCtxt {
} }
pub fn report_reassigned_immutable_variable(&self, pub fn report_reassigned_immutable_variable(&self,
span: span, span: Span,
lp: &LoanPath, lp: &LoanPath,
assign: assign:
&move_data::Assignment) { &move_data::Assignment) {
@ -644,11 +644,11 @@ impl BorrowckCtxt {
fmt!("prior assignment occurs here")); fmt!("prior assignment occurs here"));
} }
pub fn span_err(&self, s: span, m: &str) { pub fn span_err(&self, s: Span, m: &str) {
self.tcx.sess.span_err(s, m); self.tcx.sess.span_err(s, m);
} }
pub fn span_note(&self, s: span, m: &str) { pub fn span_note(&self, s: Span, m: &str) {
self.tcx.sess.span_note(s, m); self.tcx.sess.span_note(s, m);
} }
@ -677,7 +677,7 @@ impl BorrowckCtxt {
} }
pub fn report_aliasability_violation(&self, pub fn report_aliasability_violation(&self,
span: span, span: Span,
kind: AliasableViolationKind, kind: AliasableViolationKind,
cause: mc::AliasableReason) { cause: mc::AliasableReason) {
let prefix = match kind { let prefix = match kind {

View File

@ -25,7 +25,7 @@ use middle::ty;
use middle::typeck; use middle::typeck;
use syntax::ast; use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::opt_vec::OptVec; use syntax::opt_vec::OptVec;
use syntax::opt_vec; use syntax::opt_vec;
use util::ppaux::Repr; use util::ppaux::Repr;
@ -135,7 +135,7 @@ pub struct Assignment {
id: ast::NodeId, id: ast::NodeId,
/// span of node where assignment occurs /// span of node where assignment occurs
span: span, span: Span,
} }
pub struct MoveDataFlowOperator; pub struct MoveDataFlowOperator;
@ -327,7 +327,7 @@ impl MoveData {
tcx: ty::ctxt, tcx: ty::ctxt,
lp: @LoanPath, lp: @LoanPath,
assign_id: ast::NodeId, assign_id: ast::NodeId,
span: span, span: Span,
assignee_id: ast::NodeId) { assignee_id: ast::NodeId) {
/*! /*!
* Adds a new record for an assignment to `lp` that occurs at * Adds a new record for an assignment to `lp` that occurs at

View File

@ -85,7 +85,7 @@ pub fn check_pat(v: &mut CheckCrateVisitor, p: @pat, _is_const: bool) {
fn is_str(e: @expr) -> bool { fn is_str(e: @expr) -> bool {
match e.node { match e.node {
expr_vstore( expr_vstore(
@expr { node: expr_lit(@codemap::spanned { @expr { node: expr_lit(@codemap::Spanned {
node: lit_str(_), node: lit_str(_),
_}), _}),
_ }, _ },
@ -120,7 +120,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
"disallowed operator in constant expression"); "disallowed operator in constant expression");
return; return;
} }
expr_lit(@codemap::spanned {node: lit_str(_), _}) => { } expr_lit(@codemap::Spanned {node: lit_str(_), _}) => { }
expr_binary(*) | expr_unary(*) => { expr_binary(*) | expr_unary(*) => {
if method_map.contains_key(&e.id) { if method_map.contains_key(&e.id) {
sess.span_err(e.span, "user-defined operators are not \ sess.span_err(e.span, "user-defined operators are not \
@ -200,7 +200,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
} }
} }
match e.node { match e.node {
expr_lit(@codemap::spanned {node: lit_int(v, t), _}) => { expr_lit(@codemap::Spanned {node: lit_int(v, t), _}) => {
if t != ty_char { if t != ty_char {
if (v as u64) > ast_util::int_ty_max( if (v as u64) > ast_util::int_ty_max(
if t == ty_i { sess.targ_cfg.int_type } else { t }) { if t == ty_i { sess.targ_cfg.int_type } else { t }) {
@ -208,7 +208,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
} }
} }
} }
expr_lit(@codemap::spanned {node: lit_uint(v, t), _}) => { expr_lit(@codemap::Spanned {node: lit_uint(v, t), _}) => {
if v > ast_util::uint_ty_max( if v > ast_util::uint_ty_max(
if t == ty_u { sess.targ_cfg.uint_type } else { t }) { if t == ty_u { sess.targ_cfg.uint_type } else { t }) {
sess.span_err(e.span, "literal out of range for its type"); sess.span_err(e.span, "literal out of range for its type");

View File

@ -24,7 +24,7 @@ use std::vec;
use extra::sort; use extra::sort;
use syntax::ast::*; use syntax::ast::*;
use syntax::ast_util::{unguarded_pat, walk_pat}; use syntax::ast_util::{unguarded_pat, walk_pat};
use syntax::codemap::{span, dummy_sp, spanned}; use syntax::codemap::{Span, dummy_sp, Spanned};
use syntax::visit; use syntax::visit;
use syntax::visit::{Visitor,fn_kind}; use syntax::visit::{Visitor,fn_kind};
@ -45,7 +45,7 @@ impl Visitor<()> for CheckMatchVisitor {
fn visit_local(&mut self, l:@Local, e:()) { fn visit_local(&mut self, l:@Local, e:()) {
check_local(self, self.cx, l, e); check_local(self, self.cx, l, e);
} }
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:span, n:NodeId, e:()) { fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, e:()) {
check_fn(self, self.cx, fk, fd, b, s, n, e); check_fn(self, self.cx, fk, fd, b, s, n, e);
} }
} }
@ -160,7 +160,7 @@ pub fn raw_pat(p: @pat) -> @pat {
} }
} }
pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: span, pats: ~[@pat]) { pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@pat]) {
assert!((!pats.is_empty())); assert!((!pats.is_empty()));
let ext = match is_useful(cx, &pats.map(|p| ~[*p]), [wild()]) { let ext = match is_useful(cx, &pats.map(|p| ~[*p]), [wild()]) {
not_useful => { not_useful => {
@ -821,7 +821,7 @@ pub fn check_fn(v: &mut CheckMatchVisitor,
kind: &visit::fn_kind, kind: &visit::fn_kind,
decl: &fn_decl, decl: &fn_decl,
body: &Block, body: &Block,
sp: span, sp: Span,
id: NodeId, id: NodeId,
s: ()) { s: ()) {
visit::walk_fn(v, kind, decl, body, sp, id, s); visit::walk_fn(v, kind, decl, body, sp, id, s);
@ -850,7 +850,7 @@ pub fn is_refutable(cx: &MatchCheckCtxt, pat: &pat) -> bool {
is_refutable(cx, sub) is_refutable(cx, sub)
} }
pat_wild | pat_ident(_, _, None) => { false } pat_wild | pat_ident(_, _, None) => { false }
pat_lit(@expr {node: expr_lit(@spanned { node: lit_nil, _}), _}) => { pat_lit(@expr {node: expr_lit(@Spanned { node: lit_nil, _}), _}) => {
// "()" // "()"
false false
} }

View File

@ -19,7 +19,7 @@ use util::ppaux;
use syntax::ast::{deref, expr_call, expr_inline_asm, expr_method_call}; use syntax::ast::{deref, expr_call, expr_inline_asm, expr_method_call};
use syntax::ast::{expr_unary, unsafe_fn, expr_path}; use syntax::ast::{expr_unary, unsafe_fn, expr_path};
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::visit::{fk_item_fn, fk_method}; use syntax::visit::{fk_item_fn, fk_method};
use syntax::visit; use syntax::visit;
use syntax::visit::{Visitor,fn_kind}; use syntax::visit::{Visitor,fn_kind};
@ -53,7 +53,7 @@ struct EffectCheckVisitor {
} }
impl EffectCheckVisitor { impl EffectCheckVisitor {
fn require_unsafe(&mut self, span: span, description: &str) { fn require_unsafe(&mut self, span: Span, description: &str) {
match self.context.unsafe_context { match self.context.unsafe_context {
SafeContext => { SafeContext => {
// Report an error. // Report an error.
@ -73,7 +73,7 @@ impl EffectCheckVisitor {
impl Visitor<()> for EffectCheckVisitor { impl Visitor<()> for EffectCheckVisitor {
fn visit_fn(&mut self, fn_kind:&fn_kind, fn_decl:&fn_decl, fn visit_fn(&mut self, fn_kind:&fn_kind, fn_decl:&fn_decl,
block:&Block, span:span, node_id:NodeId, _:()) { block:&Block, span:Span, node_id:NodeId, _:()) {
let (is_item_fn, is_unsafe_fn) = match *fn_kind { let (is_item_fn, is_unsafe_fn) = match *fn_kind {
fk_item_fn(_, _, purity, _) => (true, purity == unsafe_fn), fk_item_fn(_, _, purity, _) => (true, purity == unsafe_fn),

View File

@ -14,7 +14,7 @@ use driver::session::Session;
use syntax::ast::{Crate, NodeId, item, item_fn}; use syntax::ast::{Crate, NodeId, item, item_fn};
use syntax::ast_map; use syntax::ast_map;
use syntax::attr; use syntax::attr;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -26,17 +26,17 @@ struct EntryContext {
ast_map: ast_map::map, ast_map: ast_map::map,
// The top-level function called 'main' // The top-level function called 'main'
main_fn: Option<(NodeId, span)>, main_fn: Option<(NodeId, Span)>,
// The function that has attribute named 'main' // The function that has attribute named 'main'
attr_main_fn: Option<(NodeId, span)>, attr_main_fn: Option<(NodeId, Span)>,
// The function that has the attribute 'start' on it // The function that has the attribute 'start' on it
start_fn: Option<(NodeId, span)>, start_fn: Option<(NodeId, Span)>,
// The functions that one might think are 'main' but aren't, e.g. // The functions that one might think are 'main' but aren't, e.g.
// main functions not defined at the top level. For diagnostics. // main functions not defined at the top level. For diagnostics.
non_main_fns: ~[(NodeId, span)], non_main_fns: ~[(NodeId, Span)],
} }
struct EntryVisitor; struct EntryVisitor;
@ -51,7 +51,7 @@ pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map)
// FIXME #4404 android JNI hacks // FIXME #4404 android JNI hacks
if *session.building_library && if *session.building_library &&
session.targ_cfg.os != session::os_android { session.targ_cfg.os != session::OsAndroid {
// No need to find a main function // No need to find a main function
return; return;
} }
@ -157,7 +157,7 @@ fn configure_main(ctxt: @mut EntryContext) {
} else { } else {
// If we *are* building a library, then we're on android where we still might // If we *are* building a library, then we're on android where we still might
// optionally want to translate main $4404 // optionally want to translate main $4404
assert_eq!(this.session.targ_cfg.os, session::os_android); assert_eq!(this.session.targ_cfg.os, session::OsAndroid);
} }
} }
} }

View File

@ -16,7 +16,7 @@ use middle::resolve;
use middle::ty; use middle::ty;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::{ast, ast_util}; use syntax::{ast, ast_util};
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -27,7 +27,7 @@ use syntax::ast::{item};
#[deriving(Encodable, Decodable)] #[deriving(Encodable, Decodable)]
pub struct freevar_entry { pub struct freevar_entry {
def: ast::def, //< The variable being accessed free. def: ast::def, //< The variable being accessed free.
span: span //< First span where it is accessed (there can be multiple) span: Span //< First span where it is accessed (there can be multiple)
} }
pub type freevar_info = @~[@freevar_entry]; pub type freevar_info = @~[@freevar_entry];
pub type freevar_map = @mut HashMap<ast::NodeId, freevar_info>; pub type freevar_map = @mut HashMap<ast::NodeId, freevar_info>;
@ -110,7 +110,7 @@ struct AnnotateFreevarsVisitor {
impl Visitor<()> for AnnotateFreevarsVisitor { impl Visitor<()> for AnnotateFreevarsVisitor {
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
blk:&ast::Block, s:span, nid:ast::NodeId, _:()) { blk:&ast::Block, s:Span, nid:ast::NodeId, _:()) {
let vars = collect_freevars(self.def_map, blk); let vars = collect_freevars(self.def_map, blk);
self.freevars.insert(nid, vars); self.freevars.insert(nid, vars);
visit::walk_fn(self, fk, fd, blk, s, nid, ()); visit::walk_fn(self, fk, fd, blk, s, nid, ());

View File

@ -18,7 +18,7 @@ use util::ppaux::UserString;
use syntax::ast::*; use syntax::ast::*;
use syntax::attr; use syntax::attr;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::opt_vec; use syntax::opt_vec;
use syntax::print::pprust::expr_to_str; use syntax::print::pprust::expr_to_str;
use syntax::{visit,ast_util}; use syntax::{visit,ast_util};
@ -65,7 +65,7 @@ impl Visitor<Context> for KindAnalysisVisitor {
check_expr(self, ex, e); check_expr(self, ex, e);
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&fn_decl, b:&Block, s:span, n:NodeId, e:Context) { fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, e:Context) {
check_fn(self, fk, fd, b, s, n, e); check_fn(self, fk, fd, b, s, n, e);
} }
@ -91,7 +91,7 @@ pub fn check_crate(tcx: ty::ctxt,
} }
fn check_struct_safe_for_destructor(cx: Context, fn check_struct_safe_for_destructor(cx: Context,
span: span, span: Span,
struct_did: def_id) { struct_did: def_id) {
let struct_tpt = ty::lookup_item_type(cx.tcx, struct_did); let struct_tpt = ty::lookup_item_type(cx.tcx, struct_did);
if !struct_tpt.generics.has_type_params() { if !struct_tpt.generics.has_type_params() {
@ -245,7 +245,7 @@ fn check_fn(
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &fn_decl, decl: &fn_decl,
body: &Block, body: &Block,
sp: span, sp: Span,
fn_id: NodeId, fn_id: NodeId,
cx: Context) { cx: Context) {
@ -364,7 +364,7 @@ pub fn check_builtin_bounds(cx: Context, ty: ty::t, bounds: ty::BuiltinBounds,
pub fn check_typaram_bounds(cx: Context, pub fn check_typaram_bounds(cx: Context,
_type_parameter_id: NodeId, _type_parameter_id: NodeId,
sp: span, sp: Span,
ty: ty::t, ty: ty::t,
type_param_def: &ty::TypeParameterDef) type_param_def: &ty::TypeParameterDef)
{ {
@ -378,7 +378,7 @@ pub fn check_typaram_bounds(cx: Context,
} }
} }
pub fn check_freevar_bounds(cx: Context, sp: span, ty: ty::t, pub fn check_freevar_bounds(cx: Context, sp: Span, ty: ty::t,
bounds: ty::BuiltinBounds, referenced_ty: Option<ty::t>) bounds: ty::BuiltinBounds, referenced_ty: Option<ty::t>)
{ {
do check_builtin_bounds(cx, ty, bounds) |missing| { do check_builtin_bounds(cx, ty, bounds) |missing| {
@ -401,7 +401,7 @@ pub fn check_freevar_bounds(cx: Context, sp: span, ty: ty::t,
} }
} }
pub fn check_trait_cast_bounds(cx: Context, sp: span, ty: ty::t, pub fn check_trait_cast_bounds(cx: Context, sp: Span, ty: ty::t,
bounds: ty::BuiltinBounds) { bounds: ty::BuiltinBounds) {
do check_builtin_bounds(cx, ty, bounds) |missing| { do check_builtin_bounds(cx, ty, bounds) |missing| {
cx.tcx.sess.span_err(sp, cx.tcx.sess.span_err(sp,
@ -426,7 +426,7 @@ fn is_nullary_variant(cx: Context, ex: @expr) -> bool {
} }
} }
fn check_imm_free_var(cx: Context, def: def, sp: span) { fn check_imm_free_var(cx: Context, def: def, sp: Span) {
match def { match def {
def_local(_, is_mutbl) => { def_local(_, is_mutbl) => {
if is_mutbl { if is_mutbl {
@ -446,7 +446,7 @@ fn check_imm_free_var(cx: Context, def: def, sp: span) {
} }
} }
fn check_copy(cx: Context, ty: ty::t, sp: span, reason: &str) { fn check_copy(cx: Context, ty: ty::t, sp: Span, reason: &str) {
debug!("type_contents(%s)=%s", debug!("type_contents(%s)=%s",
ty_to_str(cx.tcx, ty), ty_to_str(cx.tcx, ty),
ty::type_contents(cx.tcx, ty).to_str()); ty::type_contents(cx.tcx, ty).to_str());
@ -458,7 +458,7 @@ fn check_copy(cx: Context, ty: ty::t, sp: span, reason: &str) {
} }
} }
pub fn check_send(cx: Context, ty: ty::t, sp: span) -> bool { pub fn check_send(cx: Context, ty: ty::t, sp: Span) -> bool {
if !ty::type_is_sendable(cx.tcx, ty) { if !ty::type_is_sendable(cx.tcx, ty) {
cx.tcx.sess.span_err( cx.tcx.sess.span_err(
sp, fmt!("value has non-sendable type `%s`", sp, fmt!("value has non-sendable type `%s`",
@ -470,7 +470,7 @@ pub fn check_send(cx: Context, ty: ty::t, sp: span) -> bool {
} }
// note: also used from middle::typeck::regionck! // note: also used from middle::typeck::regionck!
pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool { pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: Span) -> bool {
if !ty::type_is_static(tcx, ty) { if !ty::type_is_static(tcx, ty) {
match ty::get(ty).sty { match ty::get(ty).sty {
ty::ty_param(*) => { ty::ty_param(*) => {

View File

@ -28,7 +28,7 @@ use extra::smallintmap::SmallIntMap;
use syntax::ast_map; use syntax::ast_map;
use syntax::attr; use syntax::attr;
use syntax::attr::AttrMetaMethods; use syntax::attr::AttrMetaMethods;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::codemap; use syntax::codemap;
use syntax::parse::token; use syntax::parse::token;
use syntax::{ast, ast_util, visit}; use syntax::{ast, ast_util, visit};
@ -135,7 +135,7 @@ enum AttributedNode<'self> {
#[deriving(Eq)] #[deriving(Eq)]
enum LintSource { enum LintSource {
Node(span), Node(Span),
Default, Default,
CommandLine CommandLine
} }
@ -304,7 +304,7 @@ pub fn get_lint_dict() -> LintDict {
trait OuterLint { trait OuterLint {
fn process_item(@mut self, i:@ast::item, e:@mut Context); fn process_item(@mut self, i:@ast::item, e:@mut Context);
fn process_fn(@mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn process_fn(@mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context); b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context);
// Returned inner variant will not proceed past subitems. // Returned inner variant will not proceed past subitems.
// Supports decomposition of simple lints into subitem-traversing // Supports decomposition of simple lints into subitem-traversing
@ -319,7 +319,7 @@ trait InnerLint {
function_kind: &visit::fn_kind, function_kind: &visit::fn_kind,
function_declaration: &ast::fn_decl, function_declaration: &ast::fn_decl,
function_body: &ast::Block, function_body: &ast::Block,
sp: span, sp: Span,
id: ast::NodeId, id: ast::NodeId,
env: @mut Context); env: @mut Context);
} }
@ -332,7 +332,7 @@ impl<V:Visitor<@mut Context>> InnerLint for V {
visit::walk_crate(self, crate, env); visit::walk_crate(self, crate, env);
} }
fn descend_fn(@mut self, fk: &visit::fn_kind, fd: &ast::fn_decl, fb: &ast::Block, fn descend_fn(@mut self, fk: &visit::fn_kind, fd: &ast::fn_decl, fb: &ast::Block,
sp: span, id: ast::NodeId, env: @mut Context) { sp: Span, id: ast::NodeId, env: @mut Context) {
visit::walk_fn(self, fk, fd, fb, sp, id, env); visit::walk_fn(self, fk, fd, fb, sp, id, env);
} }
} }
@ -409,7 +409,7 @@ impl Context {
fail!("unregistered lint %?", lint); fail!("unregistered lint %?", lint);
} }
fn span_lint(&self, lint: lint, span: span, msg: &str) { fn span_lint(&self, lint: lint, span: Span, msg: &str) {
let (level, src) = match self.curr.find(&(lint as uint)) { let (level, src) = match self.curr.find(&(lint as uint)) {
None => { return } None => { return }
Some(&(warn, src)) => (self.get_level(warnings), src), Some(&(warn, src)) => (self.get_level(warnings), src),
@ -617,7 +617,7 @@ trait SubitemStoppableVisitor : Visitor<@mut Context> {
} }
fn visit_fn_action(&mut self, _fk:&visit::fn_kind, _fd:&ast::fn_decl, fn visit_fn_action(&mut self, _fk:&visit::fn_kind, _fd:&ast::fn_decl,
_b:&ast::Block, _s:span, _n:ast::NodeId, _e:@mut Context) { _b:&ast::Block, _s:Span, _n:ast::NodeId, _e:@mut Context) {
// fill in with particular action without recursion if desired // fill in with particular action without recursion if desired
} }
@ -641,7 +641,7 @@ trait SubitemStoppableVisitor : Visitor<@mut Context> {
} }
fn OVERRIDE_visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn OVERRIDE_visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
if self.is_running_on_items() { if self.is_running_on_items() {
self.visit_fn_action(fk, fd, b, s, n, e); self.visit_fn_action(fk, fd, b, s, n, e);
visit::walk_fn(self, fk, fd, b, s, n, e); visit::walk_fn(self, fk, fd, b, s, n, e);
@ -670,7 +670,7 @@ impl Visitor<@mut Context> for WhileTrueLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -679,7 +679,7 @@ impl Visitor<@mut Context> for WhileTrueLintVisitor {
match e.node { match e.node {
ast::expr_while(cond, _) => { ast::expr_while(cond, _) => {
match cond.node { match cond.node {
ast::expr_lit(@codemap::spanned { ast::expr_lit(@codemap::Spanned {
node: ast::lit_bool(true), _}) => node: ast::lit_bool(true), _}) =>
{ {
cx.span_lint(while_true, e.span, cx.span_lint(while_true, e.span,
@ -703,7 +703,7 @@ macro_rules! outer_lint_boilerplate_impl(
self.visit_item_action(i, e); self.visit_item_action(i, e);
} }
fn process_fn(@mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn process_fn(@mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.visit_fn_action(fk, fd, b, s, n, e); self.visit_fn_action(fk, fd, b, s, n, e);
} }
fn inner_variant(@mut self) -> @mut InnerLint { fn inner_variant(@mut self) -> @mut InnerLint {
@ -834,7 +834,7 @@ impl Visitor<@mut Context> for TypeLimitsLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -905,7 +905,7 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {
} }
} }
fn check_type_for_lint(cx: &Context, lint: lint, span: span, ty: ty::t) { fn check_type_for_lint(cx: &Context, lint: lint, span: Span, ty: ty::t) {
if cx.get_level(lint) == allow { return } if cx.get_level(lint) == allow { return }
let mut n_box = 0; let mut n_box = 0;
@ -932,7 +932,7 @@ fn check_type_for_lint(cx: &Context, lint: lint, span: span, ty: ty::t) {
} }
} }
fn check_type(cx: &Context, span: span, ty: ty::t) { fn check_type(cx: &Context, span: Span, ty: ty::t) {
let xs = [managed_heap_memory, owned_heap_memory, heap_memory]; let xs = [managed_heap_memory, owned_heap_memory, heap_memory];
for lint in xs.iter() { for lint in xs.iter() {
check_type_for_lint(cx, *lint, span, ty); check_type_for_lint(cx, *lint, span, ty);
@ -975,7 +975,7 @@ impl Visitor<@mut Context> for HeapLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -1006,7 +1006,7 @@ impl Visitor<@mut Context> for PathStatementLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -1044,7 +1044,7 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) {
!ident.contains_char('_') !ident.contains_char('_')
} }
fn check_case(cx: &Context, sort: &str, ident: ast::ident, span: span) { fn check_case(cx: &Context, sort: &str, ident: ast::ident, span: Span) {
if !is_camel_case(cx.tcx, ident) { if !is_camel_case(cx.tcx, ident) {
cx.span_lint( cx.span_lint(
non_camel_case_types, span, non_camel_case_types, span,
@ -1099,7 +1099,7 @@ impl Visitor<@mut Context> for UnusedUnsafeLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -1157,7 +1157,7 @@ impl SubitemStoppableVisitor for UnusedMutLintVisitor {
fn is_running_on_items(&mut self) -> bool { !self.stopping_on_items } fn is_running_on_items(&mut self) -> bool { !self.stopping_on_items }
fn visit_fn_action(&mut self, _a:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn_action(&mut self, _a:&visit::fn_kind, fd:&ast::fn_decl,
_b:&ast::Block, _c:span, _d:ast::NodeId, cx:@mut Context) { _b:&ast::Block, _c:Span, _d:ast::NodeId, cx:@mut Context) {
self.visit_fn_decl(cx, fd); self.visit_fn_decl(cx, fd);
} }
} }
@ -1168,7 +1168,7 @@ impl Visitor<@mut Context> for UnusedMutLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -1225,7 +1225,7 @@ impl Visitor<@mut Context> for UnnecessaryAllocationLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -1243,7 +1243,7 @@ impl UnnecessaryAllocationLintVisitor {
ast::expr_vstore(e2, ast::expr_vstore_uniq) | ast::expr_vstore(e2, ast::expr_vstore_uniq) |
ast::expr_vstore(e2, ast::expr_vstore_box) => { ast::expr_vstore(e2, ast::expr_vstore_box) => {
match e2.node { match e2.node {
ast::expr_lit(@codemap::spanned{ ast::expr_lit(@codemap::Spanned{
node: ast::lit_str(*), _}) | node: ast::lit_str(*), _}) |
ast::expr_vec(*) => {} ast::expr_vec(*) => {}
_ => return _ => return
@ -1278,7 +1278,7 @@ impl MissingDocLintVisitor {
fn check_attrs(&mut self, fn check_attrs(&mut self,
cx: @mut Context, cx: @mut Context,
attrs: &[ast::Attribute], attrs: &[ast::Attribute],
sp: span, sp: Span,
msg: &str) { msg: &str) {
// If we're building a test harness, then warning about documentation is // If we're building a test harness, then warning about documentation is
// probably not really relevant right now // probably not really relevant right now
@ -1299,7 +1299,7 @@ impl Visitor<@mut Context> for MissingDocLintVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:@mut Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:@mut Context) {
self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); self.OVERRIDE_visit_fn(fk, fd, b, s, n, e);
} }
@ -1316,7 +1316,7 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
fn is_running_on_items(&mut self) -> bool { !self.stopping_on_items } fn is_running_on_items(&mut self) -> bool { !self.stopping_on_items }
fn visit_fn_action(&mut self, fk:&visit::fn_kind, _d:&ast::fn_decl, fn visit_fn_action(&mut self, fk:&visit::fn_kind, _d:&ast::fn_decl,
_b:&ast::Block, sp:span, _id:ast::NodeId, cx:@mut Context) { _b:&ast::Block, sp:Span, _id:ast::NodeId, cx:@mut Context) {
// Only warn about explicitly public methods. Soon implicit // Only warn about explicitly public methods. Soon implicit
// public-ness will hopefully be going away. // public-ness will hopefully be going away.
@ -1400,7 +1400,7 @@ impl Visitor<@mut Context> for LintCheckVisitor {
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, decl:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, decl:&ast::fn_decl,
body:&ast::Block, span:span, id:ast::NodeId, cx:@mut Context) { body:&ast::Block, span:Span, id:ast::NodeId, cx:@mut Context) {
match *fk { match *fk {
visit::fk_method(_, _, m) => { visit::fk_method(_, _, m) => {

View File

@ -116,7 +116,7 @@ use std::to_str;
use std::uint; use std::uint;
use std::vec; use std::vec;
use syntax::ast::*; use syntax::ast::*;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
use syntax::print::pprust::{expr_to_str, block_to_str}; use syntax::print::pprust::{expr_to_str, block_to_str};
use syntax::{visit, ast_util}; use syntax::{visit, ast_util};
@ -135,9 +135,9 @@ impl Clone for LiveNode {
#[deriving(Eq)] #[deriving(Eq)]
enum LiveNodeKind { enum LiveNodeKind {
FreeVarNode(span), FreeVarNode(Span),
ExprNode(span), ExprNode(Span),
VarDefNode(span), VarDefNode(Span),
ExitNode ExitNode
} }
@ -154,7 +154,7 @@ fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
struct LivenessVisitor; struct LivenessVisitor;
impl Visitor<@mut IrMaps> for LivenessVisitor { impl Visitor<@mut IrMaps> for LivenessVisitor {
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:span, n:NodeId, e:@mut IrMaps) { fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, e:@mut IrMaps) {
visit_fn(self, fk, fd, b, s, n, e); visit_fn(self, fk, fd, b, s, n, e);
} }
fn visit_local(&mut self, l:@Local, e:@mut IrMaps) { visit_local(self, l, e); } fn visit_local(&mut self, l:@Local, e:@mut IrMaps) { visit_local(self, l, e); }
@ -308,7 +308,7 @@ impl IrMaps {
v v
} }
pub fn variable(&mut self, node_id: NodeId, span: span) -> Variable { pub fn variable(&mut self, node_id: NodeId, span: Span) -> Variable {
match self.variable_map.find(&node_id) { match self.variable_map.find(&node_id) {
Some(&var) => var, Some(&var) => var,
None => { None => {
@ -348,7 +348,7 @@ impl IrMaps {
struct ErrorCheckVisitor; struct ErrorCheckVisitor;
impl Visitor<@Liveness> for ErrorCheckVisitor { impl Visitor<@Liveness> for ErrorCheckVisitor {
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:span, n:NodeId, e:@Liveness) { fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, e:@Liveness) {
check_fn(self, fk, fd, b, s, n, e); check_fn(self, fk, fd, b, s, n, e);
} }
fn visit_local(&mut self, l:@Local, e:@Liveness) { fn visit_local(&mut self, l:@Local, e:@Liveness) {
@ -366,7 +366,7 @@ fn visit_fn(v: &mut LivenessVisitor,
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &fn_decl, decl: &fn_decl,
body: &Block, body: &Block,
sp: span, sp: Span,
id: NodeId, id: NodeId,
this: @mut IrMaps) { this: @mut IrMaps) {
debug!("visit_fn: id=%d", id); debug!("visit_fn: id=%d", id);
@ -602,7 +602,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
} }
impl Liveness { impl Liveness {
pub fn live_node(&self, node_id: NodeId, span: span) -> LiveNode { pub fn live_node(&self, node_id: NodeId, span: Span) -> LiveNode {
let ir: &mut IrMaps = self.ir; let ir: &mut IrMaps = self.ir;
match ir.live_node_map.find(&node_id) { match ir.live_node_map.find(&node_id) {
Some(&ln) => ln, Some(&ln) => ln,
@ -630,11 +630,11 @@ impl Liveness {
} }
} }
pub fn variable(&self, node_id: NodeId, span: span) -> Variable { pub fn variable(&self, node_id: NodeId, span: Span) -> Variable {
self.ir.variable(node_id, span) self.ir.variable(node_id, span)
} }
pub fn variable_from_def_map(&self, node_id: NodeId, span: span) pub fn variable_from_def_map(&self, node_id: NodeId, span: Span)
-> Option<Variable> { -> Option<Variable> {
match self.tcx.def_map.find(&node_id) { match self.tcx.def_map.find(&node_id) {
Some(&def) => { Some(&def) => {
@ -651,7 +651,7 @@ impl Liveness {
pub fn pat_bindings(&self, pub fn pat_bindings(&self,
pat: @pat, pat: @pat,
f: &fn(LiveNode, Variable, span, NodeId)) { f: &fn(LiveNode, Variable, Span, NodeId)) {
let def_map = self.tcx.def_map; let def_map = self.tcx.def_map;
do pat_util::pat_bindings(def_map, pat) |_bm, p_id, sp, _n| { do pat_util::pat_bindings(def_map, pat) |_bm, p_id, sp, _n| {
let ln = self.live_node(p_id, sp); let ln = self.live_node(p_id, sp);
@ -662,7 +662,7 @@ impl Liveness {
pub fn arm_pats_bindings(&self, pub fn arm_pats_bindings(&self,
pats: &[@pat], pats: &[@pat],
f: &fn(LiveNode, Variable, span, NodeId)) { f: &fn(LiveNode, Variable, Span, NodeId)) {
// only consider the first pattern; any later patterns must have // only consider the first pattern; any later patterns must have
// the same bindings, and we also consider the first pattern to be // the same bindings, and we also consider the first pattern to be
// the "authoratative" set of ids // the "authoratative" set of ids
@ -758,7 +758,7 @@ impl Liveness {
pub fn find_loop_scope(&self, pub fn find_loop_scope(&self,
opt_label: Option<ident>, opt_label: Option<ident>,
id: NodeId, id: NodeId,
sp: span) sp: Span)
-> NodeId { -> NodeId {
match opt_label { match opt_label {
Some(_) => // Refers to a labeled loop. Use the results of resolve Some(_) => // Refers to a labeled loop. Use the results of resolve
@ -1512,7 +1512,7 @@ fn check_fn(_v: &mut ErrorCheckVisitor,
_fk: &visit::fn_kind, _fk: &visit::fn_kind,
_decl: &fn_decl, _decl: &fn_decl,
_body: &Block, _body: &Block,
_sp: span, _sp: Span,
_id: NodeId, _id: NodeId,
_self: @Liveness) { _self: @Liveness) {
// do not check contents of nested fns // do not check contents of nested fns
@ -1528,7 +1528,7 @@ enum ReadKind {
impl Liveness { impl Liveness {
pub fn check_ret(&self, pub fn check_ret(&self,
id: NodeId, id: NodeId,
sp: span, sp: Span,
_fk: &visit::fn_kind, _fk: &visit::fn_kind,
entry_ln: LiveNode) { entry_ln: LiveNode) {
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() { if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
@ -1584,7 +1584,7 @@ impl Liveness {
} }
pub fn report_illegal_read(&self, pub fn report_illegal_read(&self,
chk_span: span, chk_span: Span,
lnk: LiveNodeKind, lnk: LiveNodeKind,
var: Variable, var: Variable,
rk: ReadKind) { rk: ReadKind) {
@ -1639,7 +1639,7 @@ impl Liveness {
} }
pub fn warn_about_unused(&self, pub fn warn_about_unused(&self,
sp: span, sp: Span,
id: NodeId, id: NodeId,
ln: LiveNode, ln: LiveNode,
var: Variable) var: Variable)
@ -1673,7 +1673,7 @@ impl Liveness {
} }
pub fn warn_about_dead_assign(&self, pub fn warn_about_dead_assign(&self,
sp: span, sp: Span,
id: NodeId, id: NodeId,
ln: LiveNode, ln: LiveNode,
var: Variable) { var: Variable) {

View File

@ -54,7 +54,7 @@ use util::common::indenter;
use syntax::ast::{m_imm, m_mutbl}; use syntax::ast::{m_imm, m_mutbl};
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::print::pprust; use syntax::print::pprust;
#[deriving(Eq)] #[deriving(Eq)]
@ -134,7 +134,7 @@ pub enum MutabilityCategory {
#[deriving(Eq)] #[deriving(Eq)]
pub struct cmt_ { pub struct cmt_ {
id: ast::NodeId, // id of expr/pat producing this value id: ast::NodeId, // id of expr/pat producing this value
span: span, // span of same expr/pat span: Span, // span of same expr/pat
cat: categorization, // categorization of expr cat: categorization, // categorization of expr
mutbl: MutabilityCategory, // mutability of expr as lvalue mutbl: MutabilityCategory, // mutability of expr as lvalue
ty: ty::t // type of the expr (*see WARNING above*) ty: ty::t // type of the expr (*see WARNING above*)
@ -256,7 +256,7 @@ pub fn cat_def(
tcx: ty::ctxt, tcx: ty::ctxt,
method_map: typeck::method_map, method_map: typeck::method_map,
expr_id: ast::NodeId, expr_id: ast::NodeId,
expr_span: span, expr_span: Span,
expr_ty: ty::t, expr_ty: ty::t,
def: ast::def) -> cmt { def: ast::def) -> cmt {
@ -268,17 +268,17 @@ pub fn cat_def(
pub trait ast_node { pub trait ast_node {
fn id(&self) -> ast::NodeId; fn id(&self) -> ast::NodeId;
fn span(&self) -> span; fn span(&self) -> Span;
} }
impl ast_node for @ast::expr { impl ast_node for @ast::expr {
fn id(&self) -> ast::NodeId { self.id } fn id(&self) -> ast::NodeId { self.id }
fn span(&self) -> span { self.span } fn span(&self) -> Span { self.span }
} }
impl ast_node for @ast::pat { impl ast_node for @ast::pat {
fn id(&self) -> ast::NodeId { self.id } fn id(&self) -> ast::NodeId { self.id }
fn span(&self) -> span { self.span } fn span(&self) -> Span { self.span }
} }
pub struct mem_categorization_ctxt { pub struct mem_categorization_ctxt {
@ -442,7 +442,7 @@ impl mem_categorization_ctxt {
pub fn cat_def(&self, pub fn cat_def(&self,
id: ast::NodeId, id: ast::NodeId,
span: span, span: Span,
expr_ty: ty::t, expr_ty: ty::t,
def: ast::def) def: ast::def)
-> cmt { -> cmt {
@ -584,7 +584,7 @@ impl mem_categorization_ctxt {
pub fn cat_rvalue(&self, pub fn cat_rvalue(&self,
cmt_id: ast::NodeId, cmt_id: ast::NodeId,
span: span, span: Span,
cleanup_scope_id: ast::NodeId, cleanup_scope_id: ast::NodeId,
expr_ty: ty::t) -> cmt { expr_ty: ty::t) -> cmt {
@cmt_ { @cmt_ {

View File

@ -141,7 +141,7 @@ use syntax::ast::*;
use syntax::ast_util; use syntax::ast_util;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
use syntax::codemap::span; use syntax::codemap::Span;
#[deriving(Encodable, Decodable)] #[deriving(Encodable, Decodable)]
pub enum CaptureMode { pub enum CaptureMode {
@ -153,7 +153,7 @@ pub enum CaptureMode {
#[deriving(Encodable, Decodable)] #[deriving(Encodable, Decodable)]
pub struct CaptureVar { pub struct CaptureVar {
def: def, // Variable being accessed free def: def, // Variable being accessed free
span: span, // Location of an access to this variable span: Span, // Location of an access to this variable
mode: CaptureMode // How variable is being accessed mode: CaptureMode // How variable is being accessed
} }
@ -194,7 +194,7 @@ struct ComputeModesVisitor;
impl visit::Visitor<VisitContext> for ComputeModesVisitor { impl visit::Visitor<VisitContext> for ComputeModesVisitor {
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&fn_decl,
b:&Block, s:span, n:NodeId, e:VisitContext) { b:&Block, s:Span, n:NodeId, e:VisitContext) {
compute_modes_for_fn(*self, fk, fd, b, s, n, e); compute_modes_for_fn(*self, fk, fd, b, s, n, e);
} }
fn visit_expr(&mut self, ex:@expr, e:VisitContext) { fn visit_expr(&mut self, ex:@expr, e:VisitContext) {
@ -250,7 +250,7 @@ fn compute_modes_for_fn(v: ComputeModesVisitor,
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &fn_decl, decl: &fn_decl,
body: &Block, body: &Block,
span: span, span: Span,
id: NodeId, id: NodeId,
cx: VisitContext) { cx: VisitContext) {
let mut v = v; let mut v = v;

View File

@ -14,7 +14,7 @@ use middle::resolve;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use syntax::ast::*; use syntax::ast::*;
use syntax::ast_util::{path_to_ident, walk_pat}; use syntax::ast_util::{path_to_ident, walk_pat};
use syntax::codemap::span; use syntax::codemap::Span;
pub type PatIdMap = HashMap<ident, NodeId>; pub type PatIdMap = HashMap<ident, NodeId>;
@ -71,7 +71,7 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool {
} }
pub fn pat_bindings(dm: resolve::DefMap, pat: @pat, pub fn pat_bindings(dm: resolve::DefMap, pat: @pat,
it: &fn(binding_mode, NodeId, span, &Path)) { it: &fn(binding_mode, NodeId, Span, &Path)) {
do walk_pat(pat) |p| { do walk_pat(pat) |p| {
match p.node { match p.node {
pat_ident(binding_mode, ref pth, _) if pat_is_binding(dm, p) => { pat_ident(binding_mode, ref pth, _) if pat_is_binding(dm, p) => {

View File

@ -31,7 +31,7 @@ use syntax::ast_map;
use syntax::ast_util::{Private, Public, is_local}; use syntax::ast_util::{Private, Public, is_local};
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy}; use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
use syntax::attr; use syntax::attr;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token; use syntax::parse::token;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -79,7 +79,7 @@ impl PrivacyVisitor {
} }
// Checks that an enum variant is in scope // Checks that an enum variant is in scope
fn check_variant(&mut self, span: span, enum_id: ast::def_id) { fn check_variant(&mut self, span: Span, enum_id: ast::def_id) {
let variant_info = ty::enum_variants(self.tcx, enum_id)[0]; let variant_info = ty::enum_variants(self.tcx, enum_id)[0];
let parental_privacy = if is_local(enum_id) { let parental_privacy = if is_local(enum_id) {
let parent_vis = ast_map::node_item_query(self.tcx.items, let parent_vis = ast_map::node_item_query(self.tcx.items,
@ -108,7 +108,7 @@ impl PrivacyVisitor {
} }
// Returns true if a crate-local method is private and false otherwise. // Returns true if a crate-local method is private and false otherwise.
fn method_is_private(&mut self, span: span, method_id: NodeId) -> bool { fn method_is_private(&mut self, span: Span, method_id: NodeId) -> bool {
let check = |vis: visibility, container_id: def_id| { let check = |vis: visibility, container_id: def_id| {
let mut is_private = false; let mut is_private = false;
if vis == private { if vis == private {
@ -171,7 +171,7 @@ impl PrivacyVisitor {
} }
// Returns true if the given local item is private and false otherwise. // Returns true if the given local item is private and false otherwise.
fn local_item_is_private(&mut self, span: span, item_id: NodeId) -> bool { fn local_item_is_private(&mut self, span: Span, item_id: NodeId) -> bool {
let mut f: &fn(NodeId) -> bool = |_| false; let mut f: &fn(NodeId) -> bool = |_| false;
f = |item_id| { f = |item_id| {
match self.tcx.items.find(&item_id) { match self.tcx.items.find(&item_id) {
@ -203,7 +203,7 @@ impl PrivacyVisitor {
} }
// Checks that a private field is in scope. // Checks that a private field is in scope.
fn check_field(&mut self, span: span, id: ast::def_id, ident: ast::ident) { fn check_field(&mut self, span: Span, id: ast::def_id, ident: ast::ident) {
let fields = ty::lookup_struct_fields(self.tcx, id); let fields = ty::lookup_struct_fields(self.tcx, id);
for field in fields.iter() { for field in fields.iter() {
if field.ident != ident { loop; } if field.ident != ident { loop; }
@ -216,7 +216,7 @@ impl PrivacyVisitor {
} }
// Given the ID of a method, checks to ensure it's in scope. // Given the ID of a method, checks to ensure it's in scope.
fn check_method_common(&mut self, span: span, method_id: def_id, name: &ident) { fn check_method_common(&mut self, span: Span, method_id: def_id, name: &ident) {
// If the method is a default method, we need to use the def_id of // If the method is a default method, we need to use the def_id of
// the default implementation. // the default implementation.
// Having to do this this is really unfortunate. // Having to do this this is really unfortunate.
@ -245,7 +245,7 @@ impl PrivacyVisitor {
} }
// Checks that a private path is in scope. // Checks that a private path is in scope.
fn check_path(&mut self, span: span, def: def, path: &Path) { fn check_path(&mut self, span: Span, def: def, path: &Path) {
debug!("checking path"); debug!("checking path");
match def { match def {
def_static_method(method_id, _, _) => { def_static_method(method_id, _, _) => {
@ -280,7 +280,7 @@ impl PrivacyVisitor {
} }
// Checks that a private method is in scope. // Checks that a private method is in scope.
fn check_method(&mut self, span: span, origin: &method_origin, ident: ast::ident) { fn check_method(&mut self, span: Span, origin: &method_origin, ident: ast::ident) {
match *origin { match *origin {
method_static(method_id) => { method_static(method_id) => {
self.check_method_common(span, method_id, &ident) self.check_method_common(span, method_id, &ident)
@ -343,7 +343,7 @@ impl PrivacyVisitor {
impl<'self> Visitor<&'self method_map> for PrivacyVisitor { impl<'self> Visitor<&'self method_map> for PrivacyVisitor {
fn visit_mod<'mm>(&mut self, the_module:&_mod, _:span, _:NodeId, fn visit_mod<'mm>(&mut self, the_module:&_mod, _:Span, _:NodeId,
method_map:&'mm method_map) { method_map:&'mm method_map) {
let n_added = self.add_privileged_items(the_module.items); let n_added = self.add_privileged_items(the_module.items);

View File

@ -30,7 +30,7 @@ use middle::ty;
use std::hashmap::{HashMap, HashSet}; use std::hashmap::{HashMap, HashSet};
use syntax::ast_map; use syntax::ast_map;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::print::pprust; use syntax::print::pprust;
use syntax::parse::token; use syntax::parse::token;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
@ -318,7 +318,7 @@ impl RegionMaps {
} }
/// Records the current parent (if any) as the parent of `child_id`. /// Records the current parent (if any) as the parent of `child_id`.
fn parent_to_expr(cx: Context, child_id: ast::NodeId, sp: span) { fn parent_to_expr(cx: Context, child_id: ast::NodeId, sp: Span) {
debug!("region::parent_to_expr(span=%?)", debug!("region::parent_to_expr(span=%?)",
cx.sess.codemap.span_to_str(sp)); cx.sess.codemap.span_to_str(sp));
for parent_id in cx.parent.iter() { for parent_id in cx.parent.iter() {
@ -431,7 +431,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor,
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &ast::fn_decl, decl: &ast::fn_decl,
body: &ast::Block, body: &ast::Block,
sp: span, sp: Span,
id: ast::NodeId, id: ast::NodeId,
cx: Context) { cx: Context) {
debug!("region::resolve_fn(id=%?, \ debug!("region::resolve_fn(id=%?, \
@ -482,7 +482,7 @@ impl Visitor<Context> for RegionResolutionVisitor {
resolve_item(self, i, cx); resolve_item(self, i, cx);
} }
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:span, n:NodeId, cx:Context) { fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, cx:Context) {
resolve_fn(self, fk, fd, b, s, n, cx); resolve_fn(self, fk, fd, b, s, n, cx);
} }
fn visit_arm(&mut self, a:&arm, cx:Context) { fn visit_arm(&mut self, a:&arm, cx:Context) {
@ -744,7 +744,7 @@ fn determine_rp_in_fn(visitor: &mut DetermineRpVisitor,
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &ast::fn_decl, decl: &ast::fn_decl,
body: &ast::Block, body: &ast::Block,
_: span, _: Span,
_: ast::NodeId, _: ast::NodeId,
cx: @mut DetermineRpCtxt) { cx: @mut DetermineRpCtxt) {
do cx.with(cx.item_id, false) { do cx.with(cx.item_id, false) {
@ -911,7 +911,7 @@ struct DetermineRpVisitor;
impl Visitor<@mut DetermineRpCtxt> for DetermineRpVisitor { impl Visitor<@mut DetermineRpCtxt> for DetermineRpVisitor {
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl,
b:&Block, s:span, n:NodeId, e:@mut DetermineRpCtxt) { b:&Block, s:Span, n:NodeId, e:@mut DetermineRpCtxt) {
determine_rp_in_fn(self, fk, fd, b, s, n, e); determine_rp_in_fn(self, fk, fd, b, s, n, e);
} }
fn visit_item(&mut self, i:@item, e:@mut DetermineRpCtxt) { fn visit_item(&mut self, i:@item, e:@mut DetermineRpCtxt) {

View File

@ -16,7 +16,7 @@ use metadata::csearch::get_static_methods_if_impl;
use metadata::csearch::{get_type_name_if_impl, get_struct_fields}; use metadata::csearch::{get_type_name_if_impl, get_struct_fields};
use metadata::csearch; use metadata::csearch;
use metadata::cstore::find_extern_mod_stmt_cnum; use metadata::cstore::find_extern_mod_stmt_cnum;
use metadata::decoder::{def_like, dl_def, dl_field, dl_impl}; use metadata::decoder::{DefLike, DlDef, DlField, DlImpl};
use middle::lang_items::LanguageItems; use middle::lang_items::LanguageItems;
use middle::lint::{unnecessary_qualification, unused_imports}; use middle::lint::{unnecessary_qualification, unused_imports};
use middle::pat_util::pat_bindings; use middle::pat_util::pat_bindings;
@ -32,7 +32,7 @@ use syntax::parse::token;
use syntax::parse::token::ident_interner; use syntax::parse::token::ident_interner;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
use syntax::print::pprust::path_to_str; use syntax::print::pprust::path_to_str;
use syntax::codemap::{span, dummy_sp, BytePos}; use syntax::codemap::{Span, dummy_sp, BytePos};
use syntax::opt_vec::OptVec; use syntax::opt_vec::OptVec;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -46,7 +46,7 @@ use std::util;
pub type DefMap = @mut HashMap<NodeId,def>; pub type DefMap = @mut HashMap<NodeId,def>;
pub struct binding_info { pub struct binding_info {
span: span, span: Span,
binding_mode: binding_mode, binding_mode: binding_mode,
} }
@ -311,41 +311,44 @@ pub enum DuplicateCheckingMode {
/// One local scope. /// One local scope.
pub struct Rib { pub struct Rib {
bindings: @mut HashMap<ident,def_like>, bindings: @mut HashMap<ident, DefLike>,
self_binding: @mut Option<def_like>, self_binding: @mut Option<DefLike>,
kind: RibKind, kind: RibKind,
} }
pub fn Rib(kind: RibKind) -> Rib { impl Rib {
Rib { pub fn new(kind: RibKind) -> Rib {
bindings: @mut HashMap::new(), Rib {
self_binding: @mut None, bindings: @mut HashMap::new(),
kind: kind self_binding: @mut None,
kind: kind
}
} }
} }
/// One import directive. /// One import directive.
pub struct ImportDirective { pub struct ImportDirective {
privacy: Privacy, privacy: Privacy,
module_path: ~[ident], module_path: ~[ident],
subclass: @ImportDirectiveSubclass, subclass: @ImportDirectiveSubclass,
span: span, span: Span,
id: NodeId, id: NodeId,
} }
pub fn ImportDirective(privacy: Privacy, impl ImportDirective {
module_path: ~[ident], pub fn new(privacy: Privacy,
subclass: @ImportDirectiveSubclass, module_path: ~[ident],
span: span, subclass: @ImportDirectiveSubclass,
id: NodeId) span: Span,
-> ImportDirective { id: NodeId)
ImportDirective { -> ImportDirective {
privacy: privacy, ImportDirective {
module_path: module_path, privacy: privacy,
subclass: subclass, module_path: module_path,
span: span, subclass: subclass,
id: id span: span,
id: id
}
} }
} }
@ -355,12 +358,14 @@ pub struct Target {
bindings: @mut NameBindings, bindings: @mut NameBindings,
} }
pub fn Target(target_module: @mut Module, impl Target {
bindings: @mut NameBindings) pub fn new(target_module: @mut Module,
-> Target { bindings: @mut NameBindings)
Target { -> Target {
target_module: target_module, Target {
bindings: bindings target_module: target_module,
bindings: bindings
}
} }
} }
@ -388,19 +393,19 @@ pub struct ImportResolution {
type_id: NodeId, type_id: NodeId,
} }
pub fn ImportResolution(privacy: Privacy,
id: NodeId) -> ImportResolution {
ImportResolution {
privacy: privacy,
type_id: id,
value_id: id,
outstanding_references: 0,
value_target: None,
type_target: None,
}
}
impl ImportResolution { impl ImportResolution {
pub fn new(privacy: Privacy,
id: NodeId) -> ImportResolution {
ImportResolution {
privacy: privacy,
type_id: id,
value_id: id,
outstanding_references: 0,
value_target: None,
type_target: None,
}
}
pub fn target_for_namespace(&self, namespace: Namespace) pub fn target_for_namespace(&self, namespace: Namespace)
-> Option<Target> { -> Option<Target> {
match namespace { match namespace {
@ -478,27 +483,27 @@ pub struct Module {
populated: bool, populated: bool,
} }
pub fn Module(parent_link: ParentLink,
def_id: Option<def_id>,
kind: ModuleKind,
external: bool)
-> Module {
Module {
parent_link: parent_link,
def_id: def_id,
kind: kind,
children: @mut HashMap::new(),
imports: @mut ~[],
external_module_children: @mut HashMap::new(),
anonymous_children: @mut HashMap::new(),
import_resolutions: @mut HashMap::new(),
glob_count: 0,
resolved_import_count: 0,
populated: !external,
}
}
impl Module { impl Module {
pub fn new(parent_link: ParentLink,
def_id: Option<def_id>,
kind: ModuleKind,
external: bool)
-> Module {
Module {
parent_link: parent_link,
def_id: def_id,
kind: kind,
children: @mut HashMap::new(),
imports: @mut ~[],
external_module_children: @mut HashMap::new(),
anonymous_children: @mut HashMap::new(),
import_resolutions: @mut HashMap::new(),
glob_count: 0,
resolved_import_count: 0,
populated: !external,
}
}
pub fn all_imports_resolved(&self) -> bool { pub fn all_imports_resolved(&self) -> bool {
let imports = &mut *self.imports; let imports = &mut *self.imports;
return imports.len() == self.resolved_import_count; return imports.len() == self.resolved_import_count;
@ -510,14 +515,14 @@ pub struct TypeNsDef {
privacy: Privacy, privacy: Privacy,
module_def: Option<@mut Module>, module_def: Option<@mut Module>,
type_def: Option<def>, type_def: Option<def>,
type_span: Option<span> type_span: Option<Span>
} }
// Records a possibly-private value definition. // Records a possibly-private value definition.
pub struct ValueNsDef { pub struct ValueNsDef {
privacy: Privacy, privacy: Privacy,
def: def, def: def,
value_span: Option<span>, value_span: Option<Span>,
} }
// Records the definitions (at most one for each namespace) that a name is // Records the definitions (at most one for each namespace) that a name is
@ -542,9 +547,9 @@ impl NameBindings {
def_id: Option<def_id>, def_id: Option<def_id>,
kind: ModuleKind, kind: ModuleKind,
external: bool, external: bool,
sp: span) { sp: Span) {
// Merges the module with the existing type def or creates a new one. // Merges the module with the existing type def or creates a new one.
let module_ = @mut Module(parent_link, def_id, kind, external); let module_ = @mut Module::new(parent_link, def_id, kind, external);
match self.type_def { match self.type_def {
None => { None => {
self.type_def = Some(TypeNsDef { self.type_def = Some(TypeNsDef {
@ -572,10 +577,10 @@ impl NameBindings {
def_id: Option<def_id>, def_id: Option<def_id>,
kind: ModuleKind, kind: ModuleKind,
external: bool, external: bool,
_sp: span) { _sp: Span) {
match self.type_def { match self.type_def {
None => { None => {
let module = @mut Module(parent_link, def_id, kind, external); let module = @mut Module::new(parent_link, def_id, kind, external);
self.type_def = Some(TypeNsDef { self.type_def = Some(TypeNsDef {
privacy: privacy, privacy: privacy,
module_def: Some(module), module_def: Some(module),
@ -586,7 +591,7 @@ impl NameBindings {
Some(type_def) => { Some(type_def) => {
match type_def.module_def { match type_def.module_def {
None => { None => {
let module = @mut Module(parent_link, let module = @mut Module::new(parent_link,
def_id, def_id,
kind, kind,
external); external);
@ -604,7 +609,7 @@ impl NameBindings {
} }
/// Records a type definition. /// Records a type definition.
pub fn define_type(@mut self, privacy: Privacy, def: def, sp: span) { pub fn define_type(@mut self, privacy: Privacy, def: def, sp: Span) {
// Merges the type with the existing type def or creates a new one. // Merges the type with the existing type def or creates a new one.
match self.type_def { match self.type_def {
None => { None => {
@ -627,7 +632,7 @@ impl NameBindings {
} }
/// Records a value definition. /// Records a value definition.
pub fn define_value(@mut self, privacy: Privacy, def: def, sp: span) { pub fn define_value(@mut self, privacy: Privacy, def: def, sp: Span) {
self.value_def = Some(ValueNsDef { privacy: privacy, def: def, value_span: Some(sp) }); self.value_def = Some(ValueNsDef { privacy: privacy, def: def, value_span: Some(sp) });
} }
@ -723,7 +728,7 @@ impl NameBindings {
} }
} }
pub fn span_for_namespace(&self, namespace: Namespace) -> Option<span> { pub fn span_for_namespace(&self, namespace: Namespace) -> Option<Span> {
if self.defined_in_namespace(namespace) { if self.defined_in_namespace(namespace) {
match namespace { match namespace {
TypeNS => { TypeNS => {
@ -1016,7 +1021,7 @@ impl Resolver {
reduced_graph_parent: ReducedGraphParent, reduced_graph_parent: ReducedGraphParent,
duplicate_checking_mode: DuplicateCheckingMode, duplicate_checking_mode: DuplicateCheckingMode,
// For printing errors // For printing errors
sp: span) sp: Span)
-> (@mut NameBindings, ReducedGraphParent) { -> (@mut NameBindings, ReducedGraphParent) {
// If this is the immediate descendant of a module, then we add the // If this is the immediate descendant of a module, then we add the
// child name directly. Otherwise, we create or reuse an anonymous // child name directly. Otherwise, we create or reuse an anonymous
@ -1571,7 +1576,7 @@ impl Resolver {
let def_id = def_id { crate: crate_id, node: 0 }; let def_id = def_id { crate: crate_id, node: 0 };
let parent_link = ModuleParentLink let parent_link = ModuleParentLink
(self.get_module_from_parent(parent), name); (self.get_module_from_parent(parent), name);
let external_module = @mut Module(parent_link, let external_module = @mut Module::new(parent_link,
Some(def_id), Some(def_id),
NormalModuleKind, NormalModuleKind,
false); false);
@ -1635,7 +1640,7 @@ impl Resolver {
block_id); block_id);
let parent_module = self.get_module_from_parent(parent); let parent_module = self.get_module_from_parent(parent);
let new_module = @mut Module( let new_module = @mut Module::new(
BlockParentLink(parent_module, block_id), BlockParentLink(parent_module, block_id),
None, None,
AnonymousModuleKind, AnonymousModuleKind,
@ -1777,10 +1782,10 @@ impl Resolver {
/// Builds the reduced graph for a single item in an external crate. /// Builds the reduced graph for a single item in an external crate.
fn build_reduced_graph_for_external_crate_def(@mut self, fn build_reduced_graph_for_external_crate_def(@mut self,
root: @mut Module, root: @mut Module,
def_like: def_like, def_like: DefLike,
ident: ident) { ident: ident) {
match def_like { match def_like {
dl_def(def) => { DlDef(def) => {
// Add the new child item, if necessary. // Add the new child item, if necessary.
match def { match def {
def_foreign_mod(def_id) => { def_foreign_mod(def_id) => {
@ -1811,7 +1816,7 @@ impl Resolver {
} }
} }
} }
dl_impl(def) => { DlImpl(def) => {
// We only process static methods of impls here. // We only process static methods of impls here.
match get_type_name_if_impl(self.session.cstore, def) { match get_type_name_if_impl(self.session.cstore, def) {
None => {} None => {}
@ -1900,7 +1905,7 @@ impl Resolver {
} }
} }
} }
dl_field => { DlField => {
debug!("(building reduced graph for external crate) \ debug!("(building reduced graph for external crate) \
ignoring field"); ignoring field");
} }
@ -1959,9 +1964,9 @@ impl Resolver {
module_: @mut Module, module_: @mut Module,
module_path: ~[ident], module_path: ~[ident],
subclass: @ImportDirectiveSubclass, subclass: @ImportDirectiveSubclass,
span: span, span: Span,
id: NodeId) { id: NodeId) {
let directive = @ImportDirective(privacy, module_path, let directive = @ImportDirective::new(privacy, module_path,
subclass, span, id); subclass, span, id);
module_.imports.push(directive); module_.imports.push(directive);
@ -1989,7 +1994,7 @@ impl Resolver {
} }
None => { None => {
debug!("(building import directive) creating new"); debug!("(building import directive) creating new");
let resolution = @mut ImportResolution(privacy, id); let resolution = @mut ImportResolution::new(privacy, id);
resolution.outstanding_references = 1; resolution.outstanding_references = 1;
module_.import_resolutions.insert(target, resolution); module_.import_resolutions.insert(target, resolution);
} }
@ -2402,7 +2407,7 @@ impl Resolver {
BoundResult(target_module, name_bindings) => { BoundResult(target_module, name_bindings) => {
debug!("(resolving single import) found value target"); debug!("(resolving single import) found value target");
import_resolution.value_target = import_resolution.value_target =
Some(Target(target_module, name_bindings)); Some(Target::new(target_module, name_bindings));
import_resolution.value_id = directive.id; import_resolution.value_id = directive.id;
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
@ -2415,7 +2420,7 @@ impl Resolver {
debug!("(resolving single import) found type target: %?", debug!("(resolving single import) found type target: %?",
name_bindings.type_def.unwrap().type_def); name_bindings.type_def.unwrap().type_def);
import_resolution.type_target = import_resolution.type_target =
Some(Target(target_module, name_bindings)); Some(Target::new(target_module, name_bindings));
import_resolution.type_id = directive.id; import_resolution.type_id = directive.id;
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
@ -2522,7 +2527,7 @@ impl Resolver {
None if target_import_resolution.privacy == Public => { None if target_import_resolution.privacy == Public => {
// Simple: just copy the old import resolution. // Simple: just copy the old import resolution.
let new_import_resolution = let new_import_resolution =
@mut ImportResolution(privacy, id); @mut ImportResolution::new(privacy, id);
new_import_resolution.value_target = new_import_resolution.value_target =
target_import_resolution.value_target; target_import_resolution.value_target;
new_import_resolution.type_target = new_import_resolution.type_target =
@ -2564,7 +2569,7 @@ impl Resolver {
match module_.import_resolutions.find(&ident) { match module_.import_resolutions.find(&ident) {
None => { None => {
// Create a new import resolution from this child. // Create a new import resolution from this child.
dest_import_resolution = @mut ImportResolution(privacy, id); dest_import_resolution = @mut ImportResolution::new(privacy, id);
module_.import_resolutions.insert module_.import_resolutions.insert
(ident, dest_import_resolution); (ident, dest_import_resolution);
} }
@ -2584,13 +2589,13 @@ impl Resolver {
if name_bindings.defined_in_public_namespace(ValueNS) { if name_bindings.defined_in_public_namespace(ValueNS) {
debug!("(resolving glob import) ... for value target"); debug!("(resolving glob import) ... for value target");
dest_import_resolution.value_target = dest_import_resolution.value_target =
Some(Target(containing_module, name_bindings)); Some(Target::new(containing_module, name_bindings));
dest_import_resolution.value_id = id; dest_import_resolution.value_id = id;
} }
if name_bindings.defined_in_public_namespace(TypeNS) { if name_bindings.defined_in_public_namespace(TypeNS) {
debug!("(resolving glob import) ... for type target"); debug!("(resolving glob import) ... for type target");
dest_import_resolution.type_target = dest_import_resolution.type_target =
Some(Target(containing_module, name_bindings)); Some(Target::new(containing_module, name_bindings));
dest_import_resolution.type_id = id; dest_import_resolution.type_id = id;
} }
}; };
@ -2617,7 +2622,7 @@ impl Resolver {
module_: @mut Module, module_: @mut Module,
module_path: &[ident], module_path: &[ident],
index: uint, index: uint,
span: span, span: Span,
mut name_search_type: NameSearchType) mut name_search_type: NameSearchType)
-> ResolveResult<@mut Module> { -> ResolveResult<@mut Module> {
let mut search_module = module_; let mut search_module = module_;
@ -2637,7 +2642,7 @@ impl Resolver {
let segment_name = self.session.str_of(name); let segment_name = self.session.str_of(name);
let module_name = self.module_to_str(search_module); let module_name = self.module_to_str(search_module);
if "???" == module_name { if "???" == module_name {
let span = span { let span = Span {
lo: span.lo, lo: span.lo,
hi: span.lo + BytePos(segment_name.len()), hi: span.lo + BytePos(segment_name.len()),
expn_info: span.expn_info, expn_info: span.expn_info,
@ -2726,7 +2731,7 @@ impl Resolver {
module_: @mut Module, module_: @mut Module,
module_path: &[ident], module_path: &[ident],
use_lexical_scope: UseLexicalScopeFlag, use_lexical_scope: UseLexicalScopeFlag,
span: span, span: Span,
name_search_type: NameSearchType) name_search_type: NameSearchType)
-> ResolveResult<@mut Module> { -> ResolveResult<@mut Module> {
let module_path_len = module_path.len(); let module_path_len = module_path.len();
@ -2834,7 +2839,7 @@ impl Resolver {
match module_.children.find(&name) { match module_.children.find(&name) {
Some(name_bindings) Some(name_bindings)
if name_bindings.defined_in_namespace(namespace) => { if name_bindings.defined_in_namespace(namespace) => {
return Success(Target(module_, *name_bindings)); return Success(Target::new(module_, *name_bindings));
} }
Some(_) | None => { /* Not found; continue. */ } Some(_) | None => { /* Not found; continue. */ }
} }
@ -2873,7 +2878,7 @@ impl Resolver {
let name_bindings = let name_bindings =
@mut Resolver::create_name_bindings_from_module( @mut Resolver::create_name_bindings_from_module(
*module); *module);
return Success(Target(module_, name_bindings)); return Success(Target::new(module_, name_bindings));
} }
} }
} }
@ -3090,7 +3095,7 @@ impl Resolver {
Some(name_bindings) Some(name_bindings)
if name_bindings.defined_in_namespace(namespace) => { if name_bindings.defined_in_namespace(namespace) => {
debug!("(resolving name in module) found node as child"); debug!("(resolving name in module) found node as child");
return Success(Target(module_, *name_bindings)); return Success(Target::new(module_, *name_bindings));
} }
Some(_) | None => { Some(_) | None => {
// Continue. // Continue.
@ -3148,7 +3153,7 @@ impl Resolver {
let name_bindings = let name_bindings =
@mut Resolver::create_name_bindings_from_module( @mut Resolver::create_name_bindings_from_module(
*module); *module);
return Success(Target(module_, name_bindings)); return Success(Target::new(module_, name_bindings));
} }
} }
} }
@ -3382,24 +3387,24 @@ impl Resolver {
pub fn upvarify(@mut self, pub fn upvarify(@mut self,
ribs: &mut ~[@Rib], ribs: &mut ~[@Rib],
rib_index: uint, rib_index: uint,
def_like: def_like, def_like: DefLike,
span: span, span: Span,
allow_capturing_self: AllowCapturingSelfFlag) allow_capturing_self: AllowCapturingSelfFlag)
-> Option<def_like> { -> Option<DefLike> {
let mut def; let mut def;
let is_ty_param; let is_ty_param;
match def_like { match def_like {
dl_def(d @ def_local(*)) | dl_def(d @ def_upvar(*)) | DlDef(d @ def_local(*)) | DlDef(d @ def_upvar(*)) |
dl_def(d @ def_arg(*)) | dl_def(d @ def_binding(*)) => { DlDef(d @ def_arg(*)) | DlDef(d @ def_binding(*)) => {
def = d; def = d;
is_ty_param = false; is_ty_param = false;
} }
dl_def(d @ def_ty_param(*)) => { DlDef(d @ def_ty_param(*)) => {
def = d; def = d;
is_ty_param = true; is_ty_param = true;
} }
dl_def(d @ def_self(*)) DlDef(d @ def_self(*))
if allow_capturing_self == DontAllowCapturingSelf => { if allow_capturing_self == DontAllowCapturingSelf => {
def = d; def = d;
is_ty_param = false; is_ty_param = false;
@ -3488,15 +3493,15 @@ impl Resolver {
rib_index += 1; rib_index += 1;
} }
return Some(dl_def(def)); return Some(DlDef(def));
} }
pub fn search_ribs(@mut self, pub fn search_ribs(@mut self,
ribs: &mut ~[@Rib], ribs: &mut ~[@Rib],
name: ident, name: ident,
span: span, span: Span,
allow_capturing_self: AllowCapturingSelfFlag) allow_capturing_self: AllowCapturingSelfFlag)
-> Option<def_like> { -> Option<DefLike> {
// FIXME #4950: This should not use a while loop. // FIXME #4950: This should not use a while loop.
// FIXME #4950: Try caching? // FIXME #4950: Try caching?
@ -3584,10 +3589,10 @@ impl Resolver {
item_trait(ref generics, ref traits, ref methods) => { item_trait(ref generics, ref traits, ref methods) => {
// Create a new rib for the self type. // Create a new rib for the self type.
let self_type_rib = @Rib(NormalRibKind); let self_type_rib = @Rib::new(NormalRibKind);
self.type_ribs.push(self_type_rib); self.type_ribs.push(self_type_rib);
self_type_rib.bindings.insert(self.type_self_ident, self_type_rib.bindings.insert(self.type_self_ident,
dl_def(def_self_ty(item.id))); DlDef(def_self_ty(item.id)));
// Create a new rib for the trait-wide type parameters. // Create a new rib for the trait-wide type parameters.
do self.with_type_parameter_rib do self.with_type_parameter_rib
@ -3714,14 +3719,14 @@ impl Resolver {
HasTypeParameters(generics, node_id, initial_index, HasTypeParameters(generics, node_id, initial_index,
rib_kind) => { rib_kind) => {
let function_type_rib = @Rib(rib_kind); let function_type_rib = @Rib::new(rib_kind);
self.type_ribs.push(function_type_rib); self.type_ribs.push(function_type_rib);
for (index, type_parameter) in generics.ty_params.iter().enumerate() { for (index, type_parameter) in generics.ty_params.iter().enumerate() {
let name = type_parameter.ident; let name = type_parameter.ident;
debug!("with_type_parameter_rib: %d %d", node_id, debug!("with_type_parameter_rib: %d %d", node_id,
type_parameter.id); type_parameter.id);
let def_like = dl_def(def_ty_param let def_like = DlDef(def_ty_param
(local_def(type_parameter.id), (local_def(type_parameter.id),
index + initial_index)); index + initial_index));
// Associate this type parameter with // Associate this type parameter with
@ -3751,13 +3756,13 @@ impl Resolver {
} }
pub fn with_label_rib(@mut self, f: &fn()) { pub fn with_label_rib(@mut self, f: &fn()) {
self.label_ribs.push(@Rib(NormalRibKind)); self.label_ribs.push(@Rib::new(NormalRibKind));
f(); f();
self.label_ribs.pop(); self.label_ribs.pop();
} }
pub fn with_constant_rib(@mut self, f: &fn()) { pub fn with_constant_rib(@mut self, f: &fn()) {
self.value_ribs.push(@Rib(ConstantItemRibKind)); self.value_ribs.push(@Rib::new(ConstantItemRibKind));
f(); f();
self.value_ribs.pop(); self.value_ribs.pop();
} }
@ -3770,11 +3775,11 @@ impl Resolver {
self_binding: SelfBinding, self_binding: SelfBinding,
visitor: &mut ResolveVisitor) { visitor: &mut ResolveVisitor) {
// Create a value rib for the function. // Create a value rib for the function.
let function_value_rib = @Rib(rib_kind); let function_value_rib = @Rib::new(rib_kind);
self.value_ribs.push(function_value_rib); self.value_ribs.push(function_value_rib);
// Create a label rib for the function. // Create a label rib for the function.
let function_label_rib = @Rib(rib_kind); let function_label_rib = @Rib::new(rib_kind);
self.label_ribs.push(function_label_rib); self.label_ribs.push(function_label_rib);
// If this function has type parameters, add them now. // If this function has type parameters, add them now.
@ -3796,7 +3801,7 @@ impl Resolver {
// Nothing to do. // Nothing to do.
} }
HasSelfBinding(self_node_id) => { HasSelfBinding(self_node_id) => {
let def_like = dl_def(def_self(self_node_id)); let def_like = DlDef(def_self(self_node_id));
*function_value_rib.self_binding = Some(def_like); *function_value_rib.self_binding = Some(def_like);
} }
} }
@ -4029,7 +4034,7 @@ impl Resolver {
pub fn resolve_module(@mut self, pub fn resolve_module(@mut self,
module_: &_mod, module_: &_mod,
_span: span, _span: Span,
_name: ident, _name: ident,
id: NodeId, id: NodeId,
visitor: &mut ResolveVisitor) { visitor: &mut ResolveVisitor) {
@ -4110,7 +4115,7 @@ impl Resolver {
} }
pub fn resolve_arm(@mut self, arm: &arm, visitor: &mut ResolveVisitor) { pub fn resolve_arm(@mut self, arm: &arm, visitor: &mut ResolveVisitor) {
self.value_ribs.push(@Rib(NormalRibKind)); self.value_ribs.push(@Rib::new(NormalRibKind));
let bindings_list = @mut HashMap::new(); let bindings_list = @mut HashMap::new();
for pattern in arm.pats.iter() { for pattern in arm.pats.iter() {
@ -4130,7 +4135,7 @@ impl Resolver {
pub fn resolve_block(@mut self, block: &Block, visitor: &mut ResolveVisitor) { pub fn resolve_block(@mut self, block: &Block, visitor: &mut ResolveVisitor) {
debug!("(resolving block) entering block"); debug!("(resolving block) entering block");
self.value_ribs.push(@Rib(NormalRibKind)); self.value_ribs.push(@Rib::new(NormalRibKind));
// Move down in the graph, if there's an anonymous module rooted here. // Move down in the graph, if there's an anonymous module rooted here.
let orig_module = self.current_module; let orig_module = self.current_module;
@ -4366,7 +4371,7 @@ impl Resolver {
let last_rib = this.value_ribs[ let last_rib = this.value_ribs[
this.value_ribs.len() - 1]; this.value_ribs.len() - 1];
last_rib.bindings.insert(ident, last_rib.bindings.insert(ident,
dl_def(def)); DlDef(def));
bindings_list.insert(ident, pat_id); bindings_list.insert(ident, pat_id);
} }
Some(b) => { Some(b) => {
@ -4387,7 +4392,7 @@ impl Resolver {
let last_rib = this.value_ribs[ let last_rib = this.value_ribs[
this.value_ribs.len() - 1]; this.value_ribs.len() - 1];
last_rib.bindings.insert(ident, last_rib.bindings.insert(ident,
dl_def(def)); DlDef(def));
} }
} }
} }
@ -4602,7 +4607,7 @@ impl Resolver {
identifier: ident, identifier: ident,
namespace: Namespace, namespace: Namespace,
check_ribs: bool, check_ribs: bool,
span: span) span: Span)
-> Option<def> { -> Option<def> {
if check_ribs { if check_ribs {
match self.resolve_identifier_in_local_ribs(identifier, match self.resolve_identifier_in_local_ribs(identifier,
@ -4826,7 +4831,7 @@ impl Resolver {
pub fn resolve_identifier_in_local_ribs(@mut self, pub fn resolve_identifier_in_local_ribs(@mut self,
ident: ident, ident: ident,
namespace: Namespace, namespace: Namespace,
span: span) span: Span)
-> Option<def> { -> Option<def> {
// Check the local set of ribs. // Check the local set of ribs.
let search_result; let search_result;
@ -4843,20 +4848,20 @@ impl Resolver {
} }
match search_result { match search_result {
Some(dl_def(def)) => { Some(DlDef(def)) => {
debug!("(resolving path in local ribs) resolved `%s` to \ debug!("(resolving path in local ribs) resolved `%s` to \
local: %?", local: %?",
self.session.str_of(ident), self.session.str_of(ident),
def); def);
return Some(def); return Some(def);
} }
Some(dl_field) | Some(dl_impl(_)) | None => { Some(DlField) | Some(DlImpl(_)) | None => {
return None; return None;
} }
} }
} }
pub fn resolve_self_value_in_local_ribs(@mut self, span: span) pub fn resolve_self_value_in_local_ribs(@mut self, span: Span)
-> Option<def> { -> Option<def> {
// FIXME #4950: This should not use a while loop. // FIXME #4950: This should not use a while loop.
let ribs = &mut self.value_ribs; let ribs = &mut self.value_ribs;
@ -4870,7 +4875,7 @@ impl Resolver {
def_like, def_like,
span, span,
DontAllowCapturingSelf) { DontAllowCapturingSelf) {
Some(dl_def(def)) => return Some(def), Some(DlDef(def)) => return Some(def),
_ => { _ => {
if self.session.has_errors() { if self.session.has_errors() {
// May happen inside a nested fn item, cf #6642. // May happen inside a nested fn item, cf #6642.
@ -4929,7 +4934,7 @@ impl Resolver {
rs rs
} }
fn resolve_error(@mut self, span: span, s: &str) { fn resolve_error(@mut self, span: Span, s: &str) {
if self.emit_errors { if self.emit_errors {
self.session.span_err(span, s); self.session.span_err(span, s);
} }
@ -5135,7 +5140,7 @@ impl Resolver {
do self.with_label_rib { do self.with_label_rib {
{ {
let this = &mut *self; let this = &mut *self;
let def_like = dl_def(def_label(expr.id)); let def_like = DlDef(def_label(expr.id));
let rib = this.label_ribs[this.label_ribs.len() - 1]; let rib = this.label_ribs[this.label_ribs.len() - 1];
rib.bindings.insert(label, def_like); rib.bindings.insert(label, def_like);
} }
@ -5155,7 +5160,7 @@ impl Resolver {
`%s`", `%s`",
self.session.str_of( self.session.str_of(
label))), label))),
Some(dl_def(def @ def_label(_))) => { Some(DlDef(def @ def_label(_))) => {
self.record_def(expr.id, def) self.record_def(expr.id, def)
} }
Some(_) => { Some(_) => {

View File

@ -21,7 +21,7 @@ use middle::ty;
use syntax::ast; use syntax::ast;
use syntax::ast_map; use syntax::ast_map;
use syntax::attr; use syntax::attr;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
use util::ppaux::Repr; use util::ppaux::Repr;
@ -39,7 +39,7 @@ impl Visitor<Context> for StackCheckVisitor {
stack_check_item(*self, i, e); stack_check_item(*self, i, e);
} }
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:span, n:ast::NodeId, e:Context) { b:&ast::Block, s:Span, n:ast::NodeId, e:Context) {
stack_check_fn(*self, fk, fd, b, s, n, e); stack_check_fn(*self, fk, fd, b, s, n, e);
} }
fn visit_expr(&mut self, ex:@ast::expr, e:Context) { fn visit_expr(&mut self, ex:@ast::expr, e:Context) {
@ -94,7 +94,7 @@ fn stack_check_fn<'a>(v: StackCheckVisitor,
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &ast::fn_decl, decl: &ast::fn_decl,
body: &ast::Block, body: &ast::Block,
sp: span, sp: Span,
id: ast::NodeId, id: ast::NodeId,
in_cx: Context) { in_cx: Context) {
let safe_stack = match *fk { let safe_stack = match *fk {

View File

@ -225,7 +225,7 @@ use syntax::ast;
use syntax::ast::ident; use syntax::ast::ident;
use syntax::ast_util::path_to_ident; use syntax::ast_util::path_to_ident;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::{span, dummy_sp}; use syntax::codemap::{Span, dummy_sp};
// An option identifying a literal: either a unit-like struct or an // An option identifying a literal: either a unit-like struct or an
// expression. // expression.
@ -386,7 +386,7 @@ struct BindingInfo {
llmatch: ValueRef, llmatch: ValueRef,
trmode: TransBindingMode, trmode: TransBindingMode,
id: ast::NodeId, id: ast::NodeId,
span: span, span: Span,
ty: ty::t, ty: ty::t,
} }
@ -1014,7 +1014,7 @@ fn match_datum(bcx: @mut Block, val: ValueRef, pat_id: ast::NodeId) -> Datum {
fn extract_vec_elems(bcx: @mut Block, fn extract_vec_elems(bcx: @mut Block,
pat_span: span, pat_span: Span,
pat_id: ast::NodeId, pat_id: ast::NodeId,
elem_count: uint, elem_count: uint,
slice: Option<uint>, slice: Option<uint>,
@ -1891,7 +1891,7 @@ fn trans_match_inner(scope_cx: @mut Block,
bcx = controlflow::join_blocks(scope_cx, arm_cxs); bcx = controlflow::join_blocks(scope_cx, arm_cxs);
return bcx; return bcx;
fn mk_fail(bcx: @mut Block, sp: span, msg: @str, fn mk_fail(bcx: @mut Block, sp: Span, msg: @str,
finished: @mut Option<BasicBlockRef>) -> BasicBlockRef { finished: @mut Option<BasicBlockRef>) -> BasicBlockRef {
match *finished { Some(bb) => return bb, _ => () } match *finished { Some(bb) => return bb, _ => () }
let fail_cx = sub_block(bcx, "case_fallthrough"); let fail_cx = sub_block(bcx, "case_fallthrough");

View File

@ -81,7 +81,7 @@ use syntax::ast_map::{path, path_elt_to_str, path_name};
use syntax::ast_util::{local_def}; use syntax::ast_util::{local_def};
use syntax::attr; use syntax::attr;
use syntax::attr::AttrMetaMethods; use syntax::attr::AttrMetaMethods;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token; use syntax::parse::token;
use syntax::parse::token::{special_idents}; use syntax::parse::token::{special_idents};
use syntax::print::pprust::stmt_to_str; use syntax::print::pprust::stmt_to_str;
@ -138,7 +138,7 @@ fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
} }
} }
fn span_is_empty(opt_span: &Option<span>) -> bool { fn span_is_empty(opt_span: &Option<Span>) -> bool {
match *opt_span { match *opt_span {
None => true, None => true,
Some(span) => *span.lo == 0 && *span.hi == 0 Some(span) => *span.lo == 0 && *span.hi == 0
@ -791,7 +791,7 @@ pub fn cast_shift_rhs(op: ast::binop,
} }
} }
pub fn fail_if_zero(cx: @mut Block, span: span, divrem: ast::binop, pub fn fail_if_zero(cx: @mut Block, span: Span, divrem: ast::binop,
rhs: ValueRef, rhs_t: ty::t) -> @mut Block { rhs: ValueRef, rhs_t: ty::t) -> @mut Block {
let text = if divrem == ast::div { let text = if divrem == ast::div {
@"attempted to divide by zero" @"attempted to divide by zero"
@ -1064,7 +1064,7 @@ pub fn load_if_immediate(cx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
return v; return v;
} }
pub fn trans_trace(bcx: @mut Block, sp_opt: Option<span>, trace_str: @str) { pub fn trans_trace(bcx: @mut Block, sp_opt: Option<Span>, trace_str: @str) {
if !bcx.sess().trace() { return; } if !bcx.sess().trace() { return; }
let _icx = push_ctxt("trans_trace"); let _icx = push_ctxt("trans_trace");
add_comment(bcx, trace_str); add_comment(bcx, trace_str);
@ -1615,7 +1615,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
skip_retptr: bool, skip_retptr: bool,
param_substs: Option<@param_substs>, param_substs: Option<@param_substs>,
opt_node_info: Option<NodeInfo>, opt_node_info: Option<NodeInfo>,
sp: Option<span>) sp: Option<Span>)
-> @mut FunctionContext { -> @mut FunctionContext {
for p in param_substs.iter() { p.validate(); } for p in param_substs.iter() { p.validate(); }
@ -1690,7 +1690,7 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
path: path, path: path,
llfndecl: ValueRef, llfndecl: ValueRef,
output_type: ty::t, output_type: ty::t,
sp: Option<span>) sp: Option<Span>)
-> @mut FunctionContext { -> @mut FunctionContext {
new_fn_ctxt_w_id(ccx, path, llfndecl, -1, output_type, false, None, None, sp) new_fn_ctxt_w_id(ccx, path, llfndecl, -1, output_type, false, None, None, sp)
} }
@ -2283,7 +2283,7 @@ pub fn trans_mod(ccx: @mut CrateContext, m: &ast::_mod) {
} }
pub fn register_fn(ccx: @mut CrateContext, pub fn register_fn(ccx: @mut CrateContext,
sp: span, sp: Span,
sym: ~str, sym: ~str,
node_id: ast::NodeId, node_id: ast::NodeId,
node_type: ty::t) node_type: ty::t)
@ -2293,7 +2293,7 @@ pub fn register_fn(ccx: @mut CrateContext,
} }
pub fn register_fn_llvmty(ccx: @mut CrateContext, pub fn register_fn_llvmty(ccx: @mut CrateContext,
sp: span, sp: Span,
sym: ~str, sym: ~str,
node_id: ast::NodeId, node_id: ast::NodeId,
cc: lib::llvm::CallConv, cc: lib::llvm::CallConv,
@ -2309,7 +2309,7 @@ pub fn register_fn_llvmty(ccx: @mut CrateContext,
// FIXME #4404 android JNI hacks // FIXME #4404 android JNI hacks
let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library || let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library ||
(*ccx.sess.building_library && (*ccx.sess.building_library &&
ccx.sess.targ_cfg.os == session::os_android)); ccx.sess.targ_cfg.os == session::OsAndroid));
if is_entry { if is_entry {
create_entry_wrapper(ccx, sp, llfn); create_entry_wrapper(ccx, sp, llfn);
} }
@ -2326,7 +2326,7 @@ pub fn is_entry_fn(sess: &Session, node_id: ast::NodeId) -> bool {
// Create a _rust_main(args: ~[str]) function which will be called from the // Create a _rust_main(args: ~[str]) function which will be called from the
// runtime rust_start function // runtime rust_start function
pub fn create_entry_wrapper(ccx: @mut CrateContext, pub fn create_entry_wrapper(ccx: @mut CrateContext,
_sp: span, _sp: Span,
main_llfn: ValueRef) { main_llfn: ValueRef) {
let et = ccx.sess.entry_type.unwrap(); let et = ccx.sess.entry_type.unwrap();
match et { match et {

View File

@ -15,7 +15,7 @@ use lib::llvm::{Opcode, IntPredicate, RealPredicate};
use lib::llvm::{ValueRef, BasicBlockRef}; use lib::llvm::{ValueRef, BasicBlockRef};
use lib; use lib;
use middle::trans::common::*; use middle::trans::common::*;
use syntax::codemap::span; use syntax::codemap::Span;
use middle::trans::builder::Builder; use middle::trans::builder::Builder;
use middle::trans::type_::Type; use middle::trans::type_::Type;
@ -629,7 +629,7 @@ pub fn _UndefReturn(cx: @mut Block, Fn: ValueRef) -> ValueRef {
} }
} }
pub fn add_span_comment(cx: @mut Block, sp: span, text: &str) { pub fn add_span_comment(cx: @mut Block, sp: Span, text: &str) {
B(cx).add_span_comment(sp, text) B(cx).add_span_comment(sp, text)
} }

View File

@ -21,7 +21,7 @@ use std::cast;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::libc::{c_uint, c_ulonglong, c_char}; use std::libc::{c_uint, c_ulonglong, c_char};
use std::vec; use std::vec;
use syntax::codemap::span; use syntax::codemap::Span;
use std::ptr::is_not_null; use std::ptr::is_not_null;
pub struct Builder { pub struct Builder {
@ -728,7 +728,7 @@ impl Builder {
} }
} }
pub fn add_span_comment(&self, sp: span, text: &str) { pub fn add_span_comment(&self, sp: Span, text: &str) {
if self.ccx.sess.asm_comments() { if self.ccx.sess.asm_comments() {
let s = fmt!("%s (%s)", text, self.ccx.sess.codemap.span_to_str(sp)); let s = fmt!("%s (%s)", text, self.ccx.sess.codemap.span_to_str(sp));
debug!("%s", s); debug!("%s", s);

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use driver::session::{os_win32, os_macos}; use driver::session::{OsWin32, OsMacos};
use lib::llvm::*; use lib::llvm::*;
use super::cabi::*; use super::cabi::*;
use super::common::*; use super::common::*;
@ -42,7 +42,7 @@ pub fn compute_abi_info(ccx: &mut CrateContext,
enum Strategy { RetValue(Type), RetPointer } enum Strategy { RetValue(Type), RetPointer }
let strategy = match ccx.sess.targ_cfg.os { let strategy = match ccx.sess.targ_cfg.os {
os_win32 | os_macos => { OsWin32 | OsMacos => {
match llsize_of_alloc(ccx, rty) { match llsize_of_alloc(ccx, rty) {
1 => RetValue(Type::i8()), 1 => RetValue(Type::i8()),
2 => RetValue(Type::i16()), 2 => RetValue(Type::i16()),

View File

@ -40,7 +40,7 @@ use std::libc::{c_uint, c_longlong, c_ulonglong, c_char};
use std::vec; use std::vec;
use syntax::ast::ident; use syntax::ast::ident;
use syntax::ast_map::{path, path_elt}; use syntax::ast_map::{path, path_elt};
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token; use syntax::parse::token;
use syntax::{ast, ast_map}; use syntax::{ast, ast_map};
@ -220,7 +220,7 @@ pub struct FunctionContext {
// The source span and nesting context where this function comes from, for // The source span and nesting context where this function comes from, for
// error reporting and symbol generation. // error reporting and symbol generation.
span: Option<span>, span: Option<Span>,
path: path, path: path,
// This function's enclosing crate context. // This function's enclosing crate context.
@ -509,7 +509,7 @@ impl get_node_info for Option<@ast::expr> {
pub struct NodeInfo { pub struct NodeInfo {
id: ast::NodeId, id: ast::NodeId,
callee_id: Option<ast::NodeId>, callee_id: Option<ast::NodeId>,
span: span span: Span
} }
// Basic block context. We create a block context for each basic block // Basic block context. We create a block context for each basic block
@ -1110,7 +1110,7 @@ pub fn dummy_substs(tps: ~[ty::t]) -> ty::substs {
} }
pub fn filename_and_line_num_from_span(bcx: @mut Block, pub fn filename_and_line_num_from_span(bcx: @mut Block,
span: span) -> (ValueRef, ValueRef) { span: Span) -> (ValueRef, ValueRef) {
let loc = bcx.sess().parse_sess.cm.lookup_char_pos(span.lo); let loc = bcx.sess().parse_sess.cm.lookup_char_pos(span.lo);
let filename_cstr = C_cstr(bcx.ccx(), loc.file.name); let filename_cstr = C_cstr(bcx.ccx(), loc.file.name);
let filename = build::PointerCast(bcx, filename_cstr, Type::i8p()); let filename = build::PointerCast(bcx, filename_cstr, Type::i8p());
@ -1123,7 +1123,7 @@ pub fn bool_to_i1(bcx: @mut Block, llval: ValueRef) -> ValueRef {
build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(false)) build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(false))
} }
pub fn langcall(bcx: @mut Block, span: Option<span>, msg: &str, pub fn langcall(bcx: @mut Block, span: Option<Span>, msg: &str,
li: LangItem) -> ast::def_id { li: LangItem) -> ast::def_id {
match bcx.tcx().lang_items.require(li) { match bcx.tcx().lang_items.require(li) {
Ok(id) => id, Ok(id) => id,

View File

@ -30,7 +30,7 @@ use syntax::ast;
use syntax::ast::ident; use syntax::ast::ident;
use syntax::ast_map::path_mod; use syntax::ast_map::path_mod;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
pub fn trans_block(bcx: @mut Block, b: &ast::Block, dest: expr::Dest) -> @mut Block { pub fn trans_block(bcx: @mut Block, b: &ast::Block, dest: expr::Dest) -> @mut Block {
let _icx = push_ctxt("trans_block"); let _icx = push_ctxt("trans_block");
@ -353,7 +353,7 @@ pub fn trans_ret(bcx: @mut Block, e: Option<@ast::expr>) -> @mut Block {
} }
pub fn trans_fail_expr(bcx: @mut Block, pub fn trans_fail_expr(bcx: @mut Block,
sp_opt: Option<span>, sp_opt: Option<Span>,
fail_expr: Option<@ast::expr>) fail_expr: Option<@ast::expr>)
-> @mut Block { -> @mut Block {
let _icx = push_ctxt("trans_fail_expr"); let _icx = push_ctxt("trans_fail_expr");
@ -381,7 +381,7 @@ pub fn trans_fail_expr(bcx: @mut Block,
} }
pub fn trans_fail(bcx: @mut Block, pub fn trans_fail(bcx: @mut Block,
sp_opt: Option<span>, sp_opt: Option<Span>,
fail_str: @str) fail_str: @str)
-> @mut Block { -> @mut Block {
let _icx = push_ctxt("trans_fail"); let _icx = push_ctxt("trans_fail");
@ -390,7 +390,7 @@ pub fn trans_fail(bcx: @mut Block,
} }
fn trans_fail_value(bcx: @mut Block, fn trans_fail_value(bcx: @mut Block,
sp_opt: Option<span>, sp_opt: Option<Span>,
V_fail_str: ValueRef) V_fail_str: ValueRef)
-> @mut Block { -> @mut Block {
let _icx = push_ctxt("trans_fail_value"); let _icx = push_ctxt("trans_fail_value");
@ -415,7 +415,7 @@ fn trans_fail_value(bcx: @mut Block,
return bcx; return bcx;
} }
pub fn trans_fail_bounds_check(bcx: @mut Block, sp: span, pub fn trans_fail_bounds_check(bcx: @mut Block, sp: Span,
index: ValueRef, len: ValueRef) -> @mut Block { index: ValueRef, len: ValueRef) -> @mut Block {
let _icx = push_ctxt("trans_fail_bounds_check"); let _icx = push_ctxt("trans_fail_bounds_check");
let (filename, line) = filename_and_line_num_from_span(bcx, sp); let (filename, line) = filename_and_line_num_from_span(bcx, sp);

View File

@ -106,7 +106,7 @@ use util::ppaux::ty_to_str;
use std::uint; use std::uint;
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
#[deriving(Eq)] #[deriving(Eq)]
@ -613,7 +613,7 @@ impl Datum {
/// is_auto: If true, only deref if auto-derefable. /// is_auto: If true, only deref if auto-derefable.
pub fn try_deref(&self, pub fn try_deref(&self,
bcx: @mut Block, bcx: @mut Block,
span: span, span: Span,
expr_id: ast::NodeId, expr_id: ast::NodeId,
derefs: uint, derefs: uint,
is_auto: bool) is_auto: bool)
@ -739,7 +739,7 @@ impl Datum {
pub fn autoderef(&self, pub fn autoderef(&self,
bcx: @mut Block, bcx: @mut Block,
span: span, span: Span,
expr_id: ast::NodeId, expr_id: ast::NodeId,
max: uint) max: uint)
-> DatumBlock { -> DatumBlock {
@ -772,7 +772,7 @@ impl Datum {
pub fn get_vec_base_and_len(&self, pub fn get_vec_base_and_len(&self,
mut bcx: @mut Block, mut bcx: @mut Block,
span: span, span: Span,
expr_id: ast::NodeId, expr_id: ast::NodeId,
derefs: uint) derefs: uint)
-> (@mut Block, ValueRef, ValueRef) { -> (@mut Block, ValueRef, ValueRef) {
@ -796,7 +796,7 @@ impl Datum {
pub fn root_and_write_guard(&self, pub fn root_and_write_guard(&self,
bcx: @mut Block, bcx: @mut Block,
span: span, span: Span,
expr_id: ast::NodeId, expr_id: ast::NodeId,
derefs: uint) derefs: uint)
-> @mut Block { -> @mut Block {

View File

@ -68,7 +68,7 @@ use std::hashmap::HashMap;
use std::libc::{c_uint, c_ulonglong, c_longlong}; use std::libc::{c_uint, c_ulonglong, c_longlong};
use std::ptr; use std::ptr;
use std::vec; use std::vec;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::{ast, codemap, ast_util, ast_map, opt_vec}; use syntax::{ast, codemap, ast_util, ast_map, opt_vec};
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
@ -158,7 +158,7 @@ pub fn create_match_binding_metadata(bcx: @mut Block,
variable_ident: ast::ident, variable_ident: ast::ident,
node_id: ast::NodeId, node_id: ast::NodeId,
variable_type: ty::t, variable_type: ty::t,
span: span) { span: Span) {
declare_local(bcx, variable_ident, node_id, variable_type, span); declare_local(bcx, variable_ident, node_id, variable_type, span);
} }
@ -296,7 +296,7 @@ pub fn create_argument_metadata(bcx: @mut Block,
/// reliably find the correct visibility scope for the code position. /// reliably find the correct visibility scope for the code position.
pub fn set_source_location(fcx: &FunctionContext, pub fn set_source_location(fcx: &FunctionContext,
node_id: ast::NodeId, node_id: ast::NodeId,
span: span) { span: Span) {
let cx: &mut CrateContext = fcx.ccx; let cx: &mut CrateContext = fcx.ccx;
if !cx.sess.opts.debuginfo || (*span.lo == 0 && *span.hi == 0) { if !cx.sess.opts.debuginfo || (*span.lo == 0 && *span.hi == 0) {
@ -643,7 +643,7 @@ fn declare_local(bcx: @mut Block,
variable_ident: ast::ident, variable_ident: ast::ident,
node_id: ast::NodeId, node_id: ast::NodeId,
variable_type: ty::t, variable_type: ty::t,
span: span) { span: Span) {
let cx: &mut CrateContext = bcx.ccx(); let cx: &mut CrateContext = bcx.ccx();
let filename = span_start(cx, span).file.name; let filename = span_start(cx, span).file.name;
@ -720,7 +720,7 @@ fn file_metadata(cx: &mut CrateContext, full_path: &str) -> DIFile {
/// Finds the scope metadata node for the given AST node. /// Finds the scope metadata node for the given AST node.
fn scope_metadata(fcx: &FunctionContext, fn scope_metadata(fcx: &FunctionContext,
node_id: ast::NodeId, node_id: ast::NodeId,
span: span) -> DIScope { span: Span) -> DIScope {
if fcx.debug_context.is_none() { if fcx.debug_context.is_none() {
fcx.ccx.sess.span_bug(span, "debuginfo: FunctionDebugContext should be initialized \ fcx.ccx.sess.span_bug(span, "debuginfo: FunctionDebugContext should be initialized \
but is not!"); but is not!");
@ -808,7 +808,7 @@ fn pointer_type_metadata(cx: &mut CrateContext,
fn struct_metadata(cx: &mut CrateContext, fn struct_metadata(cx: &mut CrateContext,
struct_type: ty::t, struct_type: ty::t,
fields: ~[ty::field], fields: ~[ty::field],
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
let struct_name = ty_to_str(cx.tcx, struct_type); let struct_name = ty_to_str(cx.tcx, struct_type);
debug!("struct_metadata: %s", struct_name); debug!("struct_metadata: %s", struct_name);
@ -840,7 +840,7 @@ fn struct_metadata(cx: &mut CrateContext,
fn tuple_metadata(cx: &mut CrateContext, fn tuple_metadata(cx: &mut CrateContext,
tuple_type: ty::t, tuple_type: ty::t,
component_types: &[ty::t], component_types: &[ty::t],
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
let tuple_name = ty_to_str(cx.tcx, tuple_type); let tuple_name = ty_to_str(cx.tcx, tuple_type);
@ -865,7 +865,7 @@ fn tuple_metadata(cx: &mut CrateContext,
fn enum_metadata(cx: &mut CrateContext, fn enum_metadata(cx: &mut CrateContext,
enum_type: ty::t, enum_type: ty::t,
enum_def_id: ast::def_id, enum_def_id: ast::def_id,
span: span) span: Span)
-> DIType { -> DIType {
let enum_name = ty_to_str(cx.tcx, enum_type); let enum_name = ty_to_str(cx.tcx, enum_type);
@ -987,7 +987,7 @@ fn enum_metadata(cx: &mut CrateContext,
struct_def: &adt::Struct, struct_def: &adt::Struct,
variant_info: &ty::VariantInfo, variant_info: &ty::VariantInfo,
discriminant_type_metadata: Option<DIType>, discriminant_type_metadata: Option<DIType>,
span: span) span: Span)
-> DICompositeType -> DICompositeType
{ {
let arg_llvm_types: ~[Type] = do struct_def.fields.map |&ty| { type_of::type_of(cx, ty) }; let arg_llvm_types: ~[Type] = do struct_def.fields.map |&ty| { type_of::type_of(cx, ty) };
@ -1031,7 +1031,7 @@ fn composite_type_metadata(cx: &mut CrateContext,
member_llvm_types: &[Type], member_llvm_types: &[Type],
member_names: &[~str], member_names: &[~str],
member_type_metadata: &[DIType], member_type_metadata: &[DIType],
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
let loc = span_start(cx, span); let loc = span_start(cx, span);
@ -1088,7 +1088,7 @@ fn boxed_type_metadata(cx: &mut CrateContext,
content_type_name: Option<&str>, content_type_name: Option<&str>,
content_llvm_type: Type, content_llvm_type: Type,
content_type_metadata: DIType, content_type_metadata: DIType,
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
let box_type_name = match content_type_name { let box_type_name = match content_type_name {
@ -1140,7 +1140,7 @@ fn boxed_type_metadata(cx: &mut CrateContext,
fn fixed_vec_metadata(cx: &mut CrateContext, fn fixed_vec_metadata(cx: &mut CrateContext,
element_type: ty::t, element_type: ty::t,
len: uint, len: uint,
span: span) span: Span)
-> DIType { -> DIType {
let element_type_metadata = type_metadata(cx, element_type, span); let element_type_metadata = type_metadata(cx, element_type, span);
let element_llvm_type = type_of::type_of(cx, element_type); let element_llvm_type = type_of::type_of(cx, element_type);
@ -1166,7 +1166,7 @@ fn fixed_vec_metadata(cx: &mut CrateContext,
fn vec_metadata(cx: &mut CrateContext, fn vec_metadata(cx: &mut CrateContext,
element_type: ty::t, element_type: ty::t,
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
let element_type_metadata = type_metadata(cx, element_type, span); let element_type_metadata = type_metadata(cx, element_type, span);
@ -1204,7 +1204,7 @@ fn vec_metadata(cx: &mut CrateContext,
fn boxed_vec_metadata(cx: &mut CrateContext, fn boxed_vec_metadata(cx: &mut CrateContext,
element_type: ty::t, element_type: ty::t,
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
let element_llvm_type = type_of::type_of(cx, element_type); let element_llvm_type = type_of::type_of(cx, element_type);
@ -1223,7 +1223,7 @@ fn boxed_vec_metadata(cx: &mut CrateContext,
fn vec_slice_metadata(cx: &mut CrateContext, fn vec_slice_metadata(cx: &mut CrateContext,
vec_type: ty::t, vec_type: ty::t,
element_type: ty::t, element_type: ty::t,
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
debug!("vec_slice_metadata: %?", ty::get(vec_type)); debug!("vec_slice_metadata: %?", ty::get(vec_type));
@ -1264,7 +1264,7 @@ fn bare_fn_metadata(cx: &mut CrateContext,
_fn_ty: ty::t, _fn_ty: ty::t,
inputs: ~[ty::t], inputs: ~[ty::t],
output: ty::t, output: ty::t,
span: span) span: Span)
-> DICompositeType { -> DICompositeType {
debug!("bare_fn_metadata: %?", ty::get(_fn_ty)); debug!("bare_fn_metadata: %?", ty::get(_fn_ty));
@ -1307,7 +1307,7 @@ fn unimplemented_type_metadata(cx: &mut CrateContext, t: ty::t) -> DIType {
fn type_metadata(cx: &mut CrateContext, fn type_metadata(cx: &mut CrateContext,
t: ty::t, t: ty::t,
span: span) span: Span)
-> DIType { -> DIType {
let type_id = ty::type_id(t); let type_id = ty::type_id(t);
match dbg_cx(cx).created_types.find(&type_id) { match dbg_cx(cx).created_types.find(&type_id) {
@ -1493,7 +1493,7 @@ fn roundup(x: uint, a: uint) -> uint {
} }
/// Return codemap::Loc corresponding to the beginning of the span /// Return codemap::Loc corresponding to the beginning of the span
fn span_start(cx: &CrateContext, span: span) -> codemap::Loc { fn span_start(cx: &CrateContext, span: Span) -> codemap::Loc {
cx.sess.codemap.lookup_char_pos(span.lo) cx.sess.codemap.lookup_char_pos(span.lo)
} }
@ -1561,7 +1561,7 @@ fn populate_scope_map(cx: &mut CrateContext,
// local helper functions for walking the AST. // local helper functions for walking the AST.
fn with_new_scope(cx: &mut CrateContext, fn with_new_scope(cx: &mut CrateContext,
scope_span: span, scope_span: Span,
scope_stack: &mut ~[ScopeStackEntry], scope_stack: &mut ~[ScopeStackEntry],
scope_map: &mut HashMap<ast::NodeId, DIScope>, scope_map: &mut HashMap<ast::NodeId, DIScope>,
inner_walk: &fn(&mut CrateContext, inner_walk: &fn(&mut CrateContext,
@ -1625,7 +1625,7 @@ fn populate_scope_map(cx: &mut CrateContext,
scope_stack: &mut ~[ScopeStackEntry], scope_stack: &mut ~[ScopeStackEntry],
scope_map: &mut HashMap<ast::NodeId, DIScope>) { scope_map: &mut HashMap<ast::NodeId, DIScope>) {
match *decl { match *decl {
codemap::spanned { node: ast::decl_local(@ref local), _ } => { codemap::Spanned { node: ast::decl_local(@ref local), _ } => {
scope_map.insert(local.id, scope_stack.last().scope_metadata); scope_map.insert(local.id, scope_stack.last().scope_metadata);
walk_pattern(cx, local.pat, scope_stack, scope_map); walk_pattern(cx, local.pat, scope_stack, scope_map);

View File

@ -680,7 +680,7 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr,
args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect(); args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect();
return trans_adt(bcx, repr, 0, numbered_fields, None, dest); return trans_adt(bcx, repr, 0, numbered_fields, None, dest);
} }
ast::expr_lit(@codemap::spanned {node: ast::lit_str(s), _}) => { ast::expr_lit(@codemap::Spanned {node: ast::lit_str(s), _}) => {
return tvec::trans_lit_str(bcx, expr, s, dest); return tvec::trans_lit_str(bcx, expr, s, dest);
} }
ast::expr_vstore(contents, ast::expr_vstore_slice) | ast::expr_vstore(contents, ast::expr_vstore_slice) |
@ -1163,7 +1163,7 @@ pub fn with_field_tys<R>(tcx: ty::ctxt,
fn trans_rec_or_struct(bcx: @mut Block, fn trans_rec_or_struct(bcx: @mut Block,
fields: &[ast::Field], fields: &[ast::Field],
base: Option<@ast::expr>, base: Option<@ast::expr>,
expr_span: codemap::span, expr_span: codemap::Span,
id: ast::NodeId, id: ast::NodeId,
dest: Dest) -> @mut Block dest: Dest) -> @mut Block
{ {

View File

@ -29,7 +29,7 @@ use middle::ty::FnSig;
use std::uint; use std::uint;
use std::vec; use std::vec;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::{ast}; use syntax::{ast};
use syntax::{attr, ast_map}; use syntax::{attr, ast_map};
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
@ -350,7 +350,7 @@ pub fn trans_foreign_mod(ccx: @mut CrateContext,
// correct code in the first place, but this is much simpler. // correct code in the first place, but this is much simpler.
pub fn register_rust_fn_with_foreign_abi(ccx: @mut CrateContext, pub fn register_rust_fn_with_foreign_abi(ccx: @mut CrateContext,
sp: span, sp: Span,
sym: ~str, sym: ~str,
node_id: ast::NodeId) node_id: ast::NodeId)
-> ValueRef { -> ValueRef {

View File

@ -205,7 +205,7 @@ pub fn trans_slice_vstore(bcx: @mut Block,
// Handle the &"..." case: // Handle the &"..." case:
match content_expr.node { match content_expr.node {
ast::expr_lit(@codemap::spanned {node: ast::lit_str(s), span: _}) => { ast::expr_lit(@codemap::Spanned {node: ast::lit_str(s), span: _}) => {
return trans_lit_str(bcx, content_expr, s, dest); return trans_lit_str(bcx, content_expr, s, dest);
} }
_ => {} _ => {}
@ -295,7 +295,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: @a
match heap { match heap {
heap_exchange => { heap_exchange => {
match content_expr.node { match content_expr.node {
ast::expr_lit(@codemap::spanned { ast::expr_lit(@codemap::Spanned {
node: ast::lit_str(s), span node: ast::lit_str(s), span
}) => { }) => {
let llptrval = C_cstr(bcx.ccx(), s); let llptrval = C_cstr(bcx.ccx(), s);
@ -357,7 +357,7 @@ pub fn write_content(bcx: @mut Block,
let _indenter = indenter(); let _indenter = indenter();
match content_expr.node { match content_expr.node {
ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { ast::expr_lit(@codemap::Spanned { node: ast::lit_str(s), _ }) => {
match dest { match dest {
Ignore => { Ignore => {
return bcx; return bcx;
@ -490,7 +490,7 @@ pub fn elements_required(bcx: @mut Block, content_expr: &ast::expr) -> uint {
//! Figure out the number of elements we need to store this content //! Figure out the number of elements we need to store this content
match content_expr.node { match content_expr.node {
ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { ast::expr_lit(@codemap::Spanned { node: ast::lit_str(s), _ }) => {
s.len() s.len()
}, },
ast::expr_vec(ref es, _) => es.len(), ast::expr_vec(ref es, _) => es.len(),

View File

@ -28,14 +28,14 @@ use middle::trans::common::*;
use middle::trans::datum::*; use middle::trans::datum::*;
use middle::trans::expr; use middle::trans::expr;
use middle::ty; use middle::ty;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::ast; use syntax::ast;
use middle::trans::type_::Type; use middle::trans::type_::Type;
pub fn root_and_write_guard(datum: &Datum, pub fn root_and_write_guard(datum: &Datum,
mut bcx: @mut Block, mut bcx: @mut Block,
span: span, span: Span,
expr_id: ast::NodeId, expr_id: ast::NodeId,
derefs: uint) -> @mut Block { derefs: uint) -> @mut Block {
let key = root_map_key { id: expr_id, derefs: derefs }; let key = root_map_key { id: expr_id, derefs: derefs };
@ -103,7 +103,7 @@ pub fn return_to_mut(mut bcx: @mut Block,
fn root(datum: &Datum, fn root(datum: &Datum,
mut bcx: @mut Block, mut bcx: @mut Block,
span: span, span: Span,
root_key: root_map_key, root_key: root_map_key,
root_info: RootInfo) -> @mut Block { root_info: RootInfo) -> @mut Block {
//! In some cases, borrowck will decide that an @T/@[]/@str //! In some cases, borrowck will decide that an @T/@[]/@str
@ -183,7 +183,7 @@ fn root(datum: &Datum,
fn perform_write_guard(datum: &Datum, fn perform_write_guard(datum: &Datum,
bcx: @mut Block, bcx: @mut Block,
span: span) -> @mut Block { span: Span) -> @mut Block {
debug!("perform_write_guard"); debug!("perform_write_guard");
let llval = datum.to_value_llval(bcx); let llval = datum.to_value_llval(bcx);

View File

@ -38,7 +38,7 @@ use syntax::ast::*;
use syntax::ast_util::is_local; use syntax::ast_util::is_local;
use syntax::ast_util; use syntax::ast_util;
use syntax::attr; use syntax::attr;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::codemap; use syntax::codemap;
use syntax::parse::token; use syntax::parse::token;
use syntax::{ast, ast_map}; use syntax::{ast, ast_map};
@ -2898,7 +2898,7 @@ pub fn ty_vstore(ty: t) -> vstore {
} }
pub fn ty_region(tcx: ctxt, pub fn ty_region(tcx: ctxt,
span: span, span: Span,
ty: t) -> Region { ty: t) -> Region {
match get(ty).sty { match get(ty).sty {
ty_rptr(r, _) => r, ty_rptr(r, _) => r,
@ -2996,7 +2996,7 @@ pub fn expr_ty_adjusted(cx: ctxt, expr: &ast::expr) -> t {
} }
pub fn adjust_ty(cx: ctxt, pub fn adjust_ty(cx: ctxt,
span: span, span: Span,
unadjusted_ty: ty::t, unadjusted_ty: ty::t,
adjustment: Option<@AutoAdjustment>) -> ty::t adjustment: Option<@AutoAdjustment>) -> ty::t
{ {
@ -3076,7 +3076,7 @@ pub fn adjust_ty(cx: ctxt,
} }
}; };
fn borrow_vec(cx: ctxt, span: span, fn borrow_vec(cx: ctxt, span: Span,
r: Region, m: ast::mutability, r: Region, m: ast::mutability,
ty: ty::t) -> ty::t { ty: ty::t) -> ty::t {
match get(ty).sty { match get(ty).sty {
@ -3097,7 +3097,7 @@ pub fn adjust_ty(cx: ctxt,
} }
} }
fn borrow_fn(cx: ctxt, span: span, r: Region, ty: ty::t) -> ty::t { fn borrow_fn(cx: ctxt, span: Span, r: Region, ty: ty::t) -> ty::t {
match get(ty).sty { match get(ty).sty {
ty_closure(ref fty) => { ty_closure(ref fty) => {
ty::mk_closure(cx, ClosureTy { ty::mk_closure(cx, ClosureTy {
@ -3116,7 +3116,7 @@ pub fn adjust_ty(cx: ctxt,
} }
} }
fn borrow_obj(cx: ctxt, span: span, r: Region, fn borrow_obj(cx: ctxt, span: Span, r: Region,
m: ast::mutability, ty: ty::t) -> ty::t { m: ast::mutability, ty: ty::t) -> ty::t {
match get(ty).sty { match get(ty).sty {
ty_trait(trt_did, ref trt_substs, _, _, b) => { ty_trait(trt_did, ref trt_substs, _, _, b) => {
@ -3283,7 +3283,7 @@ pub fn expr_kind(tcx: ctxt,
ast::expr_do_body(*) | ast::expr_do_body(*) |
ast::expr_block(*) | ast::expr_block(*) |
ast::expr_repeat(*) | ast::expr_repeat(*) |
ast::expr_lit(@codemap::spanned {node: lit_str(_), _}) | ast::expr_lit(@codemap::Spanned {node: lit_str(_), _}) |
ast::expr_vstore(_, ast::expr_vstore_slice) | ast::expr_vstore(_, ast::expr_vstore_slice) |
ast::expr_vstore(_, ast::expr_vstore_mut_slice) | ast::expr_vstore(_, ast::expr_vstore_mut_slice) |
ast::expr_vec(*) => { ast::expr_vec(*) => {
@ -3395,7 +3395,7 @@ pub fn param_tys_in_type(ty: t) -> ~[param_ty] {
rslt rslt
} }
pub fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) { pub fn occurs_check(tcx: ctxt, sp: Span, vid: TyVid, rt: t) {
// Returns a vec of all the type variables occurring in `ty`. It may // Returns a vec of all the type variables occurring in `ty`. It may
// contain duplicates. (Integral type vars aren't counted.) // contain duplicates. (Integral type vars aren't counted.)
fn vars_in_type(ty: t) -> ~[TyVid] { fn vars_in_type(ty: t) -> ~[TyVid] {

View File

@ -65,7 +65,7 @@ use middle::typeck::lookup_def_tcx;
use std::result; use std::result;
use syntax::abi::AbiSet; use syntax::abi::AbiSet;
use syntax::{ast, ast_util}; use syntax::{ast, ast_util};
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::opt_vec::OptVec; use syntax::opt_vec::OptVec;
use syntax::opt_vec; use syntax::opt_vec;
use syntax::print::pprust::{lifetime_to_str, path_to_str}; use syntax::print::pprust::{lifetime_to_str, path_to_str};
@ -78,12 +78,12 @@ pub trait AstConv {
fn get_trait_def(&self, id: ast::def_id) -> @ty::TraitDef; fn get_trait_def(&self, id: ast::def_id) -> @ty::TraitDef;
// what type should we use when a type is omitted? // what type should we use when a type is omitted?
fn ty_infer(&self, span: span) -> ty::t; fn ty_infer(&self, span: Span) -> ty::t;
} }
pub fn get_region_reporting_err( pub fn get_region_reporting_err(
tcx: ty::ctxt, tcx: ty::ctxt,
span: span, span: Span,
a_r: &Option<ast::Lifetime>, a_r: &Option<ast::Lifetime>,
res: Result<ty::Region, RegionError>) -> ty::Region res: Result<ty::Region, RegionError>) -> ty::Region
{ {
@ -107,7 +107,7 @@ pub fn get_region_reporting_err(
pub fn ast_region_to_region<AC:AstConv,RS:RegionScope + Clone + 'static>( pub fn ast_region_to_region<AC:AstConv,RS:RegionScope + Clone + 'static>(
this: &AC, this: &AC,
rscope: &RS, rscope: &RS,
default_span: span, default_span: Span,
opt_lifetime: &Option<ast::Lifetime>) -> ty::Region opt_lifetime: &Option<ast::Lifetime>) -> ty::Region
{ {
let (span, res) = match opt_lifetime { let (span, res) = match opt_lifetime {
@ -701,7 +701,7 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope + Clone + 'static>(
decl: &ast::fn_decl, decl: &ast::fn_decl,
expected_sig: Option<ty::FnSig>, expected_sig: Option<ty::FnSig>,
lifetimes: &OptVec<ast::Lifetime>, lifetimes: &OptVec<ast::Lifetime>,
span: span) span: Span)
-> ty::ClosureTy -> ty::ClosureTy
{ {
// The caller should not both provide explicit bound lifetime // The caller should not both provide explicit bound lifetime

View File

@ -21,7 +21,7 @@ use middle::typeck::require_same_types;
use std::hashmap::{HashMap, HashSet}; use std::hashmap::{HashMap, HashSet};
use syntax::ast; use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::print::pprust; use syntax::print::pprust;
pub fn check_match(fcx: @mut FnCtxt, pub fn check_match(fcx: @mut FnCtxt,
@ -284,7 +284,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path,
/// (e.g. K,V in HashMap<K,V>). /// (e.g. K,V in HashMap<K,V>).
/// `etc` is true if the pattern said '...' and false otherwise. /// `etc` is true if the pattern said '...' and false otherwise.
pub fn check_struct_pat_fields(pcx: &pat_ctxt, pub fn check_struct_pat_fields(pcx: &pat_ctxt,
span: span, span: Span,
path: &ast::Path, path: &ast::Path,
fields: &[ast::field_pat], fields: &[ast::field_pat],
class_fields: ~[ty::field_ty], class_fields: ~[ty::field_ty],
@ -338,7 +338,7 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
} }
} }
pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, span: span, pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, span: Span,
expected: ty::t, path: &ast::Path, expected: ty::t, path: &ast::Path,
fields: &[ast::field_pat], etc: bool, fields: &[ast::field_pat], etc: bool,
struct_id: ast::def_id, struct_id: ast::def_id,
@ -372,7 +372,7 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, span: span,
pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt, pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt,
pat_id: ast::NodeId, pat_id: ast::NodeId,
span: span, span: Span,
expected: ty::t, expected: ty::t,
path: &ast::Path, path: &ast::Path,
fields: &[ast::field_pat], fields: &[ast::field_pat],
@ -651,7 +651,7 @@ pub fn check_pointer_pat(pcx: &pat_ctxt,
pointer_kind: PointerKind, pointer_kind: PointerKind,
inner: @ast::pat, inner: @ast::pat,
pat_id: ast::NodeId, pat_id: ast::NodeId,
span: span, span: Span,
expected: ty::t) { expected: ty::t) {
let fcx = pcx.fcx; let fcx = pcx.fcx;
let check_inner: &fn(ty::mt) = |e_inner| { let check_inner: &fn(ty::mt) = |e_inner| {

View File

@ -16,24 +16,24 @@ use middle::typeck::infer;
use std::result::{Err, Ok}; use std::result::{Err, Ok};
use std::result; use std::result;
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
// Requires that the two types unify, and prints an error message if they // Requires that the two types unify, and prints an error message if they
// don't. // don't.
pub fn suptype(fcx: @mut FnCtxt, sp: span, expected: ty::t, actual: ty::t) { pub fn suptype(fcx: @mut FnCtxt, sp: Span, expected: ty::t, actual: ty::t) {
suptype_with_fn(fcx, sp, false, expected, actual, suptype_with_fn(fcx, sp, false, expected, actual,
|sp, e, a, s| { fcx.report_mismatched_types(sp, e, a, s) }) |sp, e, a, s| { fcx.report_mismatched_types(sp, e, a, s) })
} }
pub fn subtype(fcx: @mut FnCtxt, sp: span, expected: ty::t, actual: ty::t) { pub fn subtype(fcx: @mut FnCtxt, sp: Span, expected: ty::t, actual: ty::t) {
suptype_with_fn(fcx, sp, true, actual, expected, suptype_with_fn(fcx, sp, true, actual, expected,
|sp, a, e, s| { fcx.report_mismatched_types(sp, e, a, s) }) |sp, a, e, s| { fcx.report_mismatched_types(sp, e, a, s) })
} }
pub fn suptype_with_fn(fcx: @mut FnCtxt, pub fn suptype_with_fn(fcx: @mut FnCtxt,
sp: span, b_is_expected: bool, sp: Span, b_is_expected: bool,
ty_a: ty::t, ty_b: ty::t, ty_a: ty::t, ty_b: ty::t,
handle_err: &fn(span, ty::t, ty::t, &ty::type_err)) { handle_err: &fn(Span, ty::t, ty::t, &ty::type_err)) {
// n.b.: order of actual, expected is reversed // n.b.: order of actual, expected is reversed
match infer::mk_subty(fcx.infcx(), b_is_expected, infer::Misc(sp), match infer::mk_subty(fcx.infcx(), b_is_expected, infer::Misc(sp),
ty_b, ty_a) { ty_b, ty_a) {
@ -44,7 +44,7 @@ pub fn suptype_with_fn(fcx: @mut FnCtxt,
} }
} }
pub fn eqtype(fcx: @mut FnCtxt, sp: span, expected: ty::t, actual: ty::t) { pub fn eqtype(fcx: @mut FnCtxt, sp: Span, expected: ty::t, actual: ty::t) {
match infer::mk_eqty(fcx.infcx(), false, infer::Misc(sp), actual, expected) { match infer::mk_eqty(fcx.infcx(), false, infer::Misc(sp), actual, expected) {
Ok(()) => { /* ok */ } Ok(()) => { /* ok */ }
Err(ref err) => { Err(ref err) => {
@ -55,7 +55,7 @@ pub fn eqtype(fcx: @mut FnCtxt, sp: span, expected: ty::t, actual: ty::t) {
// Checks that the type `actual` can be coerced to `expected`. // Checks that the type `actual` can be coerced to `expected`.
pub fn coerce(fcx: @mut FnCtxt, pub fn coerce(fcx: @mut FnCtxt,
sp: span, sp: Span,
expected: ty::t, expected: ty::t,
expr: @ast::expr) { expr: @ast::expr) {
let expr_ty = fcx.expr_ty(expr); let expr_ty = fcx.expr_ty(expr);

View File

@ -122,7 +122,7 @@ use syntax::ast;
use syntax::ast_map; use syntax::ast_map;
use syntax::ast_util::local_def; use syntax::ast_util::local_def;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::codemap; use syntax::codemap;
use syntax::opt_vec::OptVec; use syntax::opt_vec::OptVec;
use syntax::opt_vec; use syntax::opt_vec;
@ -144,7 +144,7 @@ pub mod method;
pub struct SelfInfo { pub struct SelfInfo {
self_ty: ty::t, self_ty: ty::t,
self_id: ast::NodeId, self_id: ast::NodeId,
span: span span: Span
} }
/// Fields that are part of a `FnCtxt` which are inherited by /// Fields that are part of a `FnCtxt` which are inherited by
@ -398,7 +398,7 @@ impl Visitor<()> for GatherLocalsVisitor {
// Don't descend into fns and items // Don't descend into fns and items
fn visit_fn(&mut self, _:&visit::fn_kind, _:&ast::fn_decl, fn visit_fn(&mut self, _:&visit::fn_kind, _:&ast::fn_decl,
_:&ast::Block, _:span, _:ast::NodeId, _:()) { } _:&ast::Block, _:Span, _:ast::NodeId, _:()) { }
fn visit_item(&mut self, _:@ast::item, _:()) { } fn visit_item(&mut self, _:@ast::item, _:()) { }
} }
@ -557,7 +557,7 @@ pub fn check_method(ccx: @mut CrateCtxt,
} }
pub fn check_no_duplicate_fields(tcx: ty::ctxt, pub fn check_no_duplicate_fields(tcx: ty::ctxt,
fields: ~[(ast::ident, span)]) { fields: ~[(ast::ident, Span)]) {
let mut field_names = HashMap::new(); let mut field_names = HashMap::new();
for p in fields.iter() { for p in fields.iter() {
@ -577,7 +577,7 @@ pub fn check_no_duplicate_fields(tcx: ty::ctxt,
} }
} }
pub fn check_struct(ccx: @mut CrateCtxt, id: ast::NodeId, span: span) { pub fn check_struct(ccx: @mut CrateCtxt, id: ast::NodeId, span: Span) {
let tcx = ccx.tcx; let tcx = ccx.tcx;
// Check that the class is instantiable // Check that the class is instantiable
@ -665,7 +665,7 @@ impl AstConv for FnCtxt {
ty::lookup_trait_def(self.tcx(), id) ty::lookup_trait_def(self.tcx(), id)
} }
fn ty_infer(&self, _span: span) -> ty::t { fn ty_infer(&self, _span: Span) -> ty::t {
self.infcx().next_ty_var() self.infcx().next_ty_var()
} }
} }
@ -678,7 +678,7 @@ impl FnCtxt {
self.ccx.tcx.sess.err_count() - self.err_count_on_creation self.ccx.tcx.sess.err_count() - self.err_count_on_creation
} }
pub fn search_in_scope_regions(&self, pub fn search_in_scope_regions(&self,
span: span, span: Span,
br: ty::bound_region) br: ty::bound_region)
-> Result<ty::Region, RegionError> { -> Result<ty::Region, RegionError> {
let in_scope_regions = self.in_scope_regions; let in_scope_regions = self.in_scope_regions;
@ -706,14 +706,14 @@ impl FnCtxt {
} }
impl RegionScope for FnCtxt { impl RegionScope for FnCtxt {
fn anon_region(&self, span: span) -> Result<ty::Region, RegionError> { fn anon_region(&self, span: Span) -> Result<ty::Region, RegionError> {
result::Ok(self.infcx().next_region_var(infer::MiscVariable(span))) result::Ok(self.infcx().next_region_var(infer::MiscVariable(span)))
} }
fn self_region(&self, span: span) -> Result<ty::Region, RegionError> { fn self_region(&self, span: Span) -> Result<ty::Region, RegionError> {
self.search_in_scope_regions(span, ty::br_self) self.search_in_scope_regions(span, ty::br_self)
} }
fn named_region(&self, fn named_region(&self,
span: span, span: Span,
id: ast::ident) -> Result<ty::Region, RegionError> { id: ast::ident) -> Result<ty::Region, RegionError> {
self.search_in_scope_regions(span, ty::br_named(id)) self.search_in_scope_regions(span, ty::br_named(id))
} }
@ -726,7 +726,7 @@ impl FnCtxt {
} }
} }
pub fn local_ty(&self, span: span, nid: ast::NodeId) -> ty::t { pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {
match self.inh.locals.find(&nid) { match self.inh.locals.find(&nid) {
Some(&t) => t, Some(&t) => t,
None => { None => {
@ -918,7 +918,7 @@ impl FnCtxt {
pub fn region_var_if_parameterized(&self, pub fn region_var_if_parameterized(&self,
rp: Option<ty::region_variance>, rp: Option<ty::region_variance>,
span: span) span: Span)
-> OptVec<ty::Region> { -> OptVec<ty::Region> {
match rp { match rp {
None => opt_vec::Empty, None => opt_vec::Empty,
@ -931,7 +931,7 @@ impl FnCtxt {
} }
pub fn type_error_message(&self, pub fn type_error_message(&self,
sp: span, sp: Span,
mk_msg: &fn(~str) -> ~str, mk_msg: &fn(~str) -> ~str,
actual_ty: ty::t, actual_ty: ty::t,
err: Option<&ty::type_err>) { err: Option<&ty::type_err>) {
@ -939,7 +939,7 @@ impl FnCtxt {
} }
pub fn report_mismatched_return_types(&self, pub fn report_mismatched_return_types(&self,
sp: span, sp: Span,
e: ty::t, e: ty::t,
a: ty::t, a: ty::t,
err: &ty::type_err) { err: &ty::type_err) {
@ -951,7 +951,7 @@ impl FnCtxt {
} }
pub fn report_mismatched_types(&self, pub fn report_mismatched_types(&self,
sp: span, sp: Span,
e: ty::t, e: ty::t,
a: ty::t, a: ty::t,
err: &ty::type_err) { err: &ty::type_err) {
@ -959,7 +959,7 @@ impl FnCtxt {
} }
} }
pub fn do_autoderef(fcx: @mut FnCtxt, sp: span, t: ty::t) -> (ty::t, uint) { pub fn do_autoderef(fcx: @mut FnCtxt, sp: Span, t: ty::t) -> (ty::t, uint) {
/*! /*!
* *
* Autoderefs the type `t` as many times as possible, returning * Autoderefs the type `t` as many times as possible, returning
@ -1306,7 +1306,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
fn check_method_argument_types( fn check_method_argument_types(
fcx: @mut FnCtxt, fcx: @mut FnCtxt,
sp: span, sp: Span,
method_fn_ty: ty::t, method_fn_ty: ty::t,
callee_expr: @ast::expr, callee_expr: @ast::expr,
args: &[@ast::expr], args: &[@ast::expr],
@ -1336,7 +1336,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
fn check_argument_types( fn check_argument_types(
fcx: @mut FnCtxt, fcx: @mut FnCtxt,
sp: span, sp: Span,
fn_inputs: &[ty::t], fn_inputs: &[ty::t],
callee_expr: @ast::expr, callee_expr: @ast::expr,
args: &[@ast::expr], args: &[@ast::expr],
@ -1597,7 +1597,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
then_blk: &ast::Block, then_blk: &ast::Block,
opt_else_expr: Option<@ast::expr>, opt_else_expr: Option<@ast::expr>,
id: ast::NodeId, id: ast::NodeId,
sp: span, sp: Span,
expected: Option<ty::t>) { expected: Option<ty::t>) {
check_expr_has_type(fcx, cond_expr, ty::mk_bool()); check_expr_has_type(fcx, cond_expr, ty::mk_bool());
@ -2005,7 +2005,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
} }
fn check_struct_or_variant_fields(fcx: @mut FnCtxt, fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
span: span, span: Span,
class_id: ast::def_id, class_id: ast::def_id,
node_id: ast::NodeId, node_id: ast::NodeId,
substitutions: ty::substs, substitutions: ty::substs,
@ -2096,7 +2096,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
fn check_struct_constructor(fcx: @mut FnCtxt, fn check_struct_constructor(fcx: @mut FnCtxt,
id: ast::NodeId, id: ast::NodeId,
span: codemap::span, span: codemap::Span,
class_id: ast::def_id, class_id: ast::def_id,
fields: &[ast::Field], fields: &[ast::Field],
base_expr: Option<@ast::expr>) { base_expr: Option<@ast::expr>) {
@ -2185,7 +2185,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
fn check_struct_enum_variant(fcx: @mut FnCtxt, fn check_struct_enum_variant(fcx: @mut FnCtxt,
id: ast::NodeId, id: ast::NodeId,
span: codemap::span, span: codemap::Span,
enum_id: ast::def_id, enum_id: ast::def_id,
variant_id: ast::def_id, variant_id: ast::def_id,
fields: &[ast::Field]) { fields: &[ast::Field]) {
@ -2259,7 +2259,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
match expr.node { match expr.node {
ast::expr_vstore(ev, vst) => { ast::expr_vstore(ev, vst) => {
let typ = match ev.node { let typ = match ev.node {
ast::expr_lit(@codemap::spanned { node: ast::lit_str(_), _ }) => { ast::expr_lit(@codemap::Spanned { node: ast::lit_str(_), _ }) => {
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
ty::mk_estr(tcx, tt) ty::mk_estr(tcx, tt)
} }
@ -2708,7 +2708,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
_ => false _ => false
} }
} }
fn types_compatible(fcx: @mut FnCtxt, sp: span, fn types_compatible(fcx: @mut FnCtxt, sp: Span,
t1: ty::t, t2: ty::t) -> bool { t1: ty::t, t2: ty::t) -> bool {
if !is_vec(t1) { if !is_vec(t1) {
false false
@ -2897,7 +2897,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
unifier(); unifier();
} }
pub fn require_integral(fcx: @mut FnCtxt, sp: span, t: ty::t) { pub fn require_integral(fcx: @mut FnCtxt, sp: Span, t: ty::t) {
if !type_is_integral(fcx, sp, t) { if !type_is_integral(fcx, sp, t) {
fcx.type_error_message(sp, |actual| { fcx.type_error_message(sp, |actual| {
fmt!("mismatched types: expected integral type but found `%s`", fmt!("mismatched types: expected integral type but found `%s`",
@ -3022,7 +3022,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
let s_id = ast_util::stmt_id(*s); let s_id = ast_util::stmt_id(*s);
let s_ty = fcx.node_ty(s_id); let s_ty = fcx.node_ty(s_id);
if last_was_bot && !warned && match s.node { if last_was_bot && !warned && match s.node {
ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_), ast::stmt_decl(@codemap::Spanned { node: ast::decl_local(_),
_}, _) | _}, _) |
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) => { ast::stmt_expr(_, _) | ast::stmt_semi(_, _) => {
true true
@ -3070,7 +3070,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
} }
pub fn check_const(ccx: @mut CrateCtxt, pub fn check_const(ccx: @mut CrateCtxt,
sp: span, sp: Span,
e: @ast::expr, e: @ast::expr,
id: ast::NodeId) { id: ast::NodeId) {
let rty = ty::node_id_to_type(ccx.tcx, id); let rty = ty::node_id_to_type(ccx.tcx, id);
@ -3080,7 +3080,7 @@ pub fn check_const(ccx: @mut CrateCtxt,
} }
pub fn check_const_with_ty(fcx: @mut FnCtxt, pub fn check_const_with_ty(fcx: @mut FnCtxt,
_: span, _: Span,
e: @ast::expr, e: @ast::expr,
declty: ty::t) { declty: ty::t) {
check_expr(fcx, e); check_expr(fcx, e);
@ -3102,7 +3102,7 @@ pub fn check_const_with_ty(fcx: @mut FnCtxt,
/// ///
/// is representable, but not instantiable. /// is representable, but not instantiable.
pub fn check_instantiable(tcx: ty::ctxt, pub fn check_instantiable(tcx: ty::ctxt,
sp: span, sp: Span,
item_id: ast::NodeId) { item_id: ast::NodeId) {
let item_ty = ty::node_id_to_type(tcx, item_id); let item_ty = ty::node_id_to_type(tcx, item_id);
if !ty::is_instantiable(tcx, item_ty) { if !ty::is_instantiable(tcx, item_ty) {
@ -3113,7 +3113,7 @@ pub fn check_instantiable(tcx: ty::ctxt,
} }
} }
pub fn check_simd(tcx: ty::ctxt, sp: span, id: ast::NodeId) { pub fn check_simd(tcx: ty::ctxt, sp: Span, id: ast::NodeId) {
let t = ty::node_id_to_type(tcx, id); let t = ty::node_id_to_type(tcx, id);
if ty::type_needs_subst(t) { if ty::type_needs_subst(t) {
tcx.sess.span_err(sp, "SIMD vector cannot be generic"); tcx.sess.span_err(sp, "SIMD vector cannot be generic");
@ -3143,7 +3143,7 @@ pub fn check_simd(tcx: ty::ctxt, sp: span, id: ast::NodeId) {
} }
pub fn check_enum_variants(ccx: @mut CrateCtxt, pub fn check_enum_variants(ccx: @mut CrateCtxt,
sp: span, sp: Span,
vs: &[ast::variant], vs: &[ast::variant],
id: ast::NodeId) { id: ast::NodeId) {
fn do_check(ccx: @mut CrateCtxt, fn do_check(ccx: @mut CrateCtxt,
@ -3236,13 +3236,13 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt,
check_instantiable(ccx.tcx, sp, id); check_instantiable(ccx.tcx, sp, id);
} }
pub fn lookup_def(fcx: @mut FnCtxt, sp: span, id: ast::NodeId) -> ast::def { pub fn lookup_def(fcx: @mut FnCtxt, sp: Span, id: ast::NodeId) -> ast::def {
lookup_def_ccx(fcx.ccx, sp, id) lookup_def_ccx(fcx.ccx, sp, id)
} }
// Returns the type parameter count and the type for the given definition. // Returns the type parameter count and the type for the given definition.
pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt, pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt,
sp: span, sp: Span,
defn: ast::def) defn: ast::def)
-> ty_param_bounds_and_ty { -> ty_param_bounds_and_ty {
match defn { match defn {
@ -3295,7 +3295,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
pth: &ast::Path, pth: &ast::Path,
tpt: ty_param_bounds_and_ty, tpt: ty_param_bounds_and_ty,
def: ast::def, def: ast::def,
span: span, span: Span,
node_id: ast::NodeId) { node_id: ast::NodeId) {
debug!(">>> instantiate_path"); debug!(">>> instantiate_path");
@ -3409,7 +3409,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
// Resolves `typ` by a single level if `typ` is a type variable. If no // Resolves `typ` by a single level if `typ` is a type variable. If no
// resolution is possible, then an error is reported. // resolution is possible, then an error is reported.
pub fn structurally_resolved_type(fcx: @mut FnCtxt, sp: span, tp: ty::t) pub fn structurally_resolved_type(fcx: @mut FnCtxt, sp: Span, tp: ty::t)
-> ty::t { -> ty::t {
match infer::resolve_type(fcx.infcx(), tp, force_tvar) { match infer::resolve_type(fcx.infcx(), tp, force_tvar) {
Ok(t_s) if !ty::type_is_ty_var(t_s) => t_s, Ok(t_s) if !ty::type_is_ty_var(t_s) => t_s,
@ -3424,32 +3424,32 @@ pub fn structurally_resolved_type(fcx: @mut FnCtxt, sp: span, tp: ty::t)
} }
// Returns the one-level-deep structure of the given type. // Returns the one-level-deep structure of the given type.
pub fn structure_of<'a>(fcx: @mut FnCtxt, sp: span, typ: ty::t) pub fn structure_of<'a>(fcx: @mut FnCtxt, sp: Span, typ: ty::t)
-> &'a ty::sty { -> &'a ty::sty {
&ty::get(structurally_resolved_type(fcx, sp, typ)).sty &ty::get(structurally_resolved_type(fcx, sp, typ)).sty
} }
pub fn type_is_integral(fcx: @mut FnCtxt, sp: span, typ: ty::t) -> bool { pub fn type_is_integral(fcx: @mut FnCtxt, sp: Span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ); let typ_s = structurally_resolved_type(fcx, sp, typ);
return ty::type_is_integral(typ_s); return ty::type_is_integral(typ_s);
} }
pub fn type_is_scalar(fcx: @mut FnCtxt, sp: span, typ: ty::t) -> bool { pub fn type_is_scalar(fcx: @mut FnCtxt, sp: Span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ); let typ_s = structurally_resolved_type(fcx, sp, typ);
return ty::type_is_scalar(typ_s); return ty::type_is_scalar(typ_s);
} }
pub fn type_is_unsafe_ptr(fcx: @mut FnCtxt, sp: span, typ: ty::t) -> bool { pub fn type_is_unsafe_ptr(fcx: @mut FnCtxt, sp: Span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ); let typ_s = structurally_resolved_type(fcx, sp, typ);
return ty::type_is_unsafe_ptr(typ_s); return ty::type_is_unsafe_ptr(typ_s);
} }
pub fn type_is_region_ptr(fcx: @mut FnCtxt, sp: span, typ: ty::t) -> bool { pub fn type_is_region_ptr(fcx: @mut FnCtxt, sp: Span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ); let typ_s = structurally_resolved_type(fcx, sp, typ);
return ty::type_is_region_ptr(typ_s); return ty::type_is_region_ptr(typ_s);
} }
pub fn type_is_c_like_enum(fcx: @mut FnCtxt, sp: span, typ: ty::t) -> bool { pub fn type_is_c_like_enum(fcx: @mut FnCtxt, sp: Span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ); let typ_s = structurally_resolved_type(fcx, sp, typ);
return ty::type_is_c_like_enum(fcx.ccx.tcx, typ_s); return ty::type_is_c_like_enum(fcx.ccx.tcx, typ_s);
} }
@ -3492,7 +3492,7 @@ pub fn may_break(cx: ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool {
} }
pub fn check_bounds_are_used(ccx: @mut CrateCtxt, pub fn check_bounds_are_used(ccx: @mut CrateCtxt,
span: span, span: Span,
tps: &OptVec<ast::TyParam>, tps: &OptVec<ast::TyParam>,
ty: ty::t) { ty: ty::t) {
debug!("check_bounds_are_used(n_tps=%u, ty=%s)", debug!("check_bounds_are_used(n_tps=%u, ty=%s)",

View File

@ -42,7 +42,7 @@ use middle::pat_util;
use syntax::ast::{ManagedSigil, OwnedSigil, BorrowedSigil}; use syntax::ast::{ManagedSigil, OwnedSigil, BorrowedSigil};
use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar}; use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar};
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -626,7 +626,7 @@ fn constrain_derefs(rcx: @mut Rcx,
} }
pub fn mk_subregion_due_to_derefence(rcx: @mut Rcx, pub fn mk_subregion_due_to_derefence(rcx: @mut Rcx,
deref_span: span, deref_span: Span,
minimum_lifetime: ty::Region, minimum_lifetime: ty::Region,
maximum_lifetime: ty::Region) { maximum_lifetime: ty::Region) {
rcx.fcx.mk_subr(true, infer::DerefPointer(deref_span), rcx.fcx.mk_subr(true, infer::DerefPointer(deref_span),
@ -809,7 +809,7 @@ pub mod guarantor {
use middle::typeck::infer; use middle::typeck::infer;
use middle::ty; use middle::ty;
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use util::ppaux::{ty_to_str}; use util::ppaux::{ty_to_str};
pub fn for_addr_of(rcx: @mut Rcx, expr: @ast::expr, base: @ast::expr) { pub fn for_addr_of(rcx: @mut Rcx, expr: @ast::expr, base: @ast::expr) {
@ -918,7 +918,7 @@ pub mod guarantor {
fn link( fn link(
rcx: @mut Rcx, rcx: @mut Rcx,
span: span, span: Span,
id: ast::NodeId, id: ast::NodeId,
guarantor: Option<ty::Region>) { guarantor: Option<ty::Region>) {
/*! /*!

View File

@ -27,7 +27,7 @@ use std::hashmap::HashSet;
use std::result; use std::result;
use syntax::ast; use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::print::pprust::expr_to_str; use syntax::print::pprust::expr_to_str;
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -62,7 +62,7 @@ use syntax::visit::Visitor;
/// responsible for this vtable instantiation. (This may not be an expression /// responsible for this vtable instantiation. (This may not be an expression
/// if the vtable instantiation is being performed as part of "deriving".) /// if the vtable instantiation is being performed as part of "deriving".)
pub struct LocationInfo { pub struct LocationInfo {
span: span, span: Span,
id: ast::NodeId id: ast::NodeId
} }

View File

@ -27,11 +27,11 @@ use middle::typeck::write_ty_to_tcx;
use util::ppaux; use util::ppaux;
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::print::pprust::pat_to_str; use syntax::print::pprust::pat_to_str;
use syntax::oldvisit; use syntax::oldvisit;
fn resolve_type_vars_in_type(fcx: @mut FnCtxt, sp: span, typ: ty::t) fn resolve_type_vars_in_type(fcx: @mut FnCtxt, sp: Span, typ: ty::t)
-> Option<ty::t> { -> Option<ty::t> {
if !ty::type_needs_infer(typ) { return Some(typ); } if !ty::type_needs_infer(typ) { return Some(typ); }
match resolve_type(fcx.infcx(), typ, resolve_all | force_all) { match resolve_type(fcx.infcx(), typ, resolve_all | force_all) {
@ -49,7 +49,7 @@ fn resolve_type_vars_in_type(fcx: @mut FnCtxt, sp: span, typ: ty::t)
} }
} }
fn resolve_type_vars_in_types(fcx: @mut FnCtxt, sp: span, tys: &[ty::t]) fn resolve_type_vars_in_types(fcx: @mut FnCtxt, sp: Span, tys: &[ty::t])
-> ~[ty::t] { -> ~[ty::t] {
tys.map(|t| { tys.map(|t| {
match resolve_type_vars_in_type(fcx, sp, *t) { match resolve_type_vars_in_type(fcx, sp, *t) {
@ -59,7 +59,7 @@ fn resolve_type_vars_in_types(fcx: @mut FnCtxt, sp: span, tys: &[ty::t])
}) })
} }
fn resolve_method_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::NodeId) { fn resolve_method_map_entry(fcx: @mut FnCtxt, sp: Span, id: ast::NodeId) {
// Resolve any method map entry // Resolve any method map entry
match fcx.inh.method_map.find(&id) { match fcx.inh.method_map.find(&id) {
None => {} None => {}
@ -79,7 +79,7 @@ fn resolve_method_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::NodeId) {
} }
} }
fn resolve_vtable_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::NodeId) { fn resolve_vtable_map_entry(fcx: @mut FnCtxt, sp: Span, id: ast::NodeId) {
// Resolve any method map entry // Resolve any method map entry
match fcx.inh.vtable_map.find(&id) { match fcx.inh.vtable_map.find(&id) {
None => {} None => {}
@ -92,13 +92,13 @@ fn resolve_vtable_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::NodeId) {
} }
} }
fn resolve_origins(fcx: @mut FnCtxt, sp: span, fn resolve_origins(fcx: @mut FnCtxt, sp: Span,
vtbls: vtable_res) -> vtable_res { vtbls: vtable_res) -> vtable_res {
@vtbls.map(|os| @os.map(|o| resolve_origin(fcx, sp, o))) @vtbls.map(|os| @os.map(|o| resolve_origin(fcx, sp, o)))
} }
fn resolve_origin(fcx: @mut FnCtxt, fn resolve_origin(fcx: @mut FnCtxt,
sp: span, sp: Span,
origin: &vtable_origin) -> vtable_origin { origin: &vtable_origin) -> vtable_origin {
match origin { match origin {
&vtable_static(def_id, ref tys, origins) => { &vtable_static(def_id, ref tys, origins) => {
@ -113,7 +113,7 @@ fn resolve_vtable_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::NodeId) {
} }
} }
fn resolve_type_vars_for_node(wbcx: @mut WbCtxt, sp: span, id: ast::NodeId) fn resolve_type_vars_for_node(wbcx: @mut WbCtxt, sp: Span, id: ast::NodeId)
-> Option<ty::t> { -> Option<ty::t> {
let fcx = wbcx.fcx; let fcx = wbcx.fcx;
let tcx = fcx.ccx.tcx; let tcx = fcx.ccx.tcx;
@ -196,7 +196,7 @@ fn resolve_type_vars_for_node(wbcx: @mut WbCtxt, sp: span, id: ast::NodeId)
} }
fn maybe_resolve_type_vars_for_node(wbcx: @mut WbCtxt, fn maybe_resolve_type_vars_for_node(wbcx: @mut WbCtxt,
sp: span, sp: Span,
id: ast::NodeId) id: ast::NodeId)
-> Option<ty::t> { -> Option<ty::t> {
if wbcx.fcx.inh.node_types.contains_key(&id) { if wbcx.fcx.inh.node_types.contains_key(&id) {

View File

@ -42,7 +42,7 @@ use syntax::ast;
use syntax::ast_map::node_item; use syntax::ast_map::node_item;
use syntax::ast_map; use syntax::ast_map;
use syntax::ast_util::{def_id_of_def, local_def}; use syntax::ast_util::{def_id_of_def, local_def};
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::opt_vec; use syntax::opt_vec;
use syntax::visit; use syntax::visit;
use syntax::parse; use syntax::parse;
@ -58,7 +58,7 @@ pub struct UniversalQuantificationResult {
} }
pub fn get_base_type(inference_context: @mut InferCtxt, pub fn get_base_type(inference_context: @mut InferCtxt,
span: span, span: Span,
original_type: t) original_type: t)
-> Option<t> { -> Option<t> {
let resolved_type; let resolved_type;
@ -121,7 +121,7 @@ pub fn type_is_defined_in_local_crate(original_type: t) -> bool {
// Returns the def ID of the base type, if there is one. // Returns the def ID of the base type, if there is one.
pub fn get_base_type_def_id(inference_context: @mut InferCtxt, pub fn get_base_type_def_id(inference_context: @mut InferCtxt,
span: span, span: Span,
original_type: t) original_type: t)
-> Option<def_id> { -> Option<def_id> {
match get_base_type(inference_context, span, original_type) { match get_base_type(inference_context, span, original_type) {
@ -546,7 +546,7 @@ impl CoherenceChecker {
&self, &self,
all_methods: &mut ~[@Method], all_methods: &mut ~[@Method],
trait_did: def_id, trait_did: def_id,
trait_ref_span: span) { trait_ref_span: Span) {
let tcx = self.crate_context.tcx; let tcx = self.crate_context.tcx;
@ -647,7 +647,7 @@ impl CoherenceChecker {
} }
} }
pub fn span_of_impl(&self, implementation: @Impl) -> span { pub fn span_of_impl(&self, implementation: @Impl) -> Span {
assert_eq!(implementation.did.crate, LOCAL_CRATE); assert_eq!(implementation.did.crate, LOCAL_CRATE);
match self.crate_context.tcx.items.find(&implementation.did.node) { match self.crate_context.tcx.items.find(&implementation.did.node) {
Some(&node_item(item, _)) => { Some(&node_item(item, _)) => {

View File

@ -54,7 +54,7 @@ use syntax::ast::{RegionTyParamBound, TraitTyParamBound};
use syntax::ast; use syntax::ast;
use syntax::ast_map; use syntax::ast_map;
use syntax::ast_util::{local_def, split_trait_methods}; use syntax::ast_util::{local_def, split_trait_methods};
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::codemap; use syntax::codemap;
use syntax::print::pprust::{path_to_str, explicit_self_to_str}; use syntax::print::pprust::{path_to_str, explicit_self_to_str};
use syntax::visit; use syntax::visit;
@ -140,7 +140,7 @@ impl AstConv for CrateCtxt {
get_trait_def(self, id) get_trait_def(self, id)
} }
fn ty_infer(&self, span: span) -> ty::t { fn ty_infer(&self, span: Span) -> ty::t {
self.tcx.sess.span_bug(span, self.tcx.sess.span_bug(span,
"found `ty_infer` in unexpected place"); "found `ty_infer` in unexpected place");
} }
@ -397,7 +397,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
pub fn ensure_supertraits(ccx: &CrateCtxt, pub fn ensure_supertraits(ccx: &CrateCtxt,
id: ast::NodeId, id: ast::NodeId,
sp: codemap::span, sp: codemap::Span,
rp: Option<ty::region_variance>, rp: Option<ty::region_variance>,
ast_trait_refs: &[ast::trait_ref], ast_trait_refs: &[ast::trait_ref],
generics: &ast::Generics) -> ty::BuiltinBounds generics: &ast::Generics) -> ty::BuiltinBounds
@ -740,7 +740,7 @@ pub fn convert_field(ccx: &CrateCtxt,
pub struct ConvertedMethod { pub struct ConvertedMethod {
mty: @ty::Method, mty: @ty::Method,
id: ast::NodeId, id: ast::NodeId,
span: span, span: Span,
body_id: ast::NodeId body_id: ast::NodeId
} }
@ -828,7 +828,7 @@ pub fn convert_methods(ccx: &CrateCtxt,
} }
pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt, pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
span: span, span: Span,
generics: &ast::Generics, generics: &ast::Generics,
thing: &'static str) { thing: &'static str) {
for ty_param in generics.ty_params.iter() { for ty_param in generics.ty_params.iter() {

View File

@ -44,7 +44,7 @@ use extra::smallintmap::SmallIntMap;
use syntax::ast::{m_imm, m_mutbl}; use syntax::ast::{m_imm, m_mutbl};
use syntax::ast; use syntax::ast;
use syntax::codemap; use syntax::codemap;
use syntax::codemap::span; use syntax::codemap::Span;
pub mod doc; pub mod doc;
pub mod macros; pub mod macros;
@ -100,25 +100,25 @@ pub struct InferCtxt {
#[deriving(Clone)] #[deriving(Clone)]
pub enum TypeOrigin { pub enum TypeOrigin {
// Not yet categorized in a better way // Not yet categorized in a better way
Misc(span), Misc(Span),
// Checking that method of impl is compatible with trait // Checking that method of impl is compatible with trait
MethodCompatCheck(span), MethodCompatCheck(Span),
// Checking that this expression can be assigned where it needs to be // Checking that this expression can be assigned where it needs to be
ExprAssignable(@ast::expr), ExprAssignable(@ast::expr),
// Relating trait refs when resolving vtables // Relating trait refs when resolving vtables
RelateTraitRefs(span), RelateTraitRefs(Span),
// Relating trait refs when resolving vtables // Relating trait refs when resolving vtables
RelateSelfType(span), RelateSelfType(Span),
// Computing common supertype in a match expression // Computing common supertype in a match expression
MatchExpression(span), MatchExpression(Span),
// Computing common supertype in an if expression // Computing common supertype in an if expression
IfExpression(span), IfExpression(Span),
} }
/// See `error_reporting.rs` for more details /// See `error_reporting.rs` for more details
@ -148,47 +148,47 @@ pub enum SubregionOrigin {
// Stack-allocated closures cannot outlive innermost loop // Stack-allocated closures cannot outlive innermost loop
// or function so as to ensure we only require finite stack // or function so as to ensure we only require finite stack
InfStackClosure(span), InfStackClosure(Span),
// Invocation of closure must be within its lifetime // Invocation of closure must be within its lifetime
InvokeClosure(span), InvokeClosure(Span),
// Dereference of borrowed pointer must be within its lifetime // Dereference of borrowed pointer must be within its lifetime
DerefPointer(span), DerefPointer(Span),
// Closure bound must not outlive captured free variables // Closure bound must not outlive captured free variables
FreeVariable(span), FreeVariable(Span),
// Index into slice must be within its lifetime // Index into slice must be within its lifetime
IndexSlice(span), IndexSlice(Span),
// When casting `&'a T` to an `&'b Trait` object, // When casting `&'a T` to an `&'b Trait` object,
// relating `'a` to `'b` // relating `'a` to `'b`
RelateObjectBound(span), RelateObjectBound(Span),
// Creating a pointer `b` to contents of another borrowed pointer // Creating a pointer `b` to contents of another borrowed pointer
Reborrow(span), Reborrow(Span),
// (&'a &'b T) where a >= b // (&'a &'b T) where a >= b
ReferenceOutlivesReferent(ty::t, span), ReferenceOutlivesReferent(ty::t, Span),
// A `ref b` whose region does not enclose the decl site // A `ref b` whose region does not enclose the decl site
BindingTypeIsNotValidAtDecl(span), BindingTypeIsNotValidAtDecl(Span),
// Regions appearing in a method receiver must outlive method call // Regions appearing in a method receiver must outlive method call
CallRcvr(span), CallRcvr(Span),
// Regions appearing in a function argument must outlive func call // Regions appearing in a function argument must outlive func call
CallArg(span), CallArg(Span),
// Region in return type of invoked fn must enclose call // Region in return type of invoked fn must enclose call
CallReturn(span), CallReturn(Span),
// Region resulting from a `&` expr must enclose the `&` expr // Region resulting from a `&` expr must enclose the `&` expr
AddrOf(span), AddrOf(Span),
// An auto-borrow that does not enclose the expr where it occurs // An auto-borrow that does not enclose the expr where it occurs
AutoBorrow(span), AutoBorrow(Span),
} }
/// Reasons to create a region inference variable /// Reasons to create a region inference variable
@ -197,36 +197,36 @@ pub enum SubregionOrigin {
pub enum RegionVariableOrigin { pub enum RegionVariableOrigin {
// Region variables created for ill-categorized reasons, // Region variables created for ill-categorized reasons,
// mostly indicates places in need of refactoring // mostly indicates places in need of refactoring
MiscVariable(span), MiscVariable(Span),
// Regions created by a `&P` or `[...]` pattern // Regions created by a `&P` or `[...]` pattern
PatternRegion(span), PatternRegion(Span),
// Regions created by `&` operator // Regions created by `&` operator
AddrOfRegion(span), AddrOfRegion(Span),
// Regions created by `&[...]` literal // Regions created by `&[...]` literal
AddrOfSlice(span), AddrOfSlice(Span),
// Regions created as part of an autoref of a method receiver // Regions created as part of an autoref of a method receiver
Autoref(span), Autoref(Span),
// Regions created as part of an automatic coercion // Regions created as part of an automatic coercion
Coercion(TypeTrace), Coercion(TypeTrace),
// Region variables created for bound regions // Region variables created for bound regions
// in a function or method that is called // in a function or method that is called
BoundRegionInFnCall(span, ty::bound_region), BoundRegionInFnCall(Span, ty::bound_region),
// Region variables created for bound regions // Region variables created for bound regions
// when doing subtyping/lub/glb computations // when doing subtyping/lub/glb computations
BoundRegionInFnType(span, ty::bound_region), BoundRegionInFnType(Span, ty::bound_region),
BoundRegionInTypeOrImpl(span), BoundRegionInTypeOrImpl(Span),
BoundRegionInCoherence, BoundRegionInCoherence,
BoundRegionError(span), BoundRegionError(Span),
} }
pub enum fixup_err { pub enum fixup_err {
@ -710,7 +710,7 @@ impl InferCtxt {
// types using one of these four methods, and should not call span_err directly for such // types using one of these four methods, and should not call span_err directly for such
// errors. // errors.
pub fn type_error_message_str(@mut self, pub fn type_error_message_str(@mut self,
sp: span, sp: Span,
mk_msg: &fn(Option<~str>, ~str) -> ~str, mk_msg: &fn(Option<~str>, ~str) -> ~str,
actual_ty: ~str, actual_ty: ~str,
err: Option<&ty::type_err>) { err: Option<&ty::type_err>) {
@ -718,7 +718,7 @@ impl InferCtxt {
} }
pub fn type_error_message_str_with_expected(@mut self, pub fn type_error_message_str_with_expected(@mut self,
sp: span, sp: Span,
mk_msg: mk_msg:
&fn(Option<~str>, ~str) -> &fn(Option<~str>, ~str) ->
~str, ~str,
@ -749,7 +749,7 @@ impl InferCtxt {
} }
pub fn type_error_message(@mut self, pub fn type_error_message(@mut self,
sp: span, sp: Span,
mk_msg: &fn(~str) -> ~str, mk_msg: &fn(~str) -> ~str,
actual_ty: ty::t, actual_ty: ty::t,
err: Option<&ty::type_err>) { err: Option<&ty::type_err>) {
@ -764,7 +764,7 @@ impl InferCtxt {
} }
pub fn report_mismatched_types(@mut self, pub fn report_mismatched_types(@mut self,
sp: span, sp: Span,
e: ty::t, e: ty::t,
a: ty::t, a: ty::t,
err: &ty::type_err) { err: &ty::type_err) {
@ -812,7 +812,7 @@ pub fn fold_regions_in_sig(
} }
impl TypeTrace { impl TypeTrace {
pub fn span(&self) -> span { pub fn span(&self) -> Span {
self.origin.span() self.origin.span()
} }
} }
@ -824,7 +824,7 @@ impl Repr for TypeTrace {
} }
impl TypeOrigin { impl TypeOrigin {
pub fn span(&self) -> span { pub fn span(&self) -> Span {
match *self { match *self {
MethodCompatCheck(span) => span, MethodCompatCheck(span) => span,
ExprAssignable(expr) => expr.span, ExprAssignable(expr) => expr.span,
@ -852,7 +852,7 @@ impl Repr for TypeOrigin {
} }
impl SubregionOrigin { impl SubregionOrigin {
pub fn span(&self) -> span { pub fn span(&self) -> Span {
match *self { match *self {
Subtype(a) => a.span(), Subtype(a) => a.span(),
InfStackClosure(a) => a, InfStackClosure(a) => a,
@ -896,7 +896,7 @@ impl Repr for SubregionOrigin {
} }
impl RegionVariableOrigin { impl RegionVariableOrigin {
pub fn span(&self) -> span { pub fn span(&self) -> Span {
match *self { match *self {
MiscVariable(a) => a, MiscVariable(a) => a,
PatternRegion(a) => a, PatternRegion(a) => a,

View File

@ -61,7 +61,7 @@ use std::hashmap::HashMap;
use std::result; use std::result;
use extra::list::List; use extra::list::List;
use extra::list; use extra::list;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::print::pprust::*; use syntax::print::pprust::*;
use syntax::{ast, ast_map, abi}; use syntax::{ast, ast_map, abi};
use syntax::opt_vec; use syntax::opt_vec;
@ -249,7 +249,7 @@ pub fn write_tpt_to_tcx(tcx: ty::ctxt,
} }
} }
pub fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::NodeId) -> ast::def { pub fn lookup_def_tcx(tcx: ty::ctxt, sp: Span, id: ast::NodeId) -> ast::def {
match tcx.def_map.find(&id) { match tcx.def_map.find(&id) {
Some(&x) => x, Some(&x) => x,
_ => { _ => {
@ -258,7 +258,7 @@ pub fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::NodeId) -> ast::def {
} }
} }
pub fn lookup_def_ccx(ccx: &CrateCtxt, sp: span, id: ast::NodeId) pub fn lookup_def_ccx(ccx: &CrateCtxt, sp: Span, id: ast::NodeId)
-> ast::def { -> ast::def {
lookup_def_tcx(ccx.tcx, sp, id) lookup_def_tcx(ccx.tcx, sp, id)
} }
@ -275,7 +275,7 @@ pub fn require_same_types(
tcx: ty::ctxt, tcx: ty::ctxt,
maybe_infcx: Option<@mut infer::InferCtxt>, maybe_infcx: Option<@mut infer::InferCtxt>,
t1_is_expected: bool, t1_is_expected: bool,
span: span, span: Span,
t1: ty::t, t1: ty::t,
t2: ty::t, t2: ty::t,
msg: &fn() -> ~str) -> bool { msg: &fn() -> ~str) -> bool {
@ -330,7 +330,7 @@ impl get_and_find_region for isr_alist {
fn check_main_fn_ty(ccx: &CrateCtxt, fn check_main_fn_ty(ccx: &CrateCtxt,
main_id: ast::NodeId, main_id: ast::NodeId,
main_span: span) { main_span: Span) {
let tcx = ccx.tcx; let tcx = ccx.tcx;
let main_t = ty::node_id_to_type(tcx, main_id); let main_t = ty::node_id_to_type(tcx, main_id);
match ty::get(main_t).sty { match ty::get(main_t).sty {
@ -374,7 +374,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
fn check_start_fn_ty(ccx: &CrateCtxt, fn check_start_fn_ty(ccx: &CrateCtxt,
start_id: ast::NodeId, start_id: ast::NodeId,
start_span: span) { start_span: Span) {
let tcx = ccx.tcx; let tcx = ccx.tcx;
let start_t = ty::node_id_to_type(tcx, start_id); let start_t = ty::node_id_to_type(tcx, start_id);
match ty::get(start_t).sty { match ty::get(start_t).sty {

View File

@ -13,7 +13,7 @@ use middle::ty;
use std::result; use std::result;
use syntax::ast; use syntax::ast;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::opt_vec::OptVec; use syntax::opt_vec::OptVec;
use syntax::opt_vec; use syntax::opt_vec;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
@ -25,25 +25,25 @@ pub struct RegionError {
} }
pub trait RegionScope { pub trait RegionScope {
fn anon_region(&self, span: span) -> Result<ty::Region, RegionError>; fn anon_region(&self, span: Span) -> Result<ty::Region, RegionError>;
fn self_region(&self, span: span) -> Result<ty::Region, RegionError>; fn self_region(&self, span: Span) -> Result<ty::Region, RegionError>;
fn named_region(&self, span: span, id: ast::ident) fn named_region(&self, span: Span, id: ast::ident)
-> Result<ty::Region, RegionError>; -> Result<ty::Region, RegionError>;
} }
#[deriving(Clone)] #[deriving(Clone)]
pub struct EmptyRscope; pub struct EmptyRscope;
impl RegionScope for EmptyRscope { impl RegionScope for EmptyRscope {
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { fn anon_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
result::Err(RegionError { result::Err(RegionError {
msg: ~"only 'static is allowed here", msg: ~"only 'static is allowed here",
replacement: ty::re_static replacement: ty::re_static
}) })
} }
fn self_region(&self, _span: span) -> Result<ty::Region, RegionError> { fn self_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
self.anon_region(_span) self.anon_region(_span)
} }
fn named_region(&self, _span: span, _id: ast::ident) fn named_region(&self, _span: Span, _id: ast::ident)
-> Result<ty::Region, RegionError> -> Result<ty::Region, RegionError>
{ {
self.anon_region(_span) self.anon_region(_span)
@ -176,13 +176,13 @@ impl MethodRscope {
} }
impl RegionScope for MethodRscope { impl RegionScope for MethodRscope {
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { fn anon_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
result::Err(RegionError { result::Err(RegionError {
msg: ~"anonymous lifetimes are not permitted here", msg: ~"anonymous lifetimes are not permitted here",
replacement: ty::re_bound(ty::br_self) replacement: ty::re_bound(ty::br_self)
}) })
} }
fn self_region(&self, _span: span) -> Result<ty::Region, RegionError> { fn self_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
assert!(self.variance.is_some()); assert!(self.variance.is_some());
match self.variance { match self.variance {
None => {} // must be borrowed self, so this is OK None => {} // must be borrowed self, so this is OK
@ -197,7 +197,7 @@ impl RegionScope for MethodRscope {
} }
result::Ok(ty::re_bound(ty::br_self)) result::Ok(ty::re_bound(ty::br_self))
} }
fn named_region(&self, span: span, id: ast::ident) fn named_region(&self, span: Span, id: ast::ident)
-> Result<ty::Region, RegionError> { -> Result<ty::Region, RegionError> {
if !self.region_param_names.has_ident(id) { if !self.region_param_names.has_ident(id) {
return RegionParamNames::undeclared_name(None); return RegionParamNames::undeclared_name(None);
@ -224,13 +224,13 @@ impl TypeRscope {
} }
} }
impl RegionScope for TypeRscope { impl RegionScope for TypeRscope {
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { fn anon_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
result::Err(RegionError { result::Err(RegionError {
msg: ~"anonymous lifetimes are not permitted here", msg: ~"anonymous lifetimes are not permitted here",
replacement: self.replacement() replacement: self.replacement()
}) })
} }
fn self_region(&self, _span: span) -> Result<ty::Region, RegionError> { fn self_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
match **self { match **self {
None => { None => {
// if the self region is used, region parameterization should // if the self region is used, region parameterization should
@ -249,7 +249,7 @@ impl RegionScope for TypeRscope {
} }
result::Ok(ty::re_bound(ty::br_self)) result::Ok(ty::re_bound(ty::br_self))
} }
fn named_region(&self, span: span, id: ast::ident) fn named_region(&self, span: Span, id: ast::ident)
-> Result<ty::Region, RegionError> { -> Result<ty::Region, RegionError> {
do EmptyRscope.named_region(span, id).chain_err |_e| { do EmptyRscope.named_region(span, id).chain_err |_e| {
result::Err(RegionError { result::Err(RegionError {
@ -298,16 +298,16 @@ pub fn in_binding_rscope<RS:RegionScope + Clone + 'static>(
} }
impl RegionScope for BindingRscope { impl RegionScope for BindingRscope {
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { fn anon_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
let idx = *self.anon_bindings; let idx = *self.anon_bindings;
*self.anon_bindings += 1; *self.anon_bindings += 1;
result::Ok(ty::re_bound(ty::br_anon(idx))) result::Ok(ty::re_bound(ty::br_anon(idx)))
} }
fn self_region(&self, span: span) -> Result<ty::Region, RegionError> { fn self_region(&self, span: Span) -> Result<ty::Region, RegionError> {
self.base.self_region(span) self.base.self_region(span)
} }
fn named_region(&self, fn named_region(&self,
span: span, span: Span,
id: ast::ident) -> Result<ty::Region, RegionError> id: ast::ident) -> Result<ty::Region, RegionError>
{ {
do self.base.named_region(span, id).chain_err |_e| { do self.base.named_region(span, id).chain_err |_e| {

View File

@ -28,7 +28,7 @@ extern mod syntax;
use driver::driver::{host_triple, optgroups, early_error}; use driver::driver::{host_triple, optgroups, early_error};
use driver::driver::{str_input, file_input, build_session_options}; use driver::driver::{str_input, file_input, build_session_options};
use driver::driver::{build_session, build_configuration, parse_pretty}; use driver::driver::{build_session, build_configuration, parse_pretty};
use driver::driver::{pp_mode, pretty_print_input, list_metadata}; use driver::driver::{PpMode, pretty_print_input, list_metadata};
use driver::driver::{compile_input}; use driver::driver::{compile_input};
use driver::session; use driver::session;
use middle::lint; use middle::lint;
@ -262,11 +262,11 @@ pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
parse_pretty(sess, a) parse_pretty(sess, a)
}; };
match pretty { match pretty {
Some::<pp_mode>(ppm) => { Some::<PpMode>(ppm) => {
pretty_print_input(sess, cfg, &input, ppm); pretty_print_input(sess, cfg, &input, ppm);
return; return;
} }
None::<pp_mode> => {/* continue */ } None::<PpMode> => {/* continue */ }
} }
let ls = opt_present(matches, "ls"); let ls = opt_present(matches, "ls");
if ls { if ls {
@ -326,7 +326,7 @@ pub fn monitor(f: ~fn(diagnostic::Emitter)) {
let ch_capture = ch.clone(); let ch_capture = ch.clone();
// The 'diagnostics emitter'. Every error, warning, etc. should // The 'diagnostics emitter'. Every error, warning, etc. should
// go through this function. // go through this function.
let demitter: @fn(Option<(@codemap::CodeMap, codemap::span)>, let demitter: @fn(Option<(@codemap::CodeMap, codemap::Span)>,
&str, &str,
diagnostic::level) = diagnostic::level) =
|cmsp, msg, lvl| { |cmsp, msg, lvl| {

View File

@ -10,7 +10,7 @@
use syntax::ast; use syntax::ast;
use syntax::codemap::{span}; use syntax::codemap::{Span};
use syntax::visit; use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
@ -105,7 +105,7 @@ pub fn block_query(b: &ast::Block, p: @fn(@ast::expr) -> bool) -> bool {
return *rs; return *rs;
} }
pub fn local_rhs_span(l: @ast::Local, def: span) -> span { pub fn local_rhs_span(l: @ast::Local, def: Span) -> Span {
match l.init { match l.init {
Some(i) => return i.span, Some(i) => return i.span,
_ => return def _ => return def

View File

@ -26,7 +26,7 @@ use middle::ty;
use middle::typeck; use middle::typeck;
use syntax::abi::AbiSet; use syntax::abi::AbiSet;
use syntax::ast_map; use syntax::ast_map;
use syntax::codemap::span; use syntax::codemap::Span;
use syntax::parse::token; use syntax::parse::token;
use syntax::print::pprust; use syntax::print::pprust;
use syntax::{ast, ast_util}; use syntax::{ast, ast_util};
@ -69,7 +69,7 @@ pub fn explain_region(cx: ctxt, region: ty::Region) -> ~str {
pub fn explain_region_and_span(cx: ctxt, region: ty::Region) pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
-> (~str, Option<span>) { -> (~str, Option<Span>) {
return match region { return match region {
re_scope(node_id) => { re_scope(node_id) => {
match cx.items.find(&node_id) { match cx.items.find(&node_id) {
@ -136,8 +136,8 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
} }
}; };
fn explain_span(cx: ctxt, heading: &str, span: span) fn explain_span(cx: ctxt, heading: &str, span: Span)
-> (~str, Option<span>) -> (~str, Option<Span>)
{ {
let lo = cx.sess.codemap.lookup_char_pos_adj(span.lo); let lo = cx.sess.codemap.lookup_char_pos_adj(span.lo);
(fmt!("the %s at %u:%u", heading, (fmt!("the %s at %u:%u", heading,
@ -827,7 +827,7 @@ impl Repr for ty::BuiltinBounds {
} }
} }
impl Repr for span { impl Repr for Span {
fn repr(&self, tcx: ctxt) -> ~str { fn repr(&self, tcx: ctxt) -> ~str {
tcx.sess.codemap.span_to_str(*self) tcx.sess.codemap.span_to_str(*self)
} }

View File

@ -12,7 +12,7 @@ use std::os;
use rustc::driver::{driver, session}; use rustc::driver::{driver, session};
use extra::getopts::groups::getopts; use extra::getopts::groups::getopts;
use syntax::ast_util::*; use syntax::ast_util::*;
use syntax::codemap::{dummy_sp, spanned}; use syntax::codemap::{dummy_sp, Spanned};
use syntax::ext::base::ExtCtxt; use syntax::ext::base::ExtCtxt;
use syntax::{ast, attr, codemap, diagnostic, fold}; use syntax::{ast, attr, codemap, diagnostic, fold};
use syntax::attr::AttrMetaMethods; use syntax::attr::AttrMetaMethods;
@ -53,7 +53,7 @@ pub fn is_cmd(cmd: &str) -> bool {
struct ListenerFn { struct ListenerFn {
cmds: ~[~str], cmds: ~[~str],
span: codemap::span, span: codemap::Span,
path: ~[ast::ident] path: ~[ast::ident]
} }
@ -427,7 +427,7 @@ pub fn link_exe(src: &Path, dest: &Path) -> bool {
} }
pub fn mk_string_lit(s: @str) -> ast::lit { pub fn mk_string_lit(s: @str) -> ast::lit {
spanned { Spanned {
node: ast::lit_str(s), node: ast::lit_str(s),
span: dummy_sp() span: dummy_sp()
} }

View File

@ -10,7 +10,7 @@
// The Rust abstract syntax tree. // The Rust abstract syntax tree.
use codemap::{span, spanned}; use codemap::{Span, Spanned};
use abi::AbiSet; use abi::AbiSet;
use opt_vec::OptVec; use opt_vec::OptVec;
use parse::token::{interner_get, str_to_ident}; use parse::token::{interner_get, str_to_ident};
@ -95,7 +95,7 @@ pub type fn_ident = Option<ident>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct Lifetime { pub struct Lifetime {
id: NodeId, id: NodeId,
span: span, span: Span,
ident: ident ident: ident
} }
@ -105,7 +105,7 @@ pub struct Lifetime {
// of supporting information. // of supporting information.
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct Path { pub struct Path {
span: span, span: Span,
/// A `::foo` path, is relative to the crate root rather than current /// A `::foo` path, is relative to the crate root rather than current
/// module (like paths in an import). /// module (like paths in an import).
global: bool, global: bool,
@ -219,10 +219,10 @@ pub struct Crate {
module: _mod, module: _mod,
attrs: ~[Attribute], attrs: ~[Attribute],
config: CrateConfig, config: CrateConfig,
span: span, span: Span,
} }
pub type MetaItem = spanned<MetaItem_>; pub type MetaItem = Spanned<MetaItem_>;
#[deriving(Clone, Encodable, Decodable, IterBytes)] #[deriving(Clone, Encodable, Decodable, IterBytes)]
pub enum MetaItem_ { pub enum MetaItem_ {
@ -263,14 +263,14 @@ pub struct Block {
expr: Option<@expr>, expr: Option<@expr>,
id: NodeId, id: NodeId,
rules: BlockCheckMode, rules: BlockCheckMode,
span: span, span: Span,
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct pat { pub struct pat {
id: NodeId, id: NodeId,
node: pat_, node: pat_,
span: span, span: Span,
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
@ -333,7 +333,7 @@ impl ToStr for Sigil {
} }
} }
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable, IterBytes)]
pub enum vstore { pub enum vstore {
// FIXME (#3469): Change uint to @expr (actually only constant exprs) // FIXME (#3469): Change uint to @expr (actually only constant exprs)
vstore_fixed(Option<uint>), // [1,2,3,4] vstore_fixed(Option<uint>), // [1,2,3,4]
@ -382,7 +382,7 @@ pub enum unop {
neg neg
} }
pub type stmt = spanned<stmt_>; pub type stmt = Spanned<stmt_>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum stmt_ { pub enum stmt_ {
@ -408,10 +408,10 @@ pub struct Local {
pat: @pat, pat: @pat,
init: Option<@expr>, init: Option<@expr>,
id: NodeId, id: NodeId,
span: span, span: Span,
} }
pub type decl = spanned<decl_>; pub type decl = Spanned<decl_>;
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable,IterBytes)]
pub enum decl_ { pub enum decl_ {
@ -432,7 +432,7 @@ pub struct arm {
pub struct Field { pub struct Field {
ident: ident, ident: ident,
expr: @expr, expr: @expr,
span: span, span: Span,
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
@ -445,7 +445,7 @@ pub enum BlockCheckMode {
pub struct expr { pub struct expr {
id: NodeId, id: NodeId,
node: expr_, node: expr_,
span: span, span: Span,
} }
impl expr { impl expr {
@ -538,7 +538,7 @@ pub enum expr_ {
#[doc="For macro invocations; parsing is delegated to the macro"] #[doc="For macro invocations; parsing is delegated to the macro"]
pub enum token_tree { pub enum token_tree {
// a single token // a single token
tt_tok(span, ::parse::token::Token), tt_tok(Span, ::parse::token::Token),
// a delimited sequence (the delimiters appear as the first // a delimited sequence (the delimiters appear as the first
// and last elements of the vector) // and last elements of the vector)
tt_delim(@mut ~[token_tree]), tt_delim(@mut ~[token_tree]),
@ -547,10 +547,10 @@ pub enum token_tree {
// a kleene-style repetition sequence with a span, a tt_forest, // a kleene-style repetition sequence with a span, a tt_forest,
// an optional separator (?), and a boolean where true indicates // an optional separator (?), and a boolean where true indicates
// zero or more (*), and false indicates one or more (+). // zero or more (*), and false indicates one or more (+).
tt_seq(span, @mut ~[token_tree], Option<::parse::token::Token>, bool), tt_seq(Span, @mut ~[token_tree], Option<::parse::token::Token>, bool),
// a syntactic variable that will be filled in by macro expansion. // a syntactic variable that will be filled in by macro expansion.
tt_nonterminal(span, ident) tt_nonterminal(Span, ident)
} }
// //
@ -605,7 +605,7 @@ pub enum token_tree {
// If you understand that, you have closed to loop and understand the whole // If you understand that, you have closed to loop and understand the whole
// macro system. Congratulations. // macro system. Congratulations.
// //
pub type matcher = spanned<matcher_>; pub type matcher = Spanned<matcher_>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum matcher_ { pub enum matcher_ {
@ -618,14 +618,14 @@ pub enum matcher_ {
match_nonterminal(ident, ident, uint) match_nonterminal(ident, ident, uint)
} }
pub type mac = spanned<mac_>; pub type mac = Spanned<mac_>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum mac_ { pub enum mac_ {
mac_invoc_tt(Path,~[token_tree]), // new macro-invocation mac_invoc_tt(Path,~[token_tree]), // new macro-invocation
} }
pub type lit = spanned<lit_>; pub type lit = Spanned<lit_>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum lit_ { pub enum lit_ {
@ -651,7 +651,7 @@ pub struct mt {
pub struct TypeField { pub struct TypeField {
ident: ident, ident: ident,
mt: mt, mt: mt,
span: span, span: Span,
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
@ -663,7 +663,7 @@ pub struct TypeMethod {
generics: Generics, generics: Generics,
explicit_self: explicit_self, explicit_self: explicit_self,
id: NodeId, id: NodeId,
span: span, span: Span,
} }
// A trait method is either required (meaning it doesn't have an // A trait method is either required (meaning it doesn't have an
@ -724,7 +724,7 @@ impl ToStr for float_ty {
pub struct Ty { pub struct Ty {
id: NodeId, id: NodeId,
node: ty_, node: ty_,
span: span, span: Span,
} }
// Not represented directly in the AST, referred to by name through a ty_path. // Not represented directly in the AST, referred to by name through a ty_path.
@ -864,7 +864,7 @@ pub enum explicit_self_ {
sty_uniq // `~self` sty_uniq // `~self`
} }
pub type explicit_self = spanned<explicit_self_>; pub type explicit_self = Spanned<explicit_self_>;
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable,IterBytes)]
pub struct method { pub struct method {
@ -876,7 +876,7 @@ pub struct method {
decl: fn_decl, decl: fn_decl,
body: Block, body: Block,
id: NodeId, id: NodeId,
span: span, span: Span,
self_id: NodeId, self_id: NodeId,
vis: visibility, vis: visibility,
} }
@ -929,7 +929,7 @@ pub struct variant_ {
vis: visibility, vis: visibility,
} }
pub type variant = spanned<variant_>; pub type variant = Spanned<variant_>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct path_list_ident_ { pub struct path_list_ident_ {
@ -937,9 +937,9 @@ pub struct path_list_ident_ {
id: NodeId, id: NodeId,
} }
pub type path_list_ident = spanned<path_list_ident_>; pub type path_list_ident = Spanned<path_list_ident_>;
pub type view_path = spanned<view_path_>; pub type view_path = Spanned<view_path_>;
#[deriving(Eq, Encodable, Decodable, IterBytes)] #[deriving(Eq, Encodable, Decodable, IterBytes)]
pub enum view_path_ { pub enum view_path_ {
@ -963,7 +963,7 @@ pub struct view_item {
node: view_item_, node: view_item_,
attrs: ~[Attribute], attrs: ~[Attribute],
vis: visibility, vis: visibility,
span: span, span: Span,
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
@ -977,7 +977,7 @@ pub enum view_item_ {
} }
// Meta-data associated with an item // Meta-data associated with an item
pub type Attribute = spanned<Attribute_>; pub type Attribute = Spanned<Attribute_>;
// Distinguishes between Attributes that decorate items and Attributes that // Distinguishes between Attributes that decorate items and Attributes that
// are contained as statements within items. These two cases need to be // are contained as statements within items. These two cases need to be
@ -1033,7 +1033,7 @@ pub struct struct_field_ {
attrs: ~[Attribute], attrs: ~[Attribute],
} }
pub type struct_field = spanned<struct_field_>; pub type struct_field = Spanned<struct_field_>;
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable,IterBytes)]
pub enum struct_field_kind { pub enum struct_field_kind {
@ -1060,7 +1060,7 @@ pub struct item {
id: NodeId, id: NodeId,
node: item_, node: item_,
vis: visibility, vis: visibility,
span: span, span: Span,
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
@ -1087,7 +1087,7 @@ pub struct foreign_item {
attrs: ~[Attribute], attrs: ~[Attribute],
node: foreign_item_, node: foreign_item_,
id: NodeId, id: NodeId,
span: span, span: Span,
vis: visibility, vis: visibility,
} }

View File

@ -13,7 +13,7 @@ use ast::*;
use ast; use ast;
use ast_util::{inlined_item_utils, stmt_id}; use ast_util::{inlined_item_utils, stmt_id};
use ast_util; use ast_util;
use codemap::span; use codemap::Span;
use codemap; use codemap;
use diagnostic::span_handler; use diagnostic::span_handler;
use parse::token::ident_interner; use parse::token::ident_interner;
@ -148,7 +148,7 @@ impl Ctx {
fk: &visit::fn_kind, fk: &visit::fn_kind,
decl: &fn_decl, decl: &fn_decl,
body: &Block, body: &Block,
sp: codemap::span, sp: codemap::Span,
id: NodeId) { id: NodeId) {
for a in decl.inputs.iter() { for a in decl.inputs.iter() {
self.map.insert(a.id, node_arg); self.map.insert(a.id, node_arg);
@ -282,7 +282,7 @@ impl Visitor<()> for Ctx {
function_kind: &fn_kind, function_kind: &fn_kind,
function_declaration: &fn_decl, function_declaration: &fn_decl,
block: &Block, block: &Block,
span: span, span: Span,
node_id: NodeId, node_id: NodeId,
_: ()) { _: ()) {
self.map_fn(function_kind, function_declaration, block, span, node_id) self.map_fn(function_kind, function_declaration, block, span, node_id)
@ -294,7 +294,7 @@ impl Visitor<()> for Ctx {
// XXX: Methods below can become default methods. // XXX: Methods below can become default methods.
fn visit_mod(&mut self, module: &_mod, _: span, _: NodeId, _: ()) { fn visit_mod(&mut self, module: &_mod, _: Span, _: NodeId, _: ()) {
visit::walk_mod(self, module, ()) visit::walk_mod(self, module, ())
} }
@ -334,7 +334,7 @@ impl Visitor<()> for Ctx {
function_kind: &fn_kind, function_kind: &fn_kind,
function_declaration: &fn_decl, function_declaration: &fn_decl,
block: &Block, block: &Block,
span: span, span: Span,
node_id: NodeId, node_id: NodeId,
_: ()) { _: ()) {
visit::walk_fn(self, visit::walk_fn(self,

View File

@ -11,7 +11,7 @@
use ast::*; use ast::*;
use ast; use ast;
use ast_util; use ast_util;
use codemap::{span, dummy_sp}; use codemap::{Span, dummy_sp};
use opt_vec; use opt_vec;
use parse::token; use parse::token;
use visit::{SimpleVisitor, SimpleVisitorVisitor, Visitor}; use visit::{SimpleVisitor, SimpleVisitorVisitor, Visitor};
@ -217,7 +217,7 @@ pub fn default_block(
} }
} }
pub fn ident_to_path(s: span, identifier: ident) -> Path { pub fn ident_to_path(s: Span, identifier: ident) -> Path {
ast::Path { ast::Path {
span: s, span: s,
global: false, global: false,
@ -231,7 +231,7 @@ pub fn ident_to_path(s: span, identifier: ident) -> Path {
} }
} }
pub fn ident_to_pat(id: NodeId, s: span, i: ident) -> @pat { pub fn ident_to_pat(id: NodeId, s: Span, i: ident) -> @pat {
@ast::pat { id: id, @ast::pat { id: id,
node: pat_ident(bind_infer, ident_to_path(s, i), None), node: pat_ident(bind_infer, ident_to_path(s, i), None),
span: s } span: s }
@ -426,7 +426,7 @@ impl IdVisitor {
impl Visitor<()> for IdVisitor { impl Visitor<()> for IdVisitor {
fn visit_mod(&mut self, fn visit_mod(&mut self,
module: &_mod, module: &_mod,
_: span, _: Span,
node_id: NodeId, node_id: NodeId,
env: ()) { env: ()) {
(self.visit_callback)(node_id); (self.visit_callback)(node_id);
@ -551,7 +551,7 @@ impl Visitor<()> for IdVisitor {
function_kind: &visit::fn_kind, function_kind: &visit::fn_kind,
function_declaration: &fn_decl, function_declaration: &fn_decl,
block: &Block, block: &Block,
span: span, span: Span,
node_id: NodeId, node_id: NodeId,
env: ()) { env: ()) {
if !self.pass_through_items { if !self.pass_through_items {
@ -691,7 +691,7 @@ struct EachViewItemData {
} }
impl SimpleVisitor for EachViewItemData { impl SimpleVisitor for EachViewItemData {
fn visit_mod(&mut self, _: &_mod, _: span, _: NodeId) { fn visit_mod(&mut self, _: &_mod, _: Span, _: NodeId) {
// XXX: Default method. // XXX: Default method.
} }
fn visit_view_item(&mut self, view_item: &view_item) { fn visit_view_item(&mut self, view_item: &view_item) {
@ -737,7 +737,7 @@ impl SimpleVisitor for EachViewItemData {
_: &visit::fn_kind, _: &visit::fn_kind,
_: &fn_decl, _: &fn_decl,
_: &Block, _: &Block,
_: span, _: Span,
_: NodeId) { _: NodeId) {
// XXX: Default method. // XXX: Default method.
} }

View File

@ -14,7 +14,7 @@ use extra;
use ast; use ast;
use ast::{Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList}; use ast::{Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList};
use codemap::{spanned, dummy_spanned}; use codemap::{Spanned, spanned, dummy_spanned};
use codemap::BytePos; use codemap::BytePos;
use diagnostic::span_handler; use diagnostic::span_handler;
use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
@ -212,7 +212,7 @@ pub fn sort_meta_items(items: &[@MetaItem]) -> ~[@MetaItem] {
do v.move_iter().map |(_, m)| { do v.move_iter().map |(_, m)| {
match m.node { match m.node {
MetaList(n, ref mis) => { MetaList(n, ref mis) => {
@spanned { @Spanned {
node: MetaList(n, sort_meta_items(*mis)), node: MetaList(n, sort_meta_items(*mis)),
.. /*bad*/ (*m).clone() .. /*bad*/ (*m).clone()
} }

View File

@ -96,57 +96,57 @@ relative to FileMaps. Methods on the CodeMap can be used to relate spans back
to the original source. to the original source.
*/ */
#[deriving(Clone, IterBytes)] #[deriving(Clone, IterBytes)]
pub struct span { pub struct Span {
lo: BytePos, lo: BytePos,
hi: BytePos, hi: BytePos,
expn_info: Option<@ExpnInfo> expn_info: Option<@ExpnInfo>
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct spanned<T> { pub struct Spanned<T> {
node: T, node: T,
span: span, span: Span,
} }
impl cmp::Eq for span { impl cmp::Eq for Span {
fn eq(&self, other: &span) -> bool { fn eq(&self, other: &Span) -> bool {
return (*self).lo == (*other).lo && (*self).hi == (*other).hi; return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
} }
fn ne(&self, other: &span) -> bool { !(*self).eq(other) } fn ne(&self, other: &Span) -> bool { !(*self).eq(other) }
} }
impl<S:Encoder> Encodable<S> for span { impl<S:Encoder> Encodable<S> for Span {
/* Note #1972 -- spans are encoded but not decoded */ /* Note #1972 -- spans are encoded but not decoded */
fn encode(&self, s: &mut S) { fn encode(&self, s: &mut S) {
s.emit_nil() s.emit_nil()
} }
} }
impl<D:Decoder> Decodable<D> for span { impl<D:Decoder> Decodable<D> for Span {
fn decode(_d: &mut D) -> span { fn decode(_d: &mut D) -> Span {
dummy_sp() dummy_sp()
} }
} }
pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> spanned<T> { pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> Spanned<T> {
respan(mk_sp(lo, hi), t) respan(mk_sp(lo, hi), t)
} }
pub fn respan<T>(sp: span, t: T) -> spanned<T> { pub fn respan<T>(sp: Span, t: T) -> Spanned<T> {
spanned {node: t, span: sp} Spanned {node: t, span: sp}
} }
pub fn dummy_spanned<T>(t: T) -> spanned<T> { pub fn dummy_spanned<T>(t: T) -> Spanned<T> {
respan(dummy_sp(), t) respan(dummy_sp(), t)
} }
/* assuming that we're not in macro expansion */ /* assuming that we're not in macro expansion */
pub fn mk_sp(lo: BytePos, hi: BytePos) -> span { pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
span {lo: lo, hi: hi, expn_info: None} Span {lo: lo, hi: hi, expn_info: None}
} }
// make this a const, once the compiler supports it // make this a const, once the compiler supports it
pub fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); } pub fn dummy_sp() -> Span { return mk_sp(BytePos(0), BytePos(0)); }
@ -174,12 +174,12 @@ pub struct LocWithOpt {
pub struct FileMapAndLine {fm: @FileMap, line: uint} pub struct FileMapAndLine {fm: @FileMap, line: uint}
pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos} pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
#[deriving(IterBytes)] #[deriving(IterBytes)]
pub struct NameAndSpan {name: @str, span: Option<span>} pub struct NameAndSpan {name: @str, span: Option<Span>}
/// Extra information for tracking macro expansion of spans /// Extra information for tracking macro expansion of spans
#[deriving(IterBytes)] #[deriving(IterBytes)]
pub struct ExpnInfo { pub struct ExpnInfo {
call_site: span, call_site: Span,
callee: NameAndSpan callee: NameAndSpan
} }
@ -197,7 +197,7 @@ pub enum FileSubstr {
FssNone, FssNone,
// indicates that this "file" is actually a substring // indicates that this "file" is actually a substring
// of another file that appears earlier in the codemap // of another file that appears earlier in the codemap
FssInternal(span), FssInternal(Span),
} }
/// Identifies an offset of a multi-byte character in a FileMap /// Identifies an offset of a multi-byte character in a FileMap
@ -302,7 +302,7 @@ impl CodeMap {
return filemap; return filemap;
} }
pub fn mk_substr_filename(&self, sp: span) -> ~str { pub fn mk_substr_filename(&self, sp: Span) -> ~str {
let pos = self.lookup_char_pos(sp.lo); let pos = self.lookup_char_pos(sp.lo);
return fmt!("<%s:%u:%u>", pos.file.name, return fmt!("<%s:%u:%u>", pos.file.name,
pos.line, pos.col.to_uint()); pos.line, pos.col.to_uint());
@ -328,12 +328,12 @@ impl CodeMap {
} }
} }
pub fn adjust_span(&self, sp: span) -> span { pub fn adjust_span(&self, sp: Span) -> Span {
let line = self.lookup_line(sp.lo); let line = self.lookup_line(sp.lo);
match (line.fm.substr) { match (line.fm.substr) {
FssNone => sp, FssNone => sp,
FssInternal(s) => { FssInternal(s) => {
self.adjust_span(span { self.adjust_span(Span {
lo: s.lo + (sp.lo - line.fm.start_pos), lo: s.lo + (sp.lo - line.fm.start_pos),
hi: s.lo + (sp.hi - line.fm.start_pos), hi: s.lo + (sp.hi - line.fm.start_pos),
expn_info: sp.expn_info expn_info: sp.expn_info
@ -342,7 +342,7 @@ impl CodeMap {
} }
} }
pub fn span_to_str(&self, sp: span) -> ~str { pub fn span_to_str(&self, sp: Span) -> ~str {
let files = &*self.files; let files = &*self.files;
if files.len() == 0 && sp == dummy_sp() { if files.len() == 0 && sp == dummy_sp() {
return ~"no-location"; return ~"no-location";
@ -354,12 +354,12 @@ impl CodeMap {
lo.line, lo.col.to_uint(), hi.line, hi.col.to_uint()) lo.line, lo.col.to_uint(), hi.line, hi.col.to_uint())
} }
pub fn span_to_filename(&self, sp: span) -> FileName { pub fn span_to_filename(&self, sp: Span) -> FileName {
let lo = self.lookup_char_pos(sp.lo); let lo = self.lookup_char_pos(sp.lo);
lo.file.name lo.file.name
} }
pub fn span_to_lines(&self, sp: span) -> @FileLines { pub fn span_to_lines(&self, sp: Span) -> @FileLines {
let lo = self.lookup_char_pos(sp.lo); let lo = self.lookup_char_pos(sp.lo);
let hi = self.lookup_char_pos(sp.hi); let hi = self.lookup_char_pos(sp.hi);
let mut lines = ~[]; let mut lines = ~[];
@ -369,7 +369,7 @@ impl CodeMap {
return @FileLines {file: lo.file, lines: lines}; return @FileLines {file: lo.file, lines: lines};
} }
pub fn span_to_snippet(&self, sp: span) -> Option<~str> { pub fn span_to_snippet(&self, sp: Span) -> Option<~str> {
let begin = self.lookup_byte_offset(sp.lo); let begin = self.lookup_byte_offset(sp.lo);
let end = self.lookup_byte_offset(sp.hi); let end = self.lookup_byte_offset(sp.hi);
@ -446,7 +446,7 @@ impl CodeMap {
}; };
} }
fn span_to_str_no_adj(&self, sp: span) -> ~str { fn span_to_str_no_adj(&self, sp: Span) -> ~str {
let lo = self.lookup_char_pos(sp.lo); let lo = self.lookup_char_pos(sp.lo);
let hi = self.lookup_char_pos(sp.hi); let hi = self.lookup_char_pos(sp.hi);
return fmt!("%s:%u:%u: %u:%u", lo.file.name, return fmt!("%s:%u:%u: %u:%u", lo.file.name,

View File

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use codemap::{Pos, span}; use codemap::{Pos, Span};
use codemap; use codemap;
use std::io; use std::io;
use std::local_data; use std::local_data;
use extra::term; use extra::term;
pub type Emitter = @fn(cmsp: Option<(@codemap::CodeMap, span)>, pub type Emitter = @fn(cmsp: Option<(@codemap::CodeMap, Span)>,
msg: &str, msg: &str,
lvl: level); lvl: level);
@ -35,7 +35,7 @@ pub trait handler {
fn bug(@mut self, msg: &str) -> !; fn bug(@mut self, msg: &str) -> !;
fn unimpl(@mut self, msg: &str) -> !; fn unimpl(@mut self, msg: &str) -> !;
fn emit(@mut self, fn emit(@mut self,
cmsp: Option<(@codemap::CodeMap, span)>, cmsp: Option<(@codemap::CodeMap, Span)>,
msg: &str, msg: &str,
lvl: level); lvl: level);
} }
@ -44,12 +44,12 @@ pub trait handler {
// accepts span information for source-location // accepts span information for source-location
// reporting. // reporting.
pub trait span_handler { pub trait span_handler {
fn span_fatal(@mut self, sp: span, msg: &str) -> !; fn span_fatal(@mut self, sp: Span, msg: &str) -> !;
fn span_err(@mut self, sp: span, msg: &str); fn span_err(@mut self, sp: Span, msg: &str);
fn span_warn(@mut self, sp: span, msg: &str); fn span_warn(@mut self, sp: Span, msg: &str);
fn span_note(@mut self, sp: span, msg: &str); fn span_note(@mut self, sp: Span, msg: &str);
fn span_bug(@mut self, sp: span, msg: &str) -> !; fn span_bug(@mut self, sp: Span, msg: &str) -> !;
fn span_unimpl(@mut self, sp: span, msg: &str) -> !; fn span_unimpl(@mut self, sp: Span, msg: &str) -> !;
fn handler(@mut self) -> @mut handler; fn handler(@mut self) -> @mut handler;
} }
@ -64,24 +64,24 @@ struct CodemapT {
} }
impl span_handler for CodemapT { impl span_handler for CodemapT {
fn span_fatal(@mut self, sp: span, msg: &str) -> ! { fn span_fatal(@mut self, sp: Span, msg: &str) -> ! {
self.handler.emit(Some((self.cm, sp)), msg, fatal); self.handler.emit(Some((self.cm, sp)), msg, fatal);
fail!(); fail!();
} }
fn span_err(@mut self, sp: span, msg: &str) { fn span_err(@mut self, sp: Span, msg: &str) {
self.handler.emit(Some((self.cm, sp)), msg, error); self.handler.emit(Some((self.cm, sp)), msg, error);
self.handler.bump_err_count(); self.handler.bump_err_count();
} }
fn span_warn(@mut self, sp: span, msg: &str) { fn span_warn(@mut self, sp: Span, msg: &str) {
self.handler.emit(Some((self.cm, sp)), msg, warning); self.handler.emit(Some((self.cm, sp)), msg, warning);
} }
fn span_note(@mut self, sp: span, msg: &str) { fn span_note(@mut self, sp: Span, msg: &str) {
self.handler.emit(Some((self.cm, sp)), msg, note); self.handler.emit(Some((self.cm, sp)), msg, note);
} }
fn span_bug(@mut self, sp: span, msg: &str) -> ! { fn span_bug(@mut self, sp: Span, msg: &str) -> ! {
self.span_fatal(sp, ice_msg(msg)); self.span_fatal(sp, ice_msg(msg));
} }
fn span_unimpl(@mut self, sp: span, msg: &str) -> ! { fn span_unimpl(@mut self, sp: Span, msg: &str) -> ! {
self.span_bug(sp, ~"unimplemented " + msg); self.span_bug(sp, ~"unimplemented " + msg);
} }
fn handler(@mut self) -> @mut handler { fn handler(@mut self) -> @mut handler {
@ -132,7 +132,7 @@ impl handler for HandlerT {
self.bug(~"unimplemented " + msg); self.bug(~"unimplemented " + msg);
} }
fn emit(@mut self, fn emit(@mut self,
cmsp: Option<(@codemap::CodeMap, span)>, cmsp: Option<(@codemap::CodeMap, Span)>,
msg: &str, msg: &str,
lvl: level) { lvl: level) {
(self.emit)(cmsp, msg, lvl); (self.emit)(cmsp, msg, lvl);
@ -231,13 +231,13 @@ fn print_diagnostic(topic: &str, lvl: level, msg: &str) {
} }
pub fn collect(messages: @mut ~[~str]) pub fn collect(messages: @mut ~[~str])
-> @fn(Option<(@codemap::CodeMap, span)>, &str, level) { -> @fn(Option<(@codemap::CodeMap, Span)>, &str, level) {
let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) = let f: @fn(Option<(@codemap::CodeMap, Span)>, &str, level) =
|_o, msg: &str, _l| { messages.push(msg.to_str()); }; |_o, msg: &str, _l| { messages.push(msg.to_str()); };
f f
} }
pub fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) { pub fn emit(cmsp: Option<(@codemap::CodeMap, Span)>, msg: &str, lvl: level) {
match cmsp { match cmsp {
Some((cm, sp)) => { Some((cm, sp)) => {
let sp = cm.adjust_span(sp); let sp = cm.adjust_span(sp);
@ -254,7 +254,7 @@ pub fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) {
} }
fn highlight_lines(cm: @codemap::CodeMap, fn highlight_lines(cm: @codemap::CodeMap,
sp: span, lvl: level, sp: Span, lvl: level,
lines: @codemap::FileLines) { lines: @codemap::FileLines) {
let fm = lines.file; let fm = lines.file;
@ -330,7 +330,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
} }
} }
fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) { fn print_macro_backtrace(cm: @codemap::CodeMap, sp: Span) {
for ei in sp.expn_info.iter() { for ei in sp.expn_info.iter() {
let ss = ei.callee.span.map_default(~"", |span| cm.span_to_str(*span)); let ss = ei.callee.span.map_default(~"", |span| cm.span_to_str(*span));
print_diagnostic(ss, note, print_diagnostic(ss, note,

View File

@ -13,7 +13,7 @@
*/ */
use ast; use ast;
use codemap::span; use codemap::Span;
use ext::base; use ext::base;
use ext::base::*; use ext::base::*;
use parse; use parse;
@ -37,7 +37,7 @@ fn next_state(s: State) -> Option<State> {
} }
} }
pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let p = parse::new_parser_from_tts(cx.parse_sess(), let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(), cx.cfg(),

View File

@ -11,12 +11,12 @@
/// Deprecated #[auto_encode] and #[auto_decode] syntax extensions /// Deprecated #[auto_encode] and #[auto_decode] syntax extensions
use ast; use ast;
use codemap::span; use codemap::Span;
use ext::base::*; use ext::base::*;
pub fn expand_auto_encode( pub fn expand_auto_encode(
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
_mitem: @ast::MetaItem, _mitem: @ast::MetaItem,
in_items: ~[@ast::item] in_items: ~[@ast::item]
) -> ~[@ast::item] { ) -> ~[@ast::item] {
@ -26,7 +26,7 @@ pub fn expand_auto_encode(
pub fn expand_auto_decode( pub fn expand_auto_decode(
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
_mitem: @ast::MetaItem, _mitem: @ast::MetaItem,
in_items: ~[@ast::item] in_items: ~[@ast::item]
) -> ~[@ast::item] { ) -> ~[@ast::item] {

View File

@ -11,7 +11,7 @@
use ast; use ast;
use ast::Name; use ast::Name;
use codemap; use codemap;
use codemap::{CodeMap, span, ExpnInfo}; use codemap::{CodeMap, Span, ExpnInfo};
use diagnostic::span_handler; use diagnostic::span_handler;
use ext; use ext;
use parse; use parse;
@ -35,28 +35,28 @@ pub struct MacroDef {
} }
pub type ItemDecorator = @fn(@ExtCtxt, pub type ItemDecorator = @fn(@ExtCtxt,
span, Span,
@ast::MetaItem, @ast::MetaItem,
~[@ast::item]) ~[@ast::item])
-> ~[@ast::item]; -> ~[@ast::item];
pub struct SyntaxExpanderTT { pub struct SyntaxExpanderTT {
expander: SyntaxExpanderTTFun, expander: SyntaxExpanderTTFun,
span: Option<span> span: Option<Span>
} }
pub type SyntaxExpanderTTFun = @fn(@ExtCtxt, pub type SyntaxExpanderTTFun = @fn(@ExtCtxt,
span, Span,
&[ast::token_tree]) &[ast::token_tree])
-> MacResult; -> MacResult;
pub struct SyntaxExpanderTTItem { pub struct SyntaxExpanderTTItem {
expander: SyntaxExpanderTTItemFun, expander: SyntaxExpanderTTItemFun,
span: Option<span> span: Option<Span>
} }
pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt, pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt,
span, Span,
ast::ident, ast::ident,
~[ast::token_tree]) ~[ast::token_tree])
-> MacResult; -> MacResult;
@ -247,7 +247,7 @@ impl ExtCtxt {
pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm } pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess } pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() } pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() }
pub fn call_site(&self) -> span { pub fn call_site(&self) -> Span {
match *self.backtrace { match *self.backtrace {
Some(@ExpnInfo {call_site: cs, _}) => cs, Some(@ExpnInfo {call_site: cs, _}) => cs,
None => self.bug("missing top span") None => self.bug("missing top span")
@ -263,7 +263,7 @@ impl ExtCtxt {
ExpnInfo {call_site: cs, callee: ref callee} => { ExpnInfo {call_site: cs, callee: ref callee} => {
*self.backtrace = *self.backtrace =
Some(@ExpnInfo { Some(@ExpnInfo {
call_site: span {lo: cs.lo, hi: cs.hi, call_site: Span {lo: cs.lo, hi: cs.hi,
expn_info: *self.backtrace}, expn_info: *self.backtrace},
callee: *callee}); callee: *callee});
} }
@ -272,29 +272,29 @@ impl ExtCtxt {
pub fn bt_pop(&self) { pub fn bt_pop(&self) {
match *self.backtrace { match *self.backtrace {
Some(@ExpnInfo { Some(@ExpnInfo {
call_site: span {expn_info: prev, _}, _}) => { call_site: Span {expn_info: prev, _}, _}) => {
*self.backtrace = prev *self.backtrace = prev
} }
_ => self.bug("tried to pop without a push") _ => self.bug("tried to pop without a push")
} }
} }
pub fn span_fatal(&self, sp: span, msg: &str) -> ! { pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
self.print_backtrace(); self.print_backtrace();
self.parse_sess.span_diagnostic.span_fatal(sp, msg); self.parse_sess.span_diagnostic.span_fatal(sp, msg);
} }
pub fn span_err(&self, sp: span, msg: &str) { pub fn span_err(&self, sp: Span, msg: &str) {
self.print_backtrace(); self.print_backtrace();
self.parse_sess.span_diagnostic.span_err(sp, msg); self.parse_sess.span_diagnostic.span_err(sp, msg);
} }
pub fn span_warn(&self, sp: span, msg: &str) { pub fn span_warn(&self, sp: Span, msg: &str) {
self.print_backtrace(); self.print_backtrace();
self.parse_sess.span_diagnostic.span_warn(sp, msg); self.parse_sess.span_diagnostic.span_warn(sp, msg);
} }
pub fn span_unimpl(&self, sp: span, msg: &str) -> ! { pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
self.print_backtrace(); self.print_backtrace();
self.parse_sess.span_diagnostic.span_unimpl(sp, msg); self.parse_sess.span_diagnostic.span_unimpl(sp, msg);
} }
pub fn span_bug(&self, sp: span, msg: &str) -> ! { pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
self.print_backtrace(); self.print_backtrace();
self.parse_sess.span_diagnostic.span_bug(sp, msg); self.parse_sess.span_diagnostic.span_bug(sp, msg);
} }
@ -329,7 +329,7 @@ pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::expr, err_msg: &str) -> @str {
} }
} }
pub fn check_zero_tts(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree], pub fn check_zero_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree],
name: &str) { name: &str) {
if tts.len() != 0 { if tts.len() != 0 {
cx.span_fatal(sp, fmt!("%s takes no arguments", name)); cx.span_fatal(sp, fmt!("%s takes no arguments", name));
@ -337,7 +337,7 @@ pub fn check_zero_tts(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree],
} }
pub fn get_single_str_from_tts(cx: @ExtCtxt, pub fn get_single_str_from_tts(cx: @ExtCtxt,
sp: span, sp: Span,
tts: &[ast::token_tree], tts: &[ast::token_tree],
name: &str) name: &str)
-> @str { -> @str {
@ -352,7 +352,7 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt,
} }
pub fn get_exprs_from_tts(cx: @ExtCtxt, pub fn get_exprs_from_tts(cx: @ExtCtxt,
sp: span, sp: Span,
tts: &[ast::token_tree]) -> ~[@ast::expr] { tts: &[ast::token_tree]) -> ~[@ast::expr] {
let p = parse::new_parser_from_tts(cx.parse_sess(), let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(), cx.cfg(),

View File

@ -12,7 +12,7 @@ use abi::AbiSet;
use ast::ident; use ast::ident;
use ast; use ast;
use ast_util; use ast_util;
use codemap::{span, respan, dummy_sp}; use codemap::{Span, respan, dummy_sp};
use fold; use fold;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::quote::rt::*; use ext::quote::rt::*;
@ -32,10 +32,10 @@ mod syntax {
pub trait AstBuilder { pub trait AstBuilder {
// paths // paths
fn path(&self, span: span, strs: ~[ast::ident]) -> ast::Path; fn path(&self, span: Span, strs: ~[ast::ident]) -> ast::Path;
fn path_ident(&self, span: span, id: ast::ident) -> ast::Path; fn path_ident(&self, span: Span, id: ast::ident) -> ast::Path;
fn path_global(&self, span: span, strs: ~[ast::ident]) -> ast::Path; fn path_global(&self, span: Span, strs: ~[ast::ident]) -> ast::Path;
fn path_all(&self, sp: span, fn path_all(&self, sp: Span,
global: bool, global: bool,
idents: ~[ast::ident], idents: ~[ast::ident],
rp: Option<ast::Lifetime>, rp: Option<ast::Lifetime>,
@ -45,37 +45,37 @@ pub trait AstBuilder {
// types // types
fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt; fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt;
fn ty(&self, span: span, ty: ast::ty_) -> ast::Ty; fn ty(&self, span: Span, ty: ast::ty_) -> ast::Ty;
fn ty_path(&self, ast::Path, Option<OptVec<ast::TyParamBound>>) -> ast::Ty; fn ty_path(&self, ast::Path, Option<OptVec<ast::TyParamBound>>) -> ast::Ty;
fn ty_ident(&self, span: span, idents: ast::ident) -> ast::Ty; fn ty_ident(&self, span: Span, idents: ast::ident) -> ast::Ty;
fn ty_rptr(&self, span: span, fn ty_rptr(&self, span: Span,
ty: ast::Ty, ty: ast::Ty,
lifetime: Option<ast::Lifetime>, lifetime: Option<ast::Lifetime>,
mutbl: ast::mutability) -> ast::Ty; mutbl: ast::mutability) -> ast::Ty;
fn ty_uniq(&self, span: span, ty: ast::Ty) -> ast::Ty; fn ty_uniq(&self, span: Span, ty: ast::Ty) -> ast::Ty;
fn ty_box(&self, span: span, ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty; fn ty_box(&self, span: Span, ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty;
fn ty_option(&self, ty: ast::Ty) -> ast::Ty; fn ty_option(&self, ty: ast::Ty) -> ast::Ty;
fn ty_infer(&self, sp: span) -> ast::Ty; fn ty_infer(&self, sp: Span) -> ast::Ty;
fn ty_nil(&self) -> ast::Ty; fn ty_nil(&self) -> ast::Ty;
fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty]; fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty];
fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty]; fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty];
fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::TypeField; fn ty_field_imm(&self, span: Span, name: ident, ty: ast::Ty) -> ast::TypeField;
fn strip_bounds(&self, bounds: &Generics) -> Generics; fn strip_bounds(&self, bounds: &Generics) -> Generics;
fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam; fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam;
fn trait_ref(&self, path: ast::Path) -> ast::trait_ref; fn trait_ref(&self, path: ast::Path) -> ast::trait_ref;
fn typarambound(&self, path: ast::Path) -> ast::TyParamBound; fn typarambound(&self, path: ast::Path) -> ast::TyParamBound;
fn lifetime(&self, span: span, ident: ast::ident) -> ast::Lifetime; fn lifetime(&self, span: Span, ident: ast::ident) -> ast::Lifetime;
// statements // statements
fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt; fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt;
fn stmt_let(&self, sp: span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt; fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt;
fn stmt_let_typed(&self, fn stmt_let_typed(&self,
sp: span, sp: Span,
mutbl: bool, mutbl: bool,
ident: ast::ident, ident: ast::ident,
typ: ast::Ty, typ: ast::Ty,
@ -83,165 +83,165 @@ pub trait AstBuilder {
-> @ast::stmt; -> @ast::stmt;
// blocks // blocks
fn block(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::Block; fn block(&self, span: Span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::Block;
fn block_expr(&self, expr: @ast::expr) -> ast::Block; fn block_expr(&self, expr: @ast::expr) -> ast::Block;
fn block_all(&self, span: span, fn block_all(&self, span: Span,
view_items: ~[ast::view_item], view_items: ~[ast::view_item],
stmts: ~[@ast::stmt], stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> ast::Block; expr: Option<@ast::expr>) -> ast::Block;
// expressions // expressions
fn expr(&self, span: span, node: ast::expr_) -> @ast::expr; fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr;
fn expr_path(&self, path: ast::Path) -> @ast::expr; fn expr_path(&self, path: ast::Path) -> @ast::expr;
fn expr_ident(&self, span: span, id: ast::ident) -> @ast::expr; fn expr_ident(&self, span: Span, id: ast::ident) -> @ast::expr;
fn expr_self(&self, span: span) -> @ast::expr; fn expr_self(&self, span: Span) -> @ast::expr;
fn expr_binary(&self, sp: span, op: ast::binop, fn expr_binary(&self, sp: Span, op: ast::binop,
lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr; lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr;
fn expr_deref(&self, sp: span, e: @ast::expr) -> @ast::expr; fn expr_deref(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_unary(&self, sp: span, op: ast::unop, e: @ast::expr) -> @ast::expr; fn expr_unary(&self, sp: Span, op: ast::unop, e: @ast::expr) -> @ast::expr;
fn expr_managed(&self, sp: span, e: @ast::expr) -> @ast::expr; fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_addr_of(&self, sp: span, e: @ast::expr) -> @ast::expr; fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_mut_addr_of(&self, sp: span, e: @ast::expr) -> @ast::expr; fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_field_access(&self, span: span, expr: @ast::expr, ident: ast::ident) -> @ast::expr; fn expr_field_access(&self, span: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr;
fn expr_call(&self, span: span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr; fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr;
fn expr_call_ident(&self, span: span, id: ast::ident, args: ~[@ast::expr]) -> @ast::expr; fn expr_call_ident(&self, span: Span, id: ast::ident, args: ~[@ast::expr]) -> @ast::expr;
fn expr_call_global(&self, sp: span, fn_path: ~[ast::ident], fn expr_call_global(&self, sp: Span, fn_path: ~[ast::ident],
args: ~[@ast::expr]) -> @ast::expr; args: ~[@ast::expr]) -> @ast::expr;
fn expr_method_call(&self, span: span, fn expr_method_call(&self, span: Span,
expr: @ast::expr, ident: ast::ident, expr: @ast::expr, ident: ast::ident,
args: ~[@ast::expr]) -> @ast::expr; args: ~[@ast::expr]) -> @ast::expr;
fn expr_block(&self, b: ast::Block) -> @ast::expr; fn expr_block(&self, b: ast::Block) -> @ast::expr;
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::Field; fn field_imm(&self, span: Span, name: ident, e: @ast::expr) -> ast::Field;
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr; fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr;
fn expr_struct_ident(&self, span: span, id: ast::ident, fields: ~[ast::Field]) -> @ast::expr; fn expr_struct_ident(&self, span: Span, id: ast::ident, fields: ~[ast::Field]) -> @ast::expr;
fn expr_lit(&self, sp: span, lit: ast::lit_) -> @ast::expr; fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::expr;
fn expr_uint(&self, span: span, i: uint) -> @ast::expr; fn expr_uint(&self, span: Span, i: uint) -> @ast::expr;
fn expr_int(&self, sp: span, i: int) -> @ast::expr; fn expr_int(&self, sp: Span, i: int) -> @ast::expr;
fn expr_u8(&self, sp: span, u: u8) -> @ast::expr; fn expr_u8(&self, sp: Span, u: u8) -> @ast::expr;
fn expr_bool(&self, sp: span, value: bool) -> @ast::expr; fn expr_bool(&self, sp: Span, value: bool) -> @ast::expr;
fn expr_vstore(&self, sp: span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr; fn expr_vstore(&self, sp: Span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr;
fn expr_vec(&self, sp: span, exprs: ~[@ast::expr]) -> @ast::expr; fn expr_vec(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr;
fn expr_vec_uniq(&self, sp: span, exprs: ~[@ast::expr]) -> @ast::expr; fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr;
fn expr_vec_slice(&self, sp: span, exprs: ~[@ast::expr]) -> @ast::expr; fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr;
fn expr_str(&self, sp: span, s: @str) -> @ast::expr; fn expr_str(&self, sp: Span, s: @str) -> @ast::expr;
fn expr_str_uniq(&self, sp: span, s: @str) -> @ast::expr; fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::expr;
fn expr_unreachable(&self, span: span) -> @ast::expr; fn expr_unreachable(&self, span: Span) -> @ast::expr;
fn pat(&self, span: span, pat: ast::pat_) -> @ast::pat; fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat;
fn pat_wild(&self, span: span) -> @ast::pat; fn pat_wild(&self, span: Span) -> @ast::pat;
fn pat_lit(&self, span: span, expr: @ast::expr) -> @ast::pat; fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat;
fn pat_ident(&self, span: span, ident: ast::ident) -> @ast::pat; fn pat_ident(&self, span: Span, ident: ast::ident) -> @ast::pat;
fn pat_ident_binding_mode(&self, fn pat_ident_binding_mode(&self,
span: span, span: Span,
ident: ast::ident, ident: ast::ident,
bm: ast::binding_mode) -> @ast::pat; bm: ast::binding_mode) -> @ast::pat;
fn pat_enum(&self, span: span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat; fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat;
fn pat_struct(&self, span: span, fn pat_struct(&self, span: Span,
path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat; path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat;
fn arm(&self, span: span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm; fn arm(&self, span: Span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm;
fn arm_unreachable(&self, span: span) -> ast::arm; fn arm_unreachable(&self, span: Span) -> ast::arm;
fn expr_match(&self, span: span, arg: @ast::expr, arms: ~[ast::arm]) -> @ast::expr; fn expr_match(&self, span: Span, arg: @ast::expr, arms: ~[ast::arm]) -> @ast::expr;
fn expr_if(&self, span: span, fn expr_if(&self, span: Span,
cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr; cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr;
fn lambda_fn_decl(&self, span: span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr; fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr;
fn lambda(&self, span: span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr; fn lambda(&self, span: Span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr;
fn lambda0(&self, span: span, blk: ast::Block) -> @ast::expr; fn lambda0(&self, span: Span, blk: ast::Block) -> @ast::expr;
fn lambda1(&self, span: span, blk: ast::Block, ident: ast::ident) -> @ast::expr; fn lambda1(&self, span: Span, blk: ast::Block, ident: ast::ident) -> @ast::expr;
fn lambda_expr(&self, span: span, ids: ~[ast::ident], blk: @ast::expr) -> @ast::expr; fn lambda_expr(&self, span: Span, ids: ~[ast::ident], blk: @ast::expr) -> @ast::expr;
fn lambda_expr_0(&self, span: span, expr: @ast::expr) -> @ast::expr; fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr;
fn lambda_expr_1(&self, span: span, expr: @ast::expr, ident: ast::ident) -> @ast::expr; fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr;
fn lambda_stmts(&self, span: span, ids: ~[ast::ident], blk: ~[@ast::stmt]) -> @ast::expr; fn lambda_stmts(&self, span: Span, ids: ~[ast::ident], blk: ~[@ast::stmt]) -> @ast::expr;
fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr; fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr;
fn lambda_stmts_1(&self, span: span, stmts: ~[@ast::stmt], ident: ast::ident) -> @ast::expr; fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::ident) -> @ast::expr;
// items // items
fn item(&self, span: span, fn item(&self, span: Span,
name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item; name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item;
fn arg(&self, span: span, name: ident, ty: ast::Ty) -> ast::arg; fn arg(&self, span: Span, name: ident, ty: ast::Ty) -> ast::arg;
// XXX unused self // XXX unused self
fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl; fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl;
fn item_fn_poly(&self, fn item_fn_poly(&self,
span: span, span: Span,
name: ident, name: ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
generics: Generics, generics: Generics,
body: ast::Block) -> @ast::item; body: ast::Block) -> @ast::item;
fn item_fn(&self, fn item_fn(&self,
span: span, span: Span,
name: ident, name: ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
body: ast::Block) -> @ast::item; body: ast::Block) -> @ast::item;
fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant; fn variant(&self, span: Span, name: ident, tys: ~[ast::Ty]) -> ast::variant;
fn item_enum_poly(&self, fn item_enum_poly(&self,
span: span, span: Span,
name: ident, name: ident,
enum_definition: ast::enum_def, enum_definition: ast::enum_def,
generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_enum(&self, span: span, name: ident, enum_def: ast::enum_def) -> @ast::item; fn item_enum(&self, span: Span, name: ident, enum_def: ast::enum_def) -> @ast::item;
fn item_struct_poly(&self, fn item_struct_poly(&self,
span: span, span: Span,
name: ident, name: ident,
struct_def: ast::struct_def, struct_def: ast::struct_def,
generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_struct(&self, span: span, name: ident, struct_def: ast::struct_def) -> @ast::item; fn item_struct(&self, span: Span, name: ident, struct_def: ast::struct_def) -> @ast::item;
fn item_mod(&self, span: span, fn item_mod(&self, span: Span,
name: ident, attrs: ~[ast::Attribute], name: ident, attrs: ~[ast::Attribute],
vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item; vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item;
fn item_ty_poly(&self, fn item_ty_poly(&self,
span: span, span: Span,
name: ident, name: ident,
ty: ast::Ty, ty: ast::Ty,
generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_ty(&self, span: span, name: ident, ty: ast::Ty) -> @ast::item; fn item_ty(&self, span: Span, name: ident, ty: ast::Ty) -> @ast::item;
fn attribute(&self, sp: span, mi: @ast::MetaItem) -> ast::Attribute; fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute;
fn meta_word(&self, sp: span, w: @str) -> @ast::MetaItem; fn meta_word(&self, sp: Span, w: @str) -> @ast::MetaItem;
fn meta_list(&self, sp: span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem; fn meta_list(&self, sp: Span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem;
fn meta_name_value(&self, sp: span, name: @str, value: ast::lit_) -> @ast::MetaItem; fn meta_name_value(&self, sp: Span, name: @str, value: ast::lit_) -> @ast::MetaItem;
fn view_use(&self, sp: span, fn view_use(&self, sp: Span,
vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item; vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item;
fn view_use_list(&self, sp: span, vis: ast::visibility, fn view_use_list(&self, sp: Span, vis: ast::visibility,
path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item; path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item;
fn view_use_glob(&self, sp: span, fn view_use_glob(&self, sp: Span,
vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item; vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item;
} }
impl AstBuilder for @ExtCtxt { impl AstBuilder for @ExtCtxt {
fn path(&self, span: span, strs: ~[ast::ident]) -> ast::Path { fn path(&self, span: Span, strs: ~[ast::ident]) -> ast::Path {
self.path_all(span, false, strs, None, ~[]) self.path_all(span, false, strs, None, ~[])
} }
fn path_ident(&self, span: span, id: ast::ident) -> ast::Path { fn path_ident(&self, span: Span, id: ast::ident) -> ast::Path {
self.path(span, ~[id]) self.path(span, ~[id])
} }
fn path_global(&self, span: span, strs: ~[ast::ident]) -> ast::Path { fn path_global(&self, span: Span, strs: ~[ast::ident]) -> ast::Path {
self.path_all(span, true, strs, None, ~[]) self.path_all(span, true, strs, None, ~[])
} }
fn path_all(&self, fn path_all(&self,
sp: span, sp: Span,
global: bool, global: bool,
mut idents: ~[ast::ident], mut idents: ~[ast::ident],
rp: Option<ast::Lifetime>, rp: Option<ast::Lifetime>,
@ -275,7 +275,7 @@ impl AstBuilder for @ExtCtxt {
} }
} }
fn ty(&self, span: span, ty: ast::ty_) -> ast::Ty { fn ty(&self, span: Span, ty: ast::ty_) -> ast::Ty {
ast::Ty { ast::Ty {
id: self.next_id(), id: self.next_id(),
span: span, span: span,
@ -291,13 +291,13 @@ impl AstBuilder for @ExtCtxt {
// Might need to take bounds as an argument in the future, if you ever want // Might need to take bounds as an argument in the future, if you ever want
// to generate a bounded existential trait type. // to generate a bounded existential trait type.
fn ty_ident(&self, span: span, ident: ast::ident) fn ty_ident(&self, span: Span, ident: ast::ident)
-> ast::Ty { -> ast::Ty {
self.ty_path(self.path_ident(span, ident), None) self.ty_path(self.path_ident(span, ident), None)
} }
fn ty_rptr(&self, fn ty_rptr(&self,
span: span, span: Span,
ty: ast::Ty, ty: ast::Ty,
lifetime: Option<ast::Lifetime>, lifetime: Option<ast::Lifetime>,
mutbl: ast::mutability) mutbl: ast::mutability)
@ -305,10 +305,10 @@ impl AstBuilder for @ExtCtxt {
self.ty(span, self.ty(span,
ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl))) ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl)))
} }
fn ty_uniq(&self, span: span, ty: ast::Ty) -> ast::Ty { fn ty_uniq(&self, span: Span, ty: ast::Ty) -> ast::Ty {
self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::m_imm))) self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::m_imm)))
} }
fn ty_box(&self, span: span, fn ty_box(&self, span: Span,
ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty { ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty {
self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl))) self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl)))
} }
@ -326,7 +326,7 @@ impl AstBuilder for @ExtCtxt {
~[ ty ]), None) ~[ ty ]), None)
} }
fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::TypeField { fn ty_field_imm(&self, span: Span, name: ident, ty: ast::Ty) -> ast::TypeField {
ast::TypeField { ast::TypeField {
ident: name, ident: name,
mt: ast::mt { ty: ~ty, mutbl: ast::m_imm }, mt: ast::mt { ty: ~ty, mutbl: ast::m_imm },
@ -334,7 +334,7 @@ impl AstBuilder for @ExtCtxt {
} }
} }
fn ty_infer(&self, span: span) -> ast::Ty { fn ty_infer(&self, span: Span) -> ast::Ty {
self.ty(span, ast::ty_infer) self.ty(span, ast::ty_infer)
} }
@ -385,7 +385,7 @@ impl AstBuilder for @ExtCtxt {
ast::TraitTyParamBound(self.trait_ref(path)) ast::TraitTyParamBound(self.trait_ref(path))
} }
fn lifetime(&self, span: span, ident: ast::ident) -> ast::Lifetime { fn lifetime(&self, span: Span, ident: ast::ident) -> ast::Lifetime {
ast::Lifetime { id: self.next_id(), span: span, ident: ident } ast::Lifetime { id: self.next_id(), span: span, ident: ident }
} }
@ -393,7 +393,7 @@ impl AstBuilder for @ExtCtxt {
@respan(expr.span, ast::stmt_semi(expr, self.next_id())) @respan(expr.span, ast::stmt_semi(expr, self.next_id()))
} }
fn stmt_let(&self, sp: span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt { fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt {
let pat = self.pat_ident(sp, ident); let pat = self.pat_ident(sp, ident);
let local = @ast::Local { let local = @ast::Local {
is_mutbl: mutbl, is_mutbl: mutbl,
@ -408,7 +408,7 @@ impl AstBuilder for @ExtCtxt {
} }
fn stmt_let_typed(&self, fn stmt_let_typed(&self,
sp: span, sp: Span,
mutbl: bool, mutbl: bool,
ident: ast::ident, ident: ast::ident,
typ: ast::Ty, typ: ast::Ty,
@ -427,7 +427,7 @@ impl AstBuilder for @ExtCtxt {
@respan(sp, ast::stmt_decl(@decl, self.next_id())) @respan(sp, ast::stmt_decl(@decl, self.next_id()))
} }
fn block(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@expr>) -> ast::Block { fn block(&self, span: Span, stmts: ~[@ast::stmt], expr: Option<@expr>) -> ast::Block {
self.block_all(span, ~[], stmts, expr) self.block_all(span, ~[], stmts, expr)
} }
@ -435,7 +435,7 @@ impl AstBuilder for @ExtCtxt {
self.block_all(expr.span, ~[], ~[], Some(expr)) self.block_all(expr.span, ~[], ~[], Some(expr))
} }
fn block_all(&self, fn block_all(&self,
span: span, span: Span,
view_items: ~[ast::view_item], view_items: ~[ast::view_item],
stmts: ~[@ast::stmt], stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> ast::Block { expr: Option<@ast::expr>) -> ast::Block {
@ -449,7 +449,7 @@ impl AstBuilder for @ExtCtxt {
} }
} }
fn expr(&self, span: span, node: ast::expr_) -> @ast::expr { fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr {
@ast::expr { @ast::expr {
id: self.next_id(), id: self.next_id(),
node: node, node: node,
@ -461,53 +461,53 @@ impl AstBuilder for @ExtCtxt {
self.expr(path.span, ast::expr_path(path)) self.expr(path.span, ast::expr_path(path))
} }
fn expr_ident(&self, span: span, id: ast::ident) -> @ast::expr { fn expr_ident(&self, span: Span, id: ast::ident) -> @ast::expr {
self.expr_path(self.path_ident(span, id)) self.expr_path(self.path_ident(span, id))
} }
fn expr_self(&self, span: span) -> @ast::expr { fn expr_self(&self, span: Span) -> @ast::expr {
self.expr(span, ast::expr_self) self.expr(span, ast::expr_self)
} }
fn expr_binary(&self, sp: span, op: ast::binop, fn expr_binary(&self, sp: Span, op: ast::binop,
lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr { lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr {
self.expr(sp, ast::expr_binary(self.next_id(), op, lhs, rhs)) self.expr(sp, ast::expr_binary(self.next_id(), op, lhs, rhs))
} }
fn expr_deref(&self, sp: span, e: @ast::expr) -> @ast::expr { fn expr_deref(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr_unary(sp, ast::deref, e) self.expr_unary(sp, ast::deref, e)
} }
fn expr_unary(&self, sp: span, op: ast::unop, e: @ast::expr) fn expr_unary(&self, sp: Span, op: ast::unop, e: @ast::expr)
-> @ast::expr { -> @ast::expr {
self.expr(sp, ast::expr_unary(self.next_id(), op, e)) self.expr(sp, ast::expr_unary(self.next_id(), op, e))
} }
fn expr_managed(&self, sp: span, e: @ast::expr) -> @ast::expr { fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr_unary(sp, ast::box(ast::m_imm), e) self.expr_unary(sp, ast::box(ast::m_imm), e)
} }
fn expr_field_access(&self, sp: span, expr: @ast::expr, ident: ast::ident) -> @ast::expr { fn expr_field_access(&self, sp: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr {
self.expr(sp, ast::expr_field(expr, ident, ~[])) self.expr(sp, ast::expr_field(expr, ident, ~[]))
} }
fn expr_addr_of(&self, sp: span, e: @ast::expr) -> @ast::expr { fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr(sp, ast::expr_addr_of(ast::m_imm, e)) self.expr(sp, ast::expr_addr_of(ast::m_imm, e))
} }
fn expr_mut_addr_of(&self, sp: span, e: @ast::expr) -> @ast::expr { fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr(sp, ast::expr_addr_of(ast::m_mutbl, e)) self.expr(sp, ast::expr_addr_of(ast::m_mutbl, e))
} }
fn expr_call(&self, span: span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr { fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr {
self.expr(span, ast::expr_call(expr, args, ast::NoSugar)) self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
} }
fn expr_call_ident(&self, span: span, id: ast::ident, args: ~[@ast::expr]) -> @ast::expr { fn expr_call_ident(&self, span: Span, id: ast::ident, args: ~[@ast::expr]) -> @ast::expr {
self.expr(span, self.expr(span,
ast::expr_call(self.expr_ident(span, id), args, ast::NoSugar)) ast::expr_call(self.expr_ident(span, id), args, ast::NoSugar))
} }
fn expr_call_global(&self, sp: span, fn_path: ~[ast::ident], fn expr_call_global(&self, sp: Span, fn_path: ~[ast::ident],
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = self.expr_path(self.path_global(sp, fn_path)); let pathexpr = self.expr_path(self.path_global(sp, fn_path));
self.expr_call(sp, pathexpr, args) self.expr_call(sp, pathexpr, args)
} }
fn expr_method_call(&self, span: span, fn expr_method_call(&self, span: Span,
expr: @ast::expr, expr: @ast::expr,
ident: ast::ident, ident: ast::ident,
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
@ -517,54 +517,54 @@ impl AstBuilder for @ExtCtxt {
fn expr_block(&self, b: ast::Block) -> @ast::expr { fn expr_block(&self, b: ast::Block) -> @ast::expr {
self.expr(b.span, ast::expr_block(b)) self.expr(b.span, ast::expr_block(b))
} }
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::Field { fn field_imm(&self, span: Span, name: ident, e: @ast::expr) -> ast::Field {
ast::Field { ident: name, expr: e, span: span } ast::Field { ident: name, expr: e, span: span }
} }
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr { fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr {
self.expr(span, ast::expr_struct(path, fields, None)) self.expr(span, ast::expr_struct(path, fields, None))
} }
fn expr_struct_ident(&self, span: span, fn expr_struct_ident(&self, span: Span,
id: ast::ident, fields: ~[ast::Field]) -> @ast::expr { id: ast::ident, fields: ~[ast::Field]) -> @ast::expr {
self.expr_struct(span, self.path_ident(span, id), fields) self.expr_struct(span, self.path_ident(span, id), fields)
} }
fn expr_lit(&self, sp: span, lit: ast::lit_) -> @ast::expr { fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::expr {
self.expr(sp, ast::expr_lit(@respan(sp, lit))) self.expr(sp, ast::expr_lit(@respan(sp, lit)))
} }
fn expr_uint(&self, span: span, i: uint) -> @ast::expr { fn expr_uint(&self, span: Span, i: uint) -> @ast::expr {
self.expr_lit(span, ast::lit_uint(i as u64, ast::ty_u)) self.expr_lit(span, ast::lit_uint(i as u64, ast::ty_u))
} }
fn expr_int(&self, sp: span, i: int) -> @ast::expr { fn expr_int(&self, sp: Span, i: int) -> @ast::expr {
self.expr_lit(sp, ast::lit_int(i as i64, ast::ty_i)) self.expr_lit(sp, ast::lit_int(i as i64, ast::ty_i))
} }
fn expr_u8(&self, sp: span, u: u8) -> @ast::expr { fn expr_u8(&self, sp: Span, u: u8) -> @ast::expr {
self.expr_lit(sp, ast::lit_uint(u as u64, ast::ty_u8)) self.expr_lit(sp, ast::lit_uint(u as u64, ast::ty_u8))
} }
fn expr_bool(&self, sp: span, value: bool) -> @ast::expr { fn expr_bool(&self, sp: Span, value: bool) -> @ast::expr {
self.expr_lit(sp, ast::lit_bool(value)) self.expr_lit(sp, ast::lit_bool(value))
} }
fn expr_vstore(&self, sp: span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr { fn expr_vstore(&self, sp: Span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr {
self.expr(sp, ast::expr_vstore(expr, vst)) self.expr(sp, ast::expr_vstore(expr, vst))
} }
fn expr_vec(&self, sp: span, exprs: ~[@ast::expr]) -> @ast::expr { fn expr_vec(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr {
self.expr(sp, ast::expr_vec(exprs, ast::m_imm)) self.expr(sp, ast::expr_vec(exprs, ast::m_imm))
} }
fn expr_vec_uniq(&self, sp: span, exprs: ~[@ast::expr]) -> @ast::expr { fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr {
self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_uniq) self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_uniq)
} }
fn expr_vec_slice(&self, sp: span, exprs: ~[@ast::expr]) -> @ast::expr { fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr {
self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_slice) self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_slice)
} }
fn expr_str(&self, sp: span, s: @str) -> @ast::expr { fn expr_str(&self, sp: Span, s: @str) -> @ast::expr {
self.expr_lit(sp, ast::lit_str(s)) self.expr_lit(sp, ast::lit_str(s))
} }
fn expr_str_uniq(&self, sp: span, s: @str) -> @ast::expr { fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::expr {
self.expr_vstore(sp, self.expr_str(sp, s), ast::expr_vstore_uniq) self.expr_vstore(sp, self.expr_str(sp, s), ast::expr_vstore_uniq)
} }
fn expr_unreachable(&self, span: span) -> @ast::expr { fn expr_unreachable(&self, span: Span) -> @ast::expr {
let loc = self.codemap().lookup_char_pos(span.lo); let loc = self.codemap().lookup_char_pos(span.lo);
self.expr_call_global( self.expr_call_global(
span, span,
@ -582,38 +582,38 @@ impl AstBuilder for @ExtCtxt {
} }
fn pat(&self, span: span, pat: ast::pat_) -> @ast::pat { fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat {
@ast::pat { id: self.next_id(), node: pat, span: span } @ast::pat { id: self.next_id(), node: pat, span: span }
} }
fn pat_wild(&self, span: span) -> @ast::pat { fn pat_wild(&self, span: Span) -> @ast::pat {
self.pat(span, ast::pat_wild) self.pat(span, ast::pat_wild)
} }
fn pat_lit(&self, span: span, expr: @ast::expr) -> @ast::pat { fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat {
self.pat(span, ast::pat_lit(expr)) self.pat(span, ast::pat_lit(expr))
} }
fn pat_ident(&self, span: span, ident: ast::ident) -> @ast::pat { fn pat_ident(&self, span: Span, ident: ast::ident) -> @ast::pat {
self.pat_ident_binding_mode(span, ident, ast::bind_infer) self.pat_ident_binding_mode(span, ident, ast::bind_infer)
} }
fn pat_ident_binding_mode(&self, fn pat_ident_binding_mode(&self,
span: span, span: Span,
ident: ast::ident, ident: ast::ident,
bm: ast::binding_mode) -> @ast::pat { bm: ast::binding_mode) -> @ast::pat {
let path = self.path_ident(span, ident); let path = self.path_ident(span, ident);
let pat = ast::pat_ident(bm, path, None); let pat = ast::pat_ident(bm, path, None);
self.pat(span, pat) self.pat(span, pat)
} }
fn pat_enum(&self, span: span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat { fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat {
let pat = ast::pat_enum(path, Some(subpats)); let pat = ast::pat_enum(path, Some(subpats));
self.pat(span, pat) self.pat(span, pat)
} }
fn pat_struct(&self, span: span, fn pat_struct(&self, span: Span,
path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat { path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat {
let pat = ast::pat_struct(path, field_pats, false); let pat = ast::pat_struct(path, field_pats, false);
self.pat(span, pat) self.pat(span, pat)
} }
fn arm(&self, _span: span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm { fn arm(&self, _span: Span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm {
ast::arm { ast::arm {
pats: pats, pats: pats,
guard: None, guard: None,
@ -621,24 +621,24 @@ impl AstBuilder for @ExtCtxt {
} }
} }
fn arm_unreachable(&self, span: span) -> ast::arm { fn arm_unreachable(&self, span: Span) -> ast::arm {
self.arm(span, ~[self.pat_wild(span)], self.expr_unreachable(span)) self.arm(span, ~[self.pat_wild(span)], self.expr_unreachable(span))
} }
fn expr_match(&self, span: span, arg: @ast::expr, arms: ~[ast::arm]) -> @expr { fn expr_match(&self, span: Span, arg: @ast::expr, arms: ~[ast::arm]) -> @expr {
self.expr(span, ast::expr_match(arg, arms)) self.expr(span, ast::expr_match(arg, arms))
} }
fn expr_if(&self, span: span, fn expr_if(&self, span: Span,
cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr { cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr {
let els = els.map_move(|x| self.expr_block(self.block_expr(x))); let els = els.map_move(|x| self.expr_block(self.block_expr(x)));
self.expr(span, ast::expr_if(cond, self.block_expr(then), els)) self.expr(span, ast::expr_if(cond, self.block_expr(then), els))
} }
fn lambda_fn_decl(&self, span: span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr { fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr {
self.expr(span, ast::expr_fn_block(fn_decl, blk)) self.expr(span, ast::expr_fn_block(fn_decl, blk))
} }
fn lambda(&self, span: span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr { fn lambda(&self, span: Span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr {
let fn_decl = self.fn_decl( let fn_decl = self.fn_decl(
ids.map(|id| self.arg(span, *id, self.ty_infer(span))), ids.map(|id| self.arg(span, *id, self.ty_infer(span))),
self.ty_infer(span)); self.ty_infer(span));
@ -646,50 +646,50 @@ impl AstBuilder for @ExtCtxt {
self.expr(span, ast::expr_fn_block(fn_decl, blk)) self.expr(span, ast::expr_fn_block(fn_decl, blk))
} }
#[cfg(stage0)] #[cfg(stage0)]
fn lambda0(&self, _span: span, blk: ast::Block) -> @ast::expr { fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::expr {
let ext_cx = *self; let ext_cx = *self;
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
quote_expr!(|| $blk_e ) quote_expr!(|| $blk_e )
} }
#[cfg(not(stage0))] #[cfg(not(stage0))]
fn lambda0(&self, _span: span, blk: ast::Block) -> @ast::expr { fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::expr {
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
quote_expr!(*self, || $blk_e ) quote_expr!(*self, || $blk_e )
} }
#[cfg(stage0)] #[cfg(stage0)]
fn lambda1(&self, _span: span, blk: ast::Block, ident: ast::ident) -> @ast::expr { fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::ident) -> @ast::expr {
let ext_cx = *self; let ext_cx = *self;
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
quote_expr!(|$ident| $blk_e ) quote_expr!(|$ident| $blk_e )
} }
#[cfg(not(stage0))] #[cfg(not(stage0))]
fn lambda1(&self, _span: span, blk: ast::Block, ident: ast::ident) -> @ast::expr { fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::ident) -> @ast::expr {
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
quote_expr!(*self, |$ident| $blk_e ) quote_expr!(*self, |$ident| $blk_e )
} }
fn lambda_expr(&self, span: span, ids: ~[ast::ident], expr: @ast::expr) -> @ast::expr { fn lambda_expr(&self, span: Span, ids: ~[ast::ident], expr: @ast::expr) -> @ast::expr {
self.lambda(span, ids, self.block_expr(expr)) self.lambda(span, ids, self.block_expr(expr))
} }
fn lambda_expr_0(&self, span: span, expr: @ast::expr) -> @ast::expr { fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr {
self.lambda0(span, self.block_expr(expr)) self.lambda0(span, self.block_expr(expr))
} }
fn lambda_expr_1(&self, span: span, expr: @ast::expr, ident: ast::ident) -> @ast::expr { fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr {
self.lambda1(span, self.block_expr(expr), ident) self.lambda1(span, self.block_expr(expr), ident)
} }
fn lambda_stmts(&self, span: span, ids: ~[ast::ident], stmts: ~[@ast::stmt]) -> @ast::expr { fn lambda_stmts(&self, span: Span, ids: ~[ast::ident], stmts: ~[@ast::stmt]) -> @ast::expr {
self.lambda(span, ids, self.block(span, stmts, None)) self.lambda(span, ids, self.block(span, stmts, None))
} }
fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr { fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr {
self.lambda0(span, self.block(span, stmts, None)) self.lambda0(span, self.block(span, stmts, None))
} }
fn lambda_stmts_1(&self, span: span, stmts: ~[@ast::stmt], ident: ast::ident) -> @ast::expr { fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::ident) -> @ast::expr {
self.lambda1(span, self.block(span, stmts, None), ident) self.lambda1(span, self.block(span, stmts, None), ident)
} }
fn arg(&self, span: span, ident: ast::ident, ty: ast::Ty) -> ast::arg { fn arg(&self, span: Span, ident: ast::ident, ty: ast::Ty) -> ast::arg {
let arg_pat = self.pat_ident(span, ident); let arg_pat = self.pat_ident(span, ident);
ast::arg { ast::arg {
is_mutbl: false, is_mutbl: false,
@ -708,7 +708,7 @@ impl AstBuilder for @ExtCtxt {
} }
} }
fn item(&self, span: span, fn item(&self, span: Span,
name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item { name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item {
// XXX: Would be nice if our generated code didn't violate // XXX: Would be nice if our generated code didn't violate
// Rust coding conventions // Rust coding conventions
@ -721,7 +721,7 @@ impl AstBuilder for @ExtCtxt {
} }
fn item_fn_poly(&self, fn item_fn_poly(&self,
span: span, span: Span,
name: ident, name: ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
@ -738,7 +738,7 @@ impl AstBuilder for @ExtCtxt {
} }
fn item_fn(&self, fn item_fn(&self,
span: span, span: Span,
name: ident, name: ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
@ -753,7 +753,7 @@ impl AstBuilder for @ExtCtxt {
body) body)
} }
fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant { fn variant(&self, span: Span, name: ident, tys: ~[ast::Ty]) -> ast::variant {
let args = tys.move_iter().map(|ty| { let args = tys.move_iter().map(|ty| {
ast::variant_arg { ty: ty, id: self.next_id() } ast::variant_arg { ty: ty, id: self.next_id() }
}).collect(); }).collect();
@ -769,13 +769,13 @@ impl AstBuilder for @ExtCtxt {
}) })
} }
fn item_enum_poly(&self, span: span, name: ident, fn item_enum_poly(&self, span: Span, name: ident,
enum_definition: ast::enum_def, enum_definition: ast::enum_def,
generics: Generics) -> @ast::item { generics: Generics) -> @ast::item {
self.item(span, name, ~[], ast::item_enum(enum_definition, generics)) self.item(span, name, ~[], ast::item_enum(enum_definition, generics))
} }
fn item_enum(&self, span: span, name: ident, fn item_enum(&self, span: Span, name: ident,
enum_definition: ast::enum_def) -> @ast::item { enum_definition: ast::enum_def) -> @ast::item {
self.item_enum_poly(span, name, enum_definition, self.item_enum_poly(span, name, enum_definition,
ast_util::empty_generics()) ast_util::empty_generics())
@ -783,7 +783,7 @@ impl AstBuilder for @ExtCtxt {
fn item_struct( fn item_struct(
&self, &self,
span: span, span: Span,
name: ident, name: ident,
struct_def: ast::struct_def struct_def: ast::struct_def
) -> @ast::item { ) -> @ast::item {
@ -797,7 +797,7 @@ impl AstBuilder for @ExtCtxt {
fn item_struct_poly( fn item_struct_poly(
&self, &self,
span: span, span: Span,
name: ident, name: ident,
struct_def: ast::struct_def, struct_def: ast::struct_def,
generics: Generics generics: Generics
@ -805,7 +805,7 @@ impl AstBuilder for @ExtCtxt {
self.item(span, name, ~[], ast::item_struct(@struct_def, generics)) self.item(span, name, ~[], ast::item_struct(@struct_def, generics))
} }
fn item_mod(&self, span: span, name: ident, fn item_mod(&self, span: Span, name: ident,
attrs: ~[ast::Attribute], attrs: ~[ast::Attribute],
vi: ~[ast::view_item], vi: ~[ast::view_item],
items: ~[@ast::item]) -> @ast::item { items: ~[@ast::item]) -> @ast::item {
@ -820,16 +820,16 @@ impl AstBuilder for @ExtCtxt {
) )
} }
fn item_ty_poly(&self, span: span, name: ident, ty: ast::Ty, fn item_ty_poly(&self, span: Span, name: ident, ty: ast::Ty,
generics: Generics) -> @ast::item { generics: Generics) -> @ast::item {
self.item(span, name, ~[], ast::item_ty(ty, generics)) self.item(span, name, ~[], ast::item_ty(ty, generics))
} }
fn item_ty(&self, span: span, name: ident, ty: ast::Ty) -> @ast::item { fn item_ty(&self, span: Span, name: ident, ty: ast::Ty) -> @ast::item {
self.item_ty_poly(span, name, ty, ast_util::empty_generics()) self.item_ty_poly(span, name, ty, ast_util::empty_generics())
} }
fn attribute(&self, sp: span, mi: @ast::MetaItem) -> ast::Attribute { fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute {
respan(sp, ast::Attribute_ { respan(sp, ast::Attribute_ {
style: ast::AttrOuter, style: ast::AttrOuter,
value: mi, value: mi,
@ -837,17 +837,17 @@ impl AstBuilder for @ExtCtxt {
}) })
} }
fn meta_word(&self, sp: span, w: @str) -> @ast::MetaItem { fn meta_word(&self, sp: Span, w: @str) -> @ast::MetaItem {
@respan(sp, ast::MetaWord(w)) @respan(sp, ast::MetaWord(w))
} }
fn meta_list(&self, sp: span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem { fn meta_list(&self, sp: Span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem {
@respan(sp, ast::MetaList(name, mis)) @respan(sp, ast::MetaList(name, mis))
} }
fn meta_name_value(&self, sp: span, name: @str, value: ast::lit_) -> @ast::MetaItem { fn meta_name_value(&self, sp: Span, name: @str, value: ast::lit_) -> @ast::MetaItem {
@respan(sp, ast::MetaNameValue(name, respan(sp, value))) @respan(sp, ast::MetaNameValue(name, respan(sp, value)))
} }
fn view_use(&self, sp: span, fn view_use(&self, sp: Span,
vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item { vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item {
ast::view_item { ast::view_item {
node: ast::view_item_use(vp), node: ast::view_item_use(vp),
@ -857,7 +857,7 @@ impl AstBuilder for @ExtCtxt {
} }
} }
fn view_use_list(&self, sp: span, vis: ast::visibility, fn view_use_list(&self, sp: Span, vis: ast::visibility,
path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item { path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item {
let imports = do imports.map |id| { let imports = do imports.map |id| {
respan(sp, ast::path_list_ident_ { name: *id, id: self.next_id() }) respan(sp, ast::path_list_ident_ { name: *id, id: self.next_id() })
@ -870,7 +870,7 @@ impl AstBuilder for @ExtCtxt {
self.next_id()))]) self.next_id()))])
} }
fn view_use_glob(&self, sp: span, fn view_use_glob(&self, sp: Span,
vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item { vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item {
self.view_use(sp, vis, self.view_use(sp, vis,
~[@respan(sp, ~[@respan(sp,

View File

@ -11,12 +11,12 @@
/* The compiler code necessary to support the bytes! extension. */ /* The compiler code necessary to support the bytes! extension. */
use ast; use ast;
use codemap::span; use codemap::Span;
use ext::base::*; use ext::base::*;
use ext::base; use ext::base;
use ext::build::AstBuilder; use ext::build::AstBuilder;
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult {
// Gather all argument expressions // Gather all argument expressions
let exprs = get_exprs_from_tts(cx, sp, tts); let exprs = get_exprs_from_tts(cx, sp, tts);
let mut bytes = ~[]; let mut bytes = ~[];

View File

@ -15,7 +15,7 @@ match the current compilation environment.
*/ */
use ast; use ast;
use codemap::span; use codemap::Span;
use ext::base::*; use ext::base::*;
use ext::base; use ext::base;
use ext::build::AstBuilder; use ext::build::AstBuilder;
@ -25,7 +25,7 @@ use parse;
use parse::token; use parse::token;
use parse::attr::parser_attr; use parse::attr::parser_attr;
pub fn expand_cfg(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { pub fn expand_cfg(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult {
let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_owned()); let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_owned());
let mut cfgs = ~[]; let mut cfgs = ~[];

View File

@ -9,14 +9,14 @@
// except according to those terms. // except according to those terms.
use ast; use ast;
use codemap::span; use codemap::Span;
use ext::base::*; use ext::base::*;
use ext::base; use ext::base;
use opt_vec; use opt_vec;
use parse::token; use parse::token;
use parse::token::{str_to_ident}; use parse::token::{str_to_ident};
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let mut res_str = ~""; let mut res_str = ~"";
for (i, e) in tts.iter().enumerate() { for (i, e) in tts.iter().enumerate() {

View File

@ -9,13 +9,13 @@
// except according to those terms. // except according to those terms.
use ast::{MetaItem, item, expr}; use ast::{MetaItem, item, expr};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_clone(cx: @ExtCtxt, pub fn expand_deriving_clone(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) in_items: ~[@item])
-> ~[@item] { -> ~[@item] {
@ -40,7 +40,7 @@ pub fn expand_deriving_clone(cx: @ExtCtxt,
} }
pub fn expand_deriving_deep_clone(cx: @ExtCtxt, pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) in_items: ~[@item])
-> ~[@item] { -> ~[@item] {
@ -68,7 +68,7 @@ pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
fn cs_clone( fn cs_clone(
name: &str, name: &str,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let clone_ident = substr.method_ident; let clone_ident = substr.method_ident;
let ctor_ident; let ctor_ident;

View File

@ -9,22 +9,22 @@
// except according to those terms. // except according to those terms.
use ast::{MetaItem, item, expr}; use ast::{MetaItem, item, expr};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_eq(cx: @ExtCtxt, pub fn expand_deriving_eq(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
// structures are equal if all fields are equal, and non equal, if // structures are equal if all fields are equal, and non equal, if
// any fields are not equal or if the enum variants are different // any fields are not equal or if the enum variants are different
fn cs_eq(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr { fn cs_eq(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
cs_and(|cx, span, _, _| cx.expr_bool(span, false), cs_and(|cx, span, _, _| cx.expr_bool(span, false),
cx, span, substr) cx, span, substr)
} }
fn cs_ne(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr { fn cs_ne(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
cs_or(|cx, span, _, _| cx.expr_bool(span, true), cs_or(|cx, span, _, _| cx.expr_bool(span, true),
cx, span, substr) cx, span, substr)
} }

View File

@ -10,13 +10,13 @@
use ast; use ast;
use ast::{MetaItem, item, expr}; use ast::{MetaItem, item, expr};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_ord(cx: @ExtCtxt, pub fn expand_deriving_ord(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
macro_rules! md ( macro_rules! md (
@ -48,7 +48,7 @@ pub fn expand_deriving_ord(cx: @ExtCtxt,
} }
/// Strict inequality. /// Strict inequality.
fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr { fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
let op = if less {ast::lt} else {ast::gt}; let op = if less {ast::lt} else {ast::gt};
cs_fold( cs_fold(
false, // need foldr, false, // need foldr,

View File

@ -9,16 +9,16 @@
// except according to those terms. // except according to those terms.
use ast::{MetaItem, item, expr}; use ast::{MetaItem, item, expr};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_totaleq(cx: @ExtCtxt, pub fn expand_deriving_totaleq(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
fn cs_equals(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr { fn cs_equals(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
cs_and(|cx, span, _, _| cx.expr_bool(span, false), cs_and(|cx, span, _, _| cx.expr_bool(span, false),
cx, span, substr) cx, span, substr)
} }

View File

@ -10,14 +10,14 @@
use ast; use ast;
use ast::{MetaItem, item, expr}; use ast::{MetaItem, item, expr};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
use std::cmp::{Ordering, Equal, Less, Greater}; use std::cmp::{Ordering, Equal, Less, Greater};
pub fn expand_deriving_totalord(cx: @ExtCtxt, pub fn expand_deriving_totalord(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
let trait_def = TraitDef { let trait_def = TraitDef {
@ -41,7 +41,7 @@ pub fn expand_deriving_totalord(cx: @ExtCtxt,
} }
pub fn ordering_const(cx: @ExtCtxt, span: span, cnst: Ordering) -> ast::Path { pub fn ordering_const(cx: @ExtCtxt, span: Span, cnst: Ordering) -> ast::Path {
let cnst = match cnst { let cnst = match cnst {
Less => "Less", Less => "Less",
Equal => "Equal", Equal => "Equal",
@ -53,7 +53,7 @@ pub fn ordering_const(cx: @ExtCtxt, span: span, cnst: Ordering) -> ast::Path {
cx.ident_of(cnst)]) cx.ident_of(cnst)])
} }
pub fn cs_cmp(cx: @ExtCtxt, span: span, pub fn cs_cmp(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let test_id = cx.ident_of("__test"); let test_id = cx.ident_of("__test");
let equals_path = ordering_const(cx, span, Equal); let equals_path = ordering_const(cx, span, Equal);

View File

@ -16,13 +16,13 @@ encodable.rs for more.
use std::vec; use std::vec;
use ast::{MetaItem, item, expr, m_mutbl}; use ast::{MetaItem, item, expr, m_mutbl};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_decodable(cx: @ExtCtxt, pub fn expand_deriving_decodable(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
let trait_def = TraitDef { let trait_def = TraitDef {
@ -50,7 +50,7 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items) trait_def.expand(cx, span, mitem, in_items)
} }
fn decodable_substructure(cx: @ExtCtxt, span: span, fn decodable_substructure(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let decoder = substr.nonself_args[0]; let decoder = substr.nonself_args[0];
let recurse = ~[cx.ident_of("extra"), let recurse = ~[cx.ident_of("extra"),

View File

@ -44,7 +44,7 @@ Other interesting scenarios are whe the item has type parameters or
references other non-built-in types. A type definition like: references other non-built-in types. A type definition like:
#[deriving(Encodable, Decodable)] #[deriving(Encodable, Decodable)]
struct spanned<T> {node: T, span: span} struct spanned<T> {node: T, span: Span}
would yield functions like: would yield functions like:
@ -76,13 +76,13 @@ would yield functions like:
*/ */
use ast::{MetaItem, item, expr, m_imm, m_mutbl}; use ast::{MetaItem, item, expr, m_imm, m_mutbl};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_encodable(cx: @ExtCtxt, pub fn expand_deriving_encodable(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
let trait_def = TraitDef { let trait_def = TraitDef {
@ -110,7 +110,7 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items) trait_def.expand(cx, span, mitem, in_items)
} }
fn encodable_substructure(cx: @ExtCtxt, span: span, fn encodable_substructure(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let encoder = substr.nonself_args[0]; let encoder = substr.nonself_args[0];
// throw an underscore in front to suppress unused variable warnings // throw an underscore in front to suppress unused variable warnings

View File

@ -167,7 +167,7 @@ use ast::{enum_def, expr, ident, Generics, struct_def};
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use codemap::{span,respan}; use codemap::{Span,respan};
use opt_vec; use opt_vec;
use std::vec; use std::vec;
@ -263,7 +263,7 @@ Combine the values of all the fields together. The last argument is
all the fields of all the structures, see above for details. all the fields of all the structures, see above for details.
*/ */
pub type CombineSubstructureFunc<'self> = pub type CombineSubstructureFunc<'self> =
&'self fn(@ExtCtxt, span, &Substructure) -> @expr; &'self fn(@ExtCtxt, Span, &Substructure) -> @expr;
/** /**
Deal with non-matching enum variants, the arguments are a list Deal with non-matching enum variants, the arguments are a list
@ -271,7 +271,7 @@ representing each variant: (variant index, ast::variant instance,
[variant fields]), and a list of the nonself args of the type [variant fields]), and a list of the nonself args of the type
*/ */
pub type EnumNonMatchFunc<'self> = pub type EnumNonMatchFunc<'self> =
&'self fn(@ExtCtxt, span, &'self fn(@ExtCtxt, Span,
&[(uint, ast::variant, &[(uint, ast::variant,
~[(Option<ident>, @expr)])], ~[(Option<ident>, @expr)])],
&[@expr]) -> @expr; &[@expr]) -> @expr;
@ -279,7 +279,7 @@ pub type EnumNonMatchFunc<'self> =
impl<'self> TraitDef<'self> { impl<'self> TraitDef<'self> {
pub fn expand(&self, cx: @ExtCtxt, pub fn expand(&self, cx: @ExtCtxt,
span: span, span: Span,
_mitem: @ast::MetaItem, _mitem: @ast::MetaItem,
in_items: ~[@ast::item]) -> ~[@ast::item] { in_items: ~[@ast::item]) -> ~[@ast::item] {
let mut result = ~[]; let mut result = ~[];
@ -314,7 +314,7 @@ impl<'self> TraitDef<'self> {
* where B1, B2, ... are the bounds given by `bounds_paths`.' * where B1, B2, ... are the bounds given by `bounds_paths`.'
* *
*/ */
fn create_derived_impl(&self, cx: @ExtCtxt, span: span, fn create_derived_impl(&self, cx: @ExtCtxt, span: Span,
type_ident: ident, generics: &Generics, type_ident: ident, generics: &Generics,
methods: ~[@ast::method]) -> @ast::item { methods: ~[@ast::method]) -> @ast::item {
let trait_path = self.path.to_path(cx, span, type_ident, generics); let trait_path = self.path.to_path(cx, span, type_ident, generics);
@ -373,7 +373,7 @@ impl<'self> TraitDef<'self> {
} }
fn expand_struct_def(&self, cx: @ExtCtxt, fn expand_struct_def(&self, cx: @ExtCtxt,
span: span, span: Span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
generics: &Generics) -> @ast::item { generics: &Generics) -> @ast::item {
@ -404,7 +404,7 @@ impl<'self> TraitDef<'self> {
} }
fn expand_enum_def(&self, fn expand_enum_def(&self,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
generics: &Generics) -> @ast::item { generics: &Generics) -> @ast::item {
@ -438,7 +438,7 @@ impl<'self> TraitDef<'self> {
impl<'self> MethodDef<'self> { impl<'self> MethodDef<'self> {
fn call_substructure_method(&self, fn call_substructure_method(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
nonself_args: &[@expr], nonself_args: &[@expr],
@ -455,7 +455,7 @@ impl<'self> MethodDef<'self> {
&substructure) &substructure)
} }
fn get_ret_ty(&self, cx: @ExtCtxt, span: span, fn get_ret_ty(&self, cx: @ExtCtxt, span: Span,
generics: &Generics, type_ident: ident) -> ast::Ty { generics: &Generics, type_ident: ident) -> ast::Ty {
self.ret_ty.to_ty(cx, span, type_ident, generics) self.ret_ty.to_ty(cx, span, type_ident, generics)
} }
@ -464,7 +464,7 @@ impl<'self> MethodDef<'self> {
self.explicit_self.is_none() self.explicit_self.is_none()
} }
fn split_self_nonself_args(&self, cx: @ExtCtxt, span: span, fn split_self_nonself_args(&self, cx: @ExtCtxt, span: Span,
type_ident: ident, generics: &Generics) type_ident: ident, generics: &Generics)
-> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, ast::Ty)]) { -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, ast::Ty)]) {
@ -510,7 +510,7 @@ impl<'self> MethodDef<'self> {
(ast_explicit_self, self_args, nonself_args, arg_tys) (ast_explicit_self, self_args, nonself_args, arg_tys)
} }
fn create_method(&self, cx: @ExtCtxt, span: span, fn create_method(&self, cx: @ExtCtxt, span: Span,
type_ident: ident, type_ident: ident,
generics: &Generics, generics: &Generics,
explicit_self: ast::explicit_self, explicit_self: ast::explicit_self,
@ -569,7 +569,7 @@ impl<'self> MethodDef<'self> {
*/ */
fn expand_struct_method_body(&self, fn expand_struct_method_body(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
@ -623,7 +623,7 @@ impl<'self> MethodDef<'self> {
fn expand_static_struct_method_body(&self, fn expand_static_struct_method_body(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
@ -665,7 +665,7 @@ impl<'self> MethodDef<'self> {
*/ */
fn expand_enum_method_body(&self, fn expand_enum_method_body(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
@ -700,7 +700,7 @@ impl<'self> MethodDef<'self> {
the first call). the first call).
*/ */
fn build_enum_match(&self, fn build_enum_match(&self,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
@ -850,7 +850,7 @@ impl<'self> MethodDef<'self> {
fn expand_static_enum_method_body(&self, fn expand_static_enum_method_body(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
@ -873,7 +873,7 @@ impl<'self> MethodDef<'self> {
} }
} }
fn summarise_struct(cx: @ExtCtxt, span: span, fn summarise_struct(cx: @ExtCtxt, span: Span,
struct_def: &struct_def) -> Either<uint, ~[ident]> { struct_def: &struct_def) -> Either<uint, ~[ident]> {
let mut named_idents = ~[]; let mut named_idents = ~[];
let mut unnamed_count = 0; let mut unnamed_count = 0;
@ -896,7 +896,7 @@ fn summarise_struct(cx: @ExtCtxt, span: span,
} }
pub fn create_subpatterns(cx: @ExtCtxt, pub fn create_subpatterns(cx: @ExtCtxt,
span: span, span: Span,
field_paths: ~[ast::Path], field_paths: ~[ast::Path],
mutbl: ast::mutability) mutbl: ast::mutability)
-> ~[@ast::pat] { -> ~[@ast::pat] {
@ -912,7 +912,7 @@ enum StructType {
} }
fn create_struct_pattern(cx: @ExtCtxt, fn create_struct_pattern(cx: @ExtCtxt,
span: span, span: Span,
struct_ident: ident, struct_ident: ident,
struct_def: &struct_def, struct_def: &struct_def,
prefix: &str, prefix: &str,
@ -973,7 +973,7 @@ fn create_struct_pattern(cx: @ExtCtxt,
} }
fn create_enum_variant_pattern(cx: @ExtCtxt, fn create_enum_variant_pattern(cx: @ExtCtxt,
span: span, span: Span,
variant: &ast::variant, variant: &ast::variant,
prefix: &str, prefix: &str,
mutbl: ast::mutability) mutbl: ast::mutability)
@ -1022,13 +1022,13 @@ Fold the fields. `use_foldl` controls whether this is done
left-to-right (`true`) or right-to-left (`false`). left-to-right (`true`) or right-to-left (`false`).
*/ */
pub fn cs_fold(use_foldl: bool, pub fn cs_fold(use_foldl: bool,
f: &fn(@ExtCtxt, span, f: &fn(@ExtCtxt, Span,
old: @expr, old: @expr,
self_f: @expr, self_f: @expr,
other_fs: &[@expr]) -> @expr, other_fs: &[@expr]) -> @expr,
base: @expr, base: @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
match *substructure.fields { match *substructure.fields {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
@ -1064,9 +1064,9 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
~~~ ~~~
*/ */
#[inline] #[inline]
pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr, pub fn cs_same_method(f: &fn(@ExtCtxt, Span, ~[@expr]) -> @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
match *substructure.fields { match *substructure.fields {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
@ -1097,10 +1097,10 @@ fields. `use_foldl` controls whether this is done left-to-right
*/ */
#[inline] #[inline]
pub fn cs_same_method_fold(use_foldl: bool, pub fn cs_same_method_fold(use_foldl: bool,
f: &fn(@ExtCtxt, span, @expr, @expr) -> @expr, f: &fn(@ExtCtxt, Span, @expr, @expr) -> @expr,
base: @expr, base: @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_same_method( cs_same_method(
|cx, span, vals| { |cx, span, vals| {
@ -1126,7 +1126,7 @@ on all the fields.
#[inline] #[inline]
pub fn cs_binop(binop: ast::binop, base: @expr, pub fn cs_binop(binop: ast::binop, base: @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_same_method_fold( cs_same_method_fold(
true, // foldl is good enough true, // foldl is good enough
@ -1144,7 +1144,7 @@ pub fn cs_binop(binop: ast::binop, base: @expr,
/// cs_binop with binop == or /// cs_binop with binop == or
#[inline] #[inline]
pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_binop(ast::or, cx.expr_bool(span, false), cs_binop(ast::or, cx.expr_bool(span, false),
enum_nonmatch_f, enum_nonmatch_f,
@ -1153,7 +1153,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
/// cs_binop with binop == and /// cs_binop with binop == and
#[inline] #[inline]
pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span, cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_binop(ast::and, cx.expr_bool(span, true), cs_binop(ast::and, cx.expr_bool(span, true),
enum_nonmatch_f, enum_nonmatch_f,

View File

@ -9,14 +9,14 @@
// except according to those terms. // except according to those terms.
use ast::{MetaItem, item, expr, and}; use ast::{MetaItem, item, expr, and};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_iter_bytes(cx: @ExtCtxt, pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
let trait_def = TraitDef { let trait_def = TraitDef {
@ -42,7 +42,7 @@ pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items) trait_def.expand(cx, span, mitem, in_items)
} }
fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr { fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
let (lsb0, f)= match substr.nonself_args { let (lsb0, f)= match substr.nonself_args {
[l, f] => (l, f), [l, f] => (l, f),
_ => cx.span_bug(span, "Incorrect number of arguments in `deriving(IterBytes)`") _ => cx.span_bug(span, "Incorrect number of arguments in `deriving(IterBytes)`")

View File

@ -22,7 +22,7 @@ use ast::{enum_def, ident, item, Generics, struct_def};
use ast::{MetaItem, MetaList, MetaNameValue, MetaWord}; use ast::{MetaItem, MetaList, MetaNameValue, MetaWord};
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use codemap::span; use codemap::Span;
pub mod clone; pub mod clone;
pub mod iter_bytes; pub mod iter_bytes;
@ -45,20 +45,20 @@ pub mod totalord;
pub mod generic; pub mod generic;
pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt, pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt,
span, Span,
x: &struct_def, x: &struct_def,
ident, ident,
y: &Generics) y: &Generics)
-> @item; -> @item;
pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt, pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt,
span, Span,
x: &enum_def, x: &enum_def,
ident, ident,
y: &Generics) y: &Generics)
-> @item; -> @item;
pub fn expand_meta_deriving(cx: @ExtCtxt, pub fn expand_meta_deriving(cx: @ExtCtxt,
_span: span, _span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) in_items: ~[@item])
-> ~[@item] { -> ~[@item] {

View File

@ -10,7 +10,7 @@
use ast; use ast;
use ast::{MetaItem, item, expr, ident}; use ast::{MetaItem, item, expr, ident};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::{AstBuilder, Duplicate}; use ext::build::{AstBuilder, Duplicate};
use ext::deriving::generic::*; use ext::deriving::generic::*;
@ -18,7 +18,7 @@ use ext::deriving::generic::*;
use std::vec; use std::vec;
pub fn expand_deriving_rand(cx: @ExtCtxt, pub fn expand_deriving_rand(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) in_items: ~[@item])
-> ~[@item] { -> ~[@item] {
@ -48,7 +48,7 @@ pub fn expand_deriving_rand(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items) trait_def.expand(cx, span, mitem, in_items)
} }
fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr { fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
let rng = match substr.nonself_args { let rng = match substr.nonself_args {
[rng] => ~[ rng ], [rng] => ~[ rng ],
_ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`") _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`")
@ -128,7 +128,7 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
_ => cx.bug("Non-static method in `deriving(Rand)`") _ => cx.bug("Non-static method in `deriving(Rand)`")
}; };
fn rand_thing(cx: @ExtCtxt, span: span, fn rand_thing(cx: @ExtCtxt, span: Span,
ctor_ident: ident, ctor_ident: ident,
summary: &Either<uint, ~[ident]>, summary: &Either<uint, ~[ident]>,
rand_call: &fn() -> @expr) -> @expr { rand_call: &fn() -> @expr) -> @expr {

View File

@ -10,13 +10,13 @@
use ast; use ast;
use ast::{MetaItem, item, expr}; use ast::{MetaItem, item, expr};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_to_str(cx: @ExtCtxt, pub fn expand_deriving_to_str(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) in_items: ~[@item])
-> ~[@item] { -> ~[@item] {
@ -43,7 +43,7 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt,
// std::sys::log_str, but this isn't sufficient because it doesn't invoke the // std::sys::log_str, but this isn't sufficient because it doesn't invoke the
// to_str() method on each field. Hence we mirror the logic of the log_str() // to_str() method on each field. Hence we mirror the logic of the log_str()
// method, but with tweaks to call to_str() on sub-fields. // method, but with tweaks to call to_str() on sub-fields.
fn to_str_substructure(cx: @ExtCtxt, span: span, fn to_str_substructure(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let to_str = cx.ident_of("to_str"); let to_str = cx.ident_of("to_str");

View File

@ -17,7 +17,7 @@ use ast;
use ast::{expr,Generics,ident}; use ast::{expr,Generics,ident};
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use codemap::{span,respan}; use codemap::{Span,respan};
use opt_vec; use opt_vec;
/// The types of pointers /// The types of pointers
@ -58,7 +58,7 @@ impl<'self> Path<'self> {
pub fn to_ty(&self, pub fn to_ty(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
self_ty: ident, self_ty: ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Ty { -> ast::Ty {
@ -66,7 +66,7 @@ impl<'self> Path<'self> {
} }
pub fn to_path(&self, pub fn to_path(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
self_ty: ident, self_ty: ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Path { -> ast::Path {
@ -109,7 +109,7 @@ pub fn nil_ty() -> Ty<'static> {
Tuple(~[]) Tuple(~[])
} }
fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option<ast::Lifetime> { fn mk_lifetime(cx: @ExtCtxt, span: Span, lt: &Option<&str>) -> Option<ast::Lifetime> {
match *lt { match *lt {
Some(ref s) => Some(cx.lifetime(span, cx.ident_of(*s))), Some(ref s) => Some(cx.lifetime(span, cx.ident_of(*s))),
None => None None => None
@ -119,7 +119,7 @@ fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option<ast::Lifet
impl<'self> Ty<'self> { impl<'self> Ty<'self> {
pub fn to_ty(&self, pub fn to_ty(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
self_ty: ident, self_ty: ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Ty { -> ast::Ty {
@ -157,7 +157,7 @@ impl<'self> Ty<'self> {
pub fn to_path(&self, pub fn to_path(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
self_ty: ident, self_ty: ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Path { -> ast::Path {
@ -185,7 +185,7 @@ impl<'self> Ty<'self> {
} }
fn mk_ty_param(cx: @ExtCtxt, span: span, name: &str, bounds: &[Path], fn mk_ty_param(cx: @ExtCtxt, span: Span, name: &str, bounds: &[Path],
self_ident: ident, self_generics: &Generics) -> ast::TyParam { self_ident: ident, self_generics: &Generics) -> ast::TyParam {
let bounds = opt_vec::from( let bounds = opt_vec::from(
do bounds.map |b| { do bounds.map |b| {
@ -216,7 +216,7 @@ impl<'self> LifetimeBounds<'self> {
} }
pub fn to_generics(&self, pub fn to_generics(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: span, span: Span,
self_ty: ident, self_ty: ident,
self_generics: &Generics) self_generics: &Generics)
-> Generics { -> Generics {
@ -235,7 +235,7 @@ impl<'self> LifetimeBounds<'self> {
} }
pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>) pub fn get_explicit_self(cx: @ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
-> (@expr, ast::explicit_self) { -> (@expr, ast::explicit_self) {
let self_path = cx.expr_self(span); let self_path = cx.expr_self(span);
match *self_ptr { match *self_ptr {

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use ast::{MetaItem, item, expr}; use ast::{MetaItem, item, expr};
use codemap::span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use ext::deriving::generic::*; use ext::deriving::generic::*;
@ -17,7 +17,7 @@ use ext::deriving::generic::*;
use std::vec; use std::vec;
pub fn expand_deriving_zero(cx: @ExtCtxt, pub fn expand_deriving_zero(cx: @ExtCtxt,
span: span, span: Span,
mitem: @MetaItem, mitem: @MetaItem,
in_items: ~[@item]) in_items: ~[@item])
-> ~[@item] { -> ~[@item] {
@ -55,7 +55,7 @@ pub fn expand_deriving_zero(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items) trait_def.expand(cx, span, mitem, in_items)
} }
fn zero_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr { fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
let zero_ident = ~[ let zero_ident = ~[
cx.ident_of("std"), cx.ident_of("std"),
cx.ident_of("num"), cx.ident_of("num"),

View File

@ -15,7 +15,7 @@
*/ */
use ast; use ast;
use codemap::span; use codemap::Span;
use ext::base::*; use ext::base::*;
use ext::base; use ext::base;
use ext::build::AstBuilder; use ext::build::AstBuilder;
@ -23,7 +23,7 @@ use ext::build::AstBuilder;
use std::os; use std::os;
#[cfg(stage0)] #[cfg(stage0)]
pub fn expand_option_env(ext_cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) pub fn expand_option_env(ext_cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let var = get_single_str_from_tts(ext_cx, sp, tts, "option_env!"); let var = get_single_str_from_tts(ext_cx, sp, tts, "option_env!");
@ -34,7 +34,7 @@ pub fn expand_option_env(ext_cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
MRExpr(e) MRExpr(e)
} }
#[cfg(not(stage0))] #[cfg(not(stage0))]
pub fn expand_option_env(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) pub fn expand_option_env(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let var = get_single_str_from_tts(cx, sp, tts, "option_env!"); let var = get_single_str_from_tts(cx, sp, tts, "option_env!");
@ -45,7 +45,7 @@ pub fn expand_option_env(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
MRExpr(e) MRExpr(e)
} }
pub fn expand_env(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) pub fn expand_env(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let exprs = get_exprs_from_tts(cx, sp, tts); let exprs = get_exprs_from_tts(cx, sp, tts);

View File

@ -16,7 +16,7 @@ use ast_util::{new_rename, new_mark, resolve};
use attr; use attr;
use attr::AttrMetaMethods; use attr::AttrMetaMethods;
use codemap; use codemap;
use codemap::{span, spanned, ExpnInfo, NameAndSpan}; use codemap::{Span, Spanned, spanned, ExpnInfo, NameAndSpan};
use ext::base::*; use ext::base::*;
use fold::*; use fold::*;
use opt_vec; use opt_vec;
@ -32,10 +32,10 @@ use std::vec;
pub fn expand_expr(extsbox: @mut SyntaxEnv, pub fn expand_expr(extsbox: @mut SyntaxEnv,
cx: @ExtCtxt, cx: @ExtCtxt,
e: &expr_, e: &expr_,
s: span, s: Span,
fld: @ast_fold, fld: @ast_fold,
orig: @fn(&expr_, span, @ast_fold) -> (expr_, span)) orig: @fn(&expr_, Span, @ast_fold) -> (expr_, Span))
-> (expr_, span) { -> (expr_, Span) {
match *e { match *e {
// expr_mac should really be expr_ext or something; it's the // expr_mac should really be expr_ext or something; it's the
// entry-point for all syntax extensions. // entry-point for all syntax extensions.
@ -117,7 +117,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
let lo = s.lo; let lo = s.lo;
let hi = s.hi; let hi = s.hi;
pub fn mk_expr(cx: @ExtCtxt, span: span, pub fn mk_expr(cx: @ExtCtxt, span: Span,
node: expr_) -> @ast::expr { node: expr_) -> @ast::expr {
@ast::expr { @ast::expr {
id: cx.next_id(), id: cx.next_id(),
@ -129,7 +129,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
fn mk_block(cx: @ExtCtxt, fn mk_block(cx: @ExtCtxt,
stmts: &[@ast::stmt], stmts: &[@ast::stmt],
expr: Option<@ast::expr>, expr: Option<@ast::expr>,
span: span) -> ast::Block { span: Span) -> ast::Block {
ast::Block { ast::Block {
view_items: ~[], view_items: ~[],
stmts: stmts.to_owned(), stmts: stmts.to_owned(),
@ -140,7 +140,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
} }
} }
fn mk_simple_path(ident: ast::ident, span: span) -> ast::Path { fn mk_simple_path(ident: ast::ident, span: Span) -> ast::Path {
ast::Path { ast::Path {
span: span, span: span,
global: false, global: false,
@ -367,7 +367,7 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
fld: @ast_fold) fld: @ast_fold)
-> Option<@ast::item> { -> Option<@ast::item> {
let (pth, tts) = match it.node { let (pth, tts) = match it.node {
item_mac(codemap::spanned { node: mac_invoc_tt(ref pth, ref tts), _}) => { item_mac(codemap::Spanned { node: mac_invoc_tt(ref pth, ref tts), _}) => {
(pth, (*tts).clone()) (pth, (*tts).clone())
} }
_ => cx.span_bug(it.span, "invalid item macro invocation") _ => cx.span_bug(it.span, "invalid item macro invocation")
@ -449,11 +449,11 @@ fn insert_macro(exts: SyntaxEnv, name: ast::Name, transformer: @Transformer) {
pub fn expand_stmt(extsbox: @mut SyntaxEnv, pub fn expand_stmt(extsbox: @mut SyntaxEnv,
cx: @ExtCtxt, cx: @ExtCtxt,
s: &stmt_, s: &stmt_,
sp: span, sp: Span,
fld: @ast_fold, fld: @ast_fold,
orig: @fn(&stmt_, span, @ast_fold) orig: @fn(&stmt_, Span, @ast_fold)
-> (Option<stmt_>, span)) -> (Option<stmt_>, Span))
-> (Option<stmt_>, span) { -> (Option<stmt_>, Span) {
let (mac, pth, tts, semi) = match *s { let (mac, pth, tts, semi) = match *s {
stmt_mac(ref mac, semi) => { stmt_mac(ref mac, semi) => {
match mac.node { match mac.node {
@ -484,7 +484,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
}); });
let expanded = match exp(cx, mac.span, tts) { let expanded = match exp(cx, mac.span, tts) {
MRExpr(e) => MRExpr(e) =>
@codemap::spanned { node: stmt_expr(e, cx.next_id()), @codemap::Spanned { node: stmt_expr(e, cx.next_id()),
span: e.span}, span: e.span},
MRAny(_,_,stmt_mkr) => stmt_mkr(), MRAny(_,_,stmt_mkr) => stmt_mkr(),
_ => cx.span_fatal( _ => cx.span_fatal(
@ -563,7 +563,7 @@ impl Visitor<()> for NewNameFinderContext {
// XXX: Methods below can become default methods. // XXX: Methods below can become default methods.
fn visit_mod(&mut self, module: &ast::_mod, _: span, _: NodeId, _: ()) { fn visit_mod(&mut self, module: &ast::_mod, _: Span, _: NodeId, _: ()) {
visit::walk_mod(self, module, ()) visit::walk_mod(self, module, ())
} }
@ -621,7 +621,7 @@ impl Visitor<()> for NewNameFinderContext {
function_kind: &visit::fn_kind, function_kind: &visit::fn_kind,
function_declaration: &ast::fn_decl, function_declaration: &ast::fn_decl,
block: &ast::Block, block: &ast::Block,
span: span, span: Span,
node_id: NodeId, node_id: NodeId,
_: ()) { _: ()) {
visit::walk_fn(self, visit::walk_fn(self,
@ -723,9 +723,9 @@ fn apply_pending_renames(folder : @ast_fold, stmt : ast::stmt) -> @ast::stmt {
pub fn new_span(cx: @ExtCtxt, sp: span) -> span { pub fn new_span(cx: @ExtCtxt, sp: Span) -> Span {
/* this discards information in the case of macro-defining macros */ /* this discards information in the case of macro-defining macros */
return span {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()}; return Span {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()};
} }
// FIXME (#2247): this is a moderately bad kludge to inject some macros into // FIXME (#2247): this is a moderately bad kludge to inject some macros into
@ -1193,7 +1193,7 @@ mod test {
use ast; use ast;
use ast::{Attribute_, AttrOuter, MetaWord, empty_ctxt}; use ast::{Attribute_, AttrOuter, MetaWord, empty_ctxt};
use codemap; use codemap;
use codemap::spanned; use codemap::Spanned;
use parse; use parse;
use parse::token::{intern, get_ident_interner}; use parse::token::{intern, get_ident_interner};
use print::pprust; use print::pprust;
@ -1282,11 +1282,11 @@ mod test {
// make a MetaWord outer attribute with the given name // make a MetaWord outer attribute with the given name
fn make_dummy_attr(s: @str) -> ast::Attribute { fn make_dummy_attr(s: @str) -> ast::Attribute {
spanned { Spanned {
span:codemap::dummy_sp(), span:codemap::dummy_sp(),
node: Attribute_ { node: Attribute_ {
style: AttrOuter, style: AttrOuter,
value: @spanned { value: @Spanned {
node: MetaWord(s), node: MetaWord(s),
span: codemap::dummy_sp(), span: codemap::dummy_sp(),
}, },

View File

@ -15,7 +15,7 @@
*/ */
use ast; use ast;
use codemap::span; use codemap::Span;
use ext::base::*; use ext::base::*;
use ext::base; use ext::base;
use ext::build::AstBuilder; use ext::build::AstBuilder;
@ -24,7 +24,7 @@ use std::option;
use std::unstable::extfmt::ct::*; use std::unstable::extfmt::ct::*;
use parse::token::{str_to_ident}; use parse::token::{str_to_ident};
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let args = get_exprs_from_tts(cx, sp, tts); let args = get_exprs_from_tts(cx, sp, tts);
if args.len() == 0 { if args.len() == 0 {
@ -35,7 +35,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
"first argument to fmt! must be a string literal."); "first argument to fmt! must be a string literal.");
let fmtspan = args[0].span; let fmtspan = args[0].span;
debug!("Format string: %s", fmt); debug!("Format string: %s", fmt);
fn parse_fmt_err_(cx: @ExtCtxt, sp: span, msg: &str) -> ! { fn parse_fmt_err_(cx: @ExtCtxt, sp: Span, msg: &str) -> ! {
cx.span_fatal(sp, msg); cx.span_fatal(sp, msg);
} }
let parse_fmt_err: @fn(&str) -> ! = |s| parse_fmt_err_(cx, fmtspan, s); let parse_fmt_err: @fn(&str) -> ! = |s| parse_fmt_err_(cx, fmtspan, s);
@ -47,7 +47,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
// probably be factored out in common with other code that builds // probably be factored out in common with other code that builds
// expressions. Also: Cleanup the naming of these functions. // expressions. Also: Cleanup the naming of these functions.
// Note: Moved many of the common ones to build.rs --kevina // Note: Moved many of the common ones to build.rs --kevina
fn pieces_to_expr(cx: @ExtCtxt, sp: span, fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
pieces: ~[Piece], args: ~[@ast::expr]) pieces: ~[Piece], args: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
fn make_path_vec(ident: &str) -> ~[ast::ident] { fn make_path_vec(ident: &str) -> ~[ast::ident] {
@ -57,15 +57,15 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
str_to_ident("rt"), str_to_ident("rt"),
str_to_ident(ident)]; str_to_ident(ident)];
} }
fn make_rt_path_expr(cx: @ExtCtxt, sp: span, nm: &str) -> @ast::expr { fn make_rt_path_expr(cx: @ExtCtxt, sp: Span, nm: &str) -> @ast::expr {
let path = make_path_vec(nm); let path = make_path_vec(nm);
cx.expr_path(cx.path_global(sp, path)) cx.expr_path(cx.path_global(sp, path))
} }
// Produces an AST expression that represents a RT::conv record, // Produces an AST expression that represents a RT::conv record,
// which tells the RT::conv* functions how to perform the conversion // which tells the RT::conv* functions how to perform the conversion
fn make_rt_conv_expr(cx: @ExtCtxt, sp: span, cnv: &Conv) -> @ast::expr { fn make_rt_conv_expr(cx: @ExtCtxt, sp: Span, cnv: &Conv) -> @ast::expr {
fn make_flags(cx: @ExtCtxt, sp: span, flags: &[Flag]) -> @ast::expr { fn make_flags(cx: @ExtCtxt, sp: Span, flags: &[Flag]) -> @ast::expr {
let mut tmp_expr = make_rt_path_expr(cx, sp, "flag_none"); let mut tmp_expr = make_rt_path_expr(cx, sp, "flag_none");
for f in flags.iter() { for f in flags.iter() {
let fstr = match *f { let fstr = match *f {
@ -80,7 +80,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
} }
return tmp_expr; return tmp_expr;
} }
fn make_count(cx: @ExtCtxt, sp: span, cnt: Count) -> @ast::expr { fn make_count(cx: @ExtCtxt, sp: Span, cnt: Count) -> @ast::expr {
match cnt { match cnt {
CountImplied => { CountImplied => {
return make_rt_path_expr(cx, sp, "CountImplied"); return make_rt_path_expr(cx, sp, "CountImplied");
@ -94,7 +94,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
_ => cx.span_unimpl(sp, "unimplemented fmt! conversion") _ => cx.span_unimpl(sp, "unimplemented fmt! conversion")
} }
} }
fn make_ty(cx: @ExtCtxt, sp: span, t: Ty) -> @ast::expr { fn make_ty(cx: @ExtCtxt, sp: Span, t: Ty) -> @ast::expr {
let rt_type = match t { let rt_type = match t {
TyHex(c) => match c { TyHex(c) => match c {
CaseUpper => "TyHexUpper", CaseUpper => "TyHexUpper",
@ -106,7 +106,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
}; };
return make_rt_path_expr(cx, sp, rt_type); return make_rt_path_expr(cx, sp, rt_type);
} }
fn make_conv_struct(cx: @ExtCtxt, sp: span, flags_expr: @ast::expr, fn make_conv_struct(cx: @ExtCtxt, sp: Span, flags_expr: @ast::expr,
width_expr: @ast::expr, precision_expr: @ast::expr, width_expr: @ast::expr, precision_expr: @ast::expr,
ty_expr: @ast::expr) -> @ast::expr { ty_expr: @ast::expr) -> @ast::expr {
cx.expr_struct( cx.expr_struct(
@ -127,7 +127,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
make_conv_struct(cx, sp, rt_conv_flags, rt_conv_width, make_conv_struct(cx, sp, rt_conv_flags, rt_conv_width,
rt_conv_precision, rt_conv_ty) rt_conv_precision, rt_conv_ty)
} }
fn make_conv_call(cx: @ExtCtxt, sp: span, conv_type: &str, cnv: &Conv, fn make_conv_call(cx: @ExtCtxt, sp: Span, conv_type: &str, cnv: &Conv,
arg: @ast::expr, buf: @ast::expr) -> @ast::expr { arg: @ast::expr, buf: @ast::expr) -> @ast::expr {
let fname = ~"conv_" + conv_type; let fname = ~"conv_" + conv_type;
let path = make_path_vec(fname); let path = make_path_vec(fname);
@ -136,7 +136,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
cx.expr_call_global(arg.span, path, args) cx.expr_call_global(arg.span, path, args)
} }
fn make_new_conv(cx: @ExtCtxt, sp: span, cnv: &Conv, fn make_new_conv(cx: @ExtCtxt, sp: Span, cnv: &Conv,
arg: @ast::expr, buf: @ast::expr) -> @ast::expr { arg: @ast::expr, buf: @ast::expr) -> @ast::expr {
fn is_signed_type(cnv: &Conv) -> bool { fn is_signed_type(cnv: &Conv) -> bool {
match cnv.ty { match cnv.ty {

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use ast; use ast;
use codemap::{span, respan}; use codemap::{Span, respan};
use ext::base::*; use ext::base::*;
use ext::base; use ext::base;
use ext::build::AstBuilder; use ext::build::AstBuilder;
@ -30,7 +30,7 @@ enum ArgumentType {
struct Context { struct Context {
ecx: @ExtCtxt, ecx: @ExtCtxt,
fmtsp: span, fmtsp: Span,
// Parsed argument expressions and the types that we've found so far for // Parsed argument expressions and the types that we've found so far for
// them. // them.
@ -53,7 +53,7 @@ struct Context {
impl Context { impl Context {
/// Parses the arguments from the given list of tokens, returning None if /// Parses the arguments from the given list of tokens, returning None if
/// there's a parse error so we can continue parsing other fmt! expressions. /// there's a parse error so we can continue parsing other fmt! expressions.
fn parse_args(&mut self, sp: span, fn parse_args(&mut self, sp: Span,
leading_expr: bool, leading_expr: bool,
tts: &[ast::token_tree]) -> (Option<@ast::expr>, tts: &[ast::token_tree]) -> (Option<@ast::expr>,
Option<@ast::expr>) { Option<@ast::expr>) {
@ -294,7 +294,7 @@ impl Context {
/// ///
/// Obviously `Some(Some(x)) != Some(Some(y))`, but we consider it true /// Obviously `Some(Some(x)) != Some(Some(y))`, but we consider it true
/// that: `Some(None) == Some(Some(x))` /// that: `Some(None) == Some(Some(x))`
fn verify_same(&self, sp: span, ty: ArgumentType, fn verify_same(&self, sp: Span, ty: ArgumentType,
before: Option<ArgumentType>) { before: Option<ArgumentType>) {
if ty == Unknown { return } if ty == Unknown { return }
let cur = match before { let cur = match before {
@ -636,7 +636,7 @@ impl Context {
self.ecx.expr_block(self.ecx.block(self.fmtsp, lets, Some(result))) self.ecx.expr_block(self.ecx.block(self.fmtsp, lets, Some(result)))
} }
fn format_arg(&self, sp: span, arg: Either<uint, @str>, fn format_arg(&self, sp: Span, arg: Either<uint, @str>,
ident: ast::ident) -> @ast::expr { ident: ast::ident) -> @ast::expr {
let ty = match arg { let ty = match arg {
Left(i) => self.arg_types[i].unwrap(), Left(i) => self.arg_types[i].unwrap(),
@ -697,22 +697,22 @@ impl Context {
} }
} }
pub fn expand_format(ecx: @ExtCtxt, sp: span, pub fn expand_format(ecx: @ExtCtxt, sp: Span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
expand_ifmt(ecx, sp, tts, false, false, "format") expand_ifmt(ecx, sp, tts, false, false, "format")
} }
pub fn expand_write(ecx: @ExtCtxt, sp: span, pub fn expand_write(ecx: @ExtCtxt, sp: Span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
expand_ifmt(ecx, sp, tts, true, false, "write") expand_ifmt(ecx, sp, tts, true, false, "write")
} }
pub fn expand_writeln(ecx: @ExtCtxt, sp: span, pub fn expand_writeln(ecx: @ExtCtxt, sp: Span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
expand_ifmt(ecx, sp, tts, true, true, "write") expand_ifmt(ecx, sp, tts, true, true, "write")
} }
fn expand_ifmt(ecx: @ExtCtxt, sp: span, tts: &[ast::token_tree], fn expand_ifmt(ecx: @ExtCtxt, sp: Span, tts: &[ast::token_tree],
leading_arg: bool, append_newline: bool, leading_arg: bool, append_newline: bool,
function: &str) -> base::MacResult { function: &str) -> base::MacResult {
let mut cx = Context { let mut cx = Context {

View File

@ -18,7 +18,7 @@ use parse::token::{get_ident_interner};
use std::io; use std::io;
pub fn expand_syntax_ext(cx: @ExtCtxt, pub fn expand_syntax_ext(cx: @ExtCtxt,
sp: codemap::span, sp: codemap::Span,
tt: &[ast::token_tree]) tt: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
@ -31,7 +31,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt,
//trivial expression //trivial expression
MRExpr(@ast::expr { MRExpr(@ast::expr {
id: cx.next_id(), id: cx.next_id(),
node: ast::expr_lit(@codemap::spanned { node: ast::expr_lit(@codemap::Spanned {
node: ast::lit_nil, node: ast::lit_nil,
span: sp span: sp
}), }),

Some files were not shown because too many files have changed in this diff Show More