//! module encapsulates the platform-specific rules for dealing
//! with file paths.
//!
-//! `std` also includes modules for interoperating with the
-//! C language: [`c_str`](c_str/index.html) and
-//! [`c_vec`](c_vec/index.html).
+//! `std` also includes the [`ffi`](ffi/index.html) module for interoperating
+//! with the C language.
//!
//! ## Concurrency, I/O, and the runtime
//!
#![feature(lang_items)]
#![feature(libc)]
#![feature(linkage, thread_local, asm)]
- #![feature(old_impl_check)]
#![feature(optin_builtin_traits)]
#![feature(rand)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(unsafe_destructor)]
-#![feature(unsafe_no_drop_flag)]
+#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(macro_reexport)]
-#![feature(int_uint)]
#![feature(unique)]
#![feature(convert)]
#![feature(allow_internal_unstable)]
#![no_std]
#![allow(trivial_casts)]
-#![allow(trivial_numeric_casts)]
#![deny(missing_docs)]
#[cfg(test)] extern crate test;
#[macro_use]
#[macro_reexport(vec, format)]
-extern crate "collections" as core_collections;
+extern crate collections as core_collections;
-#[allow(deprecated)] extern crate "rand" as core_rand;
+#[allow(deprecated)] extern crate rand as core_rand;
extern crate alloc;
extern crate unicode;
extern crate libc;
#[macro_use] #[no_link] extern crate rustc_bitflags;
// Make std testable by not duplicating lang items. See #2912
-#[cfg(test)] extern crate "std" as realstd;
+#[cfg(test)] extern crate std as realstd;
#[cfg(test)] pub use realstd::marker;
#[cfg(test)] pub use realstd::ops;
#[cfg(test)] pub use realstd::cmp;
/// The default buffer size for various I/O operations
// libuv recommends 64k buffers to maximize throughput
// https://groups.google.com/forum/#!topic/libuv/oQO1HJAIDdA
-const DEFAULT_BUF_SIZE: uint = 1024 * 64;
+const DEFAULT_BUF_SIZE: usize = 1024 * 64;
/// A convenient typedef of the return value of any I/O action.
pub type IoResult<T> = Result<T, IoError>;
///
/// The payload contained as part of this variant is the number of bytes
/// which are known to have been successfully written.
- ShortWrite(uint),
+ ShortWrite(usize),
/// The Reader returned 0 bytes from `read()` too many times.
NoProgress,
}
}
}
-static NO_PROGRESS_LIMIT: uint = 1000;
+static NO_PROGRESS_LIMIT: usize = 1000;
/// A trait for objects which are byte-oriented streams. Readers are defined by
/// one method, `read`. This function will block until data is available,
///
/// When implementing this method on a new Reader, you are strongly encouraged
/// not to return 0 if you can avoid it.
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>;
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize>;
// Convenient helper methods based on the above methods
///
/// If an error occurs at any point, that error is returned, and no further
/// bytes are read.
- fn read_at_least(&mut self, min: uint, buf: &mut [u8]) -> IoResult<uint> {
+ fn read_at_least(&mut self, min: usize, buf: &mut [u8]) -> IoResult<usize> {
if min > buf.len() {
return Err(IoError {
detail: Some(String::from_str("the buffer is too short")),
///
/// If an error occurs during this I/O operation, then it is returned
/// as `Err(IoError)`. See `read()` for more details.
- fn push(&mut self, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> {
+ fn push(&mut self, len: usize, buf: &mut Vec<u8>) -> IoResult<usize> {
let start_len = buf.len();
buf.reserve(len);
///
/// If an error occurs at any point, that error is returned, and no further
/// bytes are read.
- fn push_at_least(&mut self, min: uint, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> {
+ fn push_at_least(&mut self, min: usize, len: usize, buf: &mut Vec<u8>) -> IoResult<usize> {
if min > len {
return Err(IoError {
detail: Some(String::from_str("the buffer is too short")),
/// have already been consumed from the underlying reader, and they are lost
/// (not returned as part of the error). If this is unacceptable, then it is
/// recommended to use the `push_at_least` or `read` methods.
- fn read_exact(&mut self, len: uint) -> IoResult<Vec<u8>> {
+ fn read_exact(&mut self, len: usize) -> IoResult<Vec<u8>> {
let mut buf = Vec::with_capacity(len);
match self.push_at_least(len, len, &mut buf) {
Ok(_) => Ok(buf),
/// Reads `n` little-endian unsigned integer bytes.
///
/// `n` must be between 1 and 8, inclusive.
- fn read_le_uint_n(&mut self, nbytes: uint) -> IoResult<u64> {
+ fn read_le_uint_n(&mut self, nbytes: usize) -> IoResult<u64> {
assert!(nbytes > 0 && nbytes <= 8);
let mut val = 0;
/// Reads `n` little-endian signed integer bytes.
///
/// `n` must be between 1 and 8, inclusive.
- fn read_le_int_n(&mut self, nbytes: uint) -> IoResult<i64> {
+ fn read_le_int_n(&mut self, nbytes: usize) -> IoResult<i64> {
self.read_le_uint_n(nbytes).map(|i| extend_sign(i, nbytes))
}
/// Reads `n` big-endian unsigned integer bytes.
///
/// `n` must be between 1 and 8, inclusive.
- fn read_be_uint_n(&mut self, nbytes: uint) -> IoResult<u64> {
+ fn read_be_uint_n(&mut self, nbytes: usize) -> IoResult<u64> {
assert!(nbytes > 0 && nbytes <= 8);
let mut val = 0;
/// Reads `n` big-endian signed integer bytes.
///
/// `n` must be between 1 and 8, inclusive.
- fn read_be_int_n(&mut self, nbytes: uint) -> IoResult<i64> {
+ fn read_be_int_n(&mut self, nbytes: usize) -> IoResult<i64> {
self.read_be_uint_n(nbytes).map(|i| extend_sign(i, nbytes))
}
/// Reads a little-endian unsigned integer.
///
/// The number of bytes returned is system-dependent.
- fn read_le_uint(&mut self) -> IoResult<uint> {
- self.read_le_uint_n(usize::BYTES as usize).map(|i| i as uint)
+ fn read_le_uint(&mut self) -> IoResult<usize> {
+ self.read_le_uint_n(usize::BYTES as usize).map(|i| i as usize)
}
/// Reads a little-endian integer.
///
/// The number of bytes returned is system-dependent.
- fn read_le_int(&mut self) -> IoResult<int> {
- self.read_le_int_n(isize::BYTES as usize).map(|i| i as int)
+ fn read_le_int(&mut self) -> IoResult<isize> {
+ self.read_le_int_n(isize::BYTES as usize).map(|i| i as isize)
}
/// Reads a big-endian unsigned integer.
///
/// The number of bytes returned is system-dependent.
- fn read_be_uint(&mut self) -> IoResult<uint> {
- self.read_be_uint_n(usize::BYTES as usize).map(|i| i as uint)
+ fn read_be_uint(&mut self) -> IoResult<usize> {
+ self.read_be_uint_n(usize::BYTES as usize).map(|i| i as usize)
}
/// Reads a big-endian integer.
///
/// The number of bytes returned is system-dependent.
- fn read_be_int(&mut self) -> IoResult<int> {
- self.read_be_int_n(isize::BYTES as usize).map(|i| i as int)
+ fn read_be_int(&mut self) -> IoResult<isize> {
+ self.read_be_int_n(isize::BYTES as usize).map(|i| i as isize)
}
/// Reads a big-endian `u64`.
}
impl<'a> Reader for Box<Reader+'a> {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
let reader: &mut Reader = &mut **self;
reader.read(buf)
}
}
impl<'a> Reader for &'a mut (Reader+'a) {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { (*self).read(buf) }
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { (*self).read(buf) }
}
/// Returns a slice of `v` between `start` and `end`.
/// `start` > `end`.
// Private function here because we aren't sure if we want to expose this as
// API yet. If so, it should be a method on Vec.
-unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -> &'a mut [T] {
+unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: usize, end: usize) -> &'a mut [T] {
use slice;
assert!(start <= end);
assert!(end <= v.capacity());
slice::from_raw_parts_mut(
- v.as_mut_ptr().offset(start as int),
+ v.as_mut_ptr().offset(start as isize),
end - start
)
}
}
impl<'a, R: Reader> Reader for RefReader<'a, R> {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.inner.read(buf) }
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.inner.read(buf) }
}
impl<'a, R: Buffer> Buffer for RefReader<'a, R> {
fn fill_buf(&mut self) -> IoResult<&[u8]> { self.inner.fill_buf() }
- fn consume(&mut self, amt: uint) { self.inner.consume(amt) }
+ fn consume(&mut self, amt: usize) { self.inner.consume(amt) }
}
-fn extend_sign(val: u64, nbytes: uint) -> i64 {
+fn extend_sign(val: u64, nbytes: usize) -> i64 {
let shift = (8 - nbytes) * 8;
(val << shift) as i64 >> shift
}
self.write_all(&buf[..n])
}
- /// Write the result of passing n through `int::to_str_bytes`.
+ /// Write the result of passing n through `isize::to_str_bytes`.
#[inline]
- fn write_int(&mut self, n: int) -> IoResult<()> {
+ fn write_int(&mut self, n: isize) -> IoResult<()> {
write!(self, "{}", n)
}
- /// Write the result of passing n through `uint::to_str_bytes`.
+ /// Write the result of passing n through `usize::to_str_bytes`.
#[inline]
- fn write_uint(&mut self, n: uint) -> IoResult<()> {
+ fn write_uint(&mut self, n: usize) -> IoResult<()> {
write!(self, "{}", n)
}
- /// Write a little-endian uint (number of bytes depends on system).
+ /// Write a little-endian usize (number of bytes depends on system).
#[inline]
- fn write_le_uint(&mut self, n: uint) -> IoResult<()> {
+ fn write_le_uint(&mut self, n: usize) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, usize::BYTES as usize, |v| self.write_all(v))
}
- /// Write a little-endian int (number of bytes depends on system).
+ /// Write a little-endian isize (number of bytes depends on system).
#[inline]
- fn write_le_int(&mut self, n: int) -> IoResult<()> {
+ fn write_le_int(&mut self, n: isize) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, isize::BYTES as usize, |v| self.write_all(v))
}
- /// Write a big-endian uint (number of bytes depends on system).
+ /// Write a big-endian usize (number of bytes depends on system).
#[inline]
- fn write_be_uint(&mut self, n: uint) -> IoResult<()> {
+ fn write_be_uint(&mut self, n: usize) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, usize::BYTES as usize, |v| self.write_all(v))
}
- /// Write a big-endian int (number of bytes depends on system).
+ /// Write a big-endian isize (number of bytes depends on system).
#[inline]
- fn write_be_int(&mut self, n: int) -> IoResult<()> {
+ fn write_be_int(&mut self, n: isize) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, isize::BYTES as usize, |v| self.write_all(v))
}
/// Tells this buffer that `amt` bytes have been consumed from the buffer,
/// so they should no longer be returned in calls to `read`.
- fn consume(&mut self, amt: uint);
+ fn consume(&mut self, amt: usize);
/// Reads the next line of input, interpreted as a sequence of UTF-8
/// encoded Unicode codepoints. If a newline is encountered, then the
/// connections.
///
/// Doing so produces some sort of Acceptor.
- pub trait Listener<T, A: Acceptor<T>>
- : PhantomFn<T,T> // FIXME should be an assoc type anyhow
- {
+ pub trait Listener<A: Acceptor> {
/// Spin up the listener and start queuing incoming connections
///
/// # Error
}
/// An acceptor is a value that presents incoming connections
- pub trait Acceptor<T> {
+ pub trait Acceptor {
+ /// Type of connection that is accepted by this acceptor.
+ type Connection;
+
/// Wait for and accept an incoming connection
///
/// # Error
///
/// Returns `Err` if an I/O error is encountered.
- fn accept(&mut self) -> IoResult<T>;
+ fn accept(&mut self) -> IoResult<Self::Connection>;
/// Create an iterator over incoming connection attempts.
///
inc: &'a mut A,
}
- #[old_impl_check]
- impl<'a, T, A: ?Sized + Acceptor<T>> Iterator for IncomingConnections<'a, A> {
- type Item = IoResult<T>;
+ impl<'a, A: ?Sized + Acceptor> Iterator for IncomingConnections<'a, A> {
+ type Item = IoResult<A::Connection>;
- fn next(&mut self) -> Option<IoResult<T>> {
+ fn next(&mut self) -> Option<IoResult<A::Connection>> {
Some(self.inc.accept())
}
}
#[derive(Clone, PartialEq, Debug)]
enum BadReaderBehavior {
- GoodBehavior(uint),
- BadBehavior(uint)
+ GoodBehavior(usize),
+ BadBehavior(usize)
}
struct BadReader<T> {
}
impl<T: Reader> Reader for BadReader<T> {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
let BadReader { ref mut behavior, ref mut r } = *self;
loop {
if behavior.is_empty() {
}
impl Reader for UnixStream {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
self.inner.read(buf)
}
}
}
}
- impl Listener<UnixStream, UnixAcceptor> for UnixListener {
+ impl Listener<UnixAcceptor> for UnixListener {
fn listen(self) -> IoResult<UnixAcceptor> {
self.inner.listen()
.map(|inner| UnixAcceptor { inner: inner })
}
}
- impl Acceptor<UnixStream> for UnixAcceptor {
+ impl Acceptor for UnixAcceptor {
+ type Connection = UnixStream;
fn accept(&mut self) -> IoResult<UnixStream> {
self.inner.accept().map(|s| {
UnixStream { inner: s }
/// this connection. Otherwise, the keepalive timeout will be set to the
/// specified time, in seconds.
#[unstable(feature = "io")]
- pub fn set_keepalive(&mut self, delay_in_seconds: Option<uint>) -> IoResult<()> {
+ pub fn set_keepalive(&mut self, delay_in_seconds: Option<usize>) -> IoResult<()> {
self.inner.set_keepalive(delay_in_seconds)
}
}
impl Reader for TcpStream {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
self.inner.read(buf)
}
}
}
}
- impl Listener<TcpStream, TcpAcceptor> for TcpListener {
+ impl Listener<TcpAcceptor> for TcpListener {
fn listen(self) -> IoResult<TcpAcceptor> {
self.inner.listen(128).map(|a| TcpAcceptor { inner: a })
}
}
}
- impl Acceptor<TcpStream> for TcpAcceptor {
+ impl Acceptor for TcpAcceptor {
+ type Connection = TcpStream;
fn accept(&mut self) -> IoResult<TcpStream> {
self.inner.accept().map(TcpStream::new)
}
#[test]
fn multiple_connect_interleaved_greedy_schedule_ip4() {
let addr = next_test_ip4();
- static MAX: int = 10;
+ static MAX: isize = 10;
let acceptor = TcpListener::bind(addr).listen();
let _t = thread::spawn(move|| {
let mut acceptor = acceptor;
- for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) {
+ for (i, stream) in acceptor.incoming().enumerate().take(MAX as usize) {
// Start another task to handle the connection
let _t = thread::spawn(move|| {
let mut stream = stream;
connect(0, addr);
- fn connect(i: int, addr: SocketAddr) {
+ fn connect(i: isize, addr: SocketAddr) {
if i == MAX { return }
let _t = thread::spawn(move|| {
#[test]
fn multiple_connect_interleaved_greedy_schedule_ip6() {
let addr = next_test_ip6();
- static MAX: int = 10;
+ static MAX: isize = 10;
let acceptor = TcpListener::bind(addr).listen();
let _t = thread::spawn(move|| {
let mut acceptor = acceptor;
- for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) {
+ for (i, stream) in acceptor.incoming().enumerate().take(MAX as usize) {
// Start another task to handle the connection
let _t = thread::spawn(move|| {
let mut stream = stream;
connect(0, addr);
- fn connect(i: int, addr: SocketAddr) {
+ fn connect(i: isize, addr: SocketAddr) {
if i == MAX { return }
let _t = thread::spawn(move|| {
#[test]
fn multiple_connect_interleaved_lazy_schedule_ip4() {
- static MAX: int = 10;
+ static MAX: isize = 10;
let addr = next_test_ip4();
let acceptor = TcpListener::bind(addr).listen();
let _t = thread::spawn(move|| {
let mut acceptor = acceptor;
- for stream in acceptor.incoming().take(MAX as uint) {
+ for stream in acceptor.incoming().take(MAX as usize) {
// Start another task to handle the connection
let _t = thread::spawn(move|| {
let mut stream = stream;
connect(0, addr);
- fn connect(i: int, addr: SocketAddr) {
+ fn connect(i: isize, addr: SocketAddr) {
if i == MAX { return }
let _t = thread::spawn(move|| {
#[test]
fn multiple_connect_interleaved_lazy_schedule_ip6() {
- static MAX: int = 10;
+ static MAX: isize = 10;
let addr = next_test_ip6();
let acceptor = TcpListener::bind(addr).listen();
let _t = thread::spawn(move|| {
let mut acceptor = acceptor;
- for stream in acceptor.incoming().take(MAX as uint) {
+ for stream in acceptor.incoming().take(MAX as usize) {
// Start another task to handle the connection
let _t = thread::spawn(move|| {
let mut stream = stream;
connect(0, addr);
- fn connect(i: int, addr: SocketAddr) {
+ fn connect(i: isize, addr: SocketAddr) {
if i == MAX { return }
let _t = thread::spawn(move|| {
}
impl<R: Reader> Reader for IoResult<R> {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
match *self {
Ok(ref mut reader) => reader.read(buf),
Err(ref e) => Err(e.clone()),
}
}
- impl<T, A: Acceptor<T>, L: Listener<T, A>> Listener<T, A> for IoResult<L> {
+ impl<A: Acceptor, L: Listener<A>> Listener<A> for IoResult<L> {
fn listen(self) -> IoResult<A> {
match self {
Ok(listener) => listener.listen(),
}
}
- impl<T, A: Acceptor<T>> Acceptor<T> for IoResult<A> {
- fn accept(&mut self) -> IoResult<T> {
+ impl<A: Acceptor> Acceptor for IoResult<A> {
+ type Connection = A::Connection;
+ fn accept(&mut self) -> IoResult<A::Connection> {
match *self {
Ok(ref mut acceptor) => acceptor.accept(),
Err(ref e) => Err(e.clone()),
("non_ascii_idents", "1.0.0", Active),
("thread_local", "1.0.0", Active),
("link_args", "1.0.0", Active),
- ("phase", "1.0.0", Removed),
("plugin_registrar", "1.0.0", Active),
("log_syntax", "1.0.0", Active),
("trace_macros", "1.0.0", Active),
("rustc_diagnostic_macros", "1.0.0", Active),
("unboxed_closures", "1.0.0", Active),
+ ("reflect", "1.0.0", Active),
("import_shadowing", "1.0.0", Removed),
("advanced_slice_patterns", "1.0.0", Active),
("tuple_indexing", "1.0.0", Accepted),
// A way to temporarily opt out of the new orphan rules. This will *never* be accepted.
("old_orphan_check", "1.0.0", Deprecated),
- // A way to temporarily opt out of the new impl rules. This will *never* be accepted.
- ("old_impl_check", "1.0.0", Deprecated),
-
// OIBIT specific features
("optin_builtin_traits", "1.0.0", Active),
- // int and uint are now deprecated
- ("int_uint", "1.0.0", Active),
-
// macro reexport needs more discussion and stabilization
("macro_reexport", "1.0.0", Active),
("no_mangle", Normal),
("no_link", Normal),
("derive", Normal),
- ("should_fail", Normal),
("should_panic", Normal),
("ignore", Normal),
("no_implicit_prelude", Normal),
// FIXME: #19470 this shouldn't be needed forever
("old_orphan_check", Whitelisted),
- ("old_impl_check", Whitelisted),
- ("rustc_paren_sugar", Whitelisted), // FIXME: #18101 temporary unboxed closure hack
+
+ ("rustc_paren_sugar", Gated("unboxed_closures",
+ "unboxed_closures are still evolving")),
+ ("rustc_reflect_like", Gated("reflect",
+ "defining reflective traits is still evolving")),
// Crate level attributes
("crate_name", CrateLevel),
features: Vec<&'static str>,
span_handler: &'a SpanHandler,
cm: &'a CodeMap,
- do_warnings: bool,
}
impl<'a> Context<'a> {
emit_feature_err(self.span_handler, feature, span, explain);
}
}
-
- fn warn_feature(&self, feature: &str, span: Span, explain: &str) {
- if !self.has_feature(feature) && self.do_warnings {
- emit_feature_warn(self.span_handler, feature, span, explain);
- }
- }
fn has_feature(&self, feature: &str) -> bool {
self.features.iter().any(|&n| n == feature)
}
i.span,
"the new orphan check rules will eventually be strictly enforced");
}
-
- if attr::contains_name(&i.attrs[..],
- "old_impl_check") {
- self.gate_feature("old_impl_check",
- i.span,
- "`#[old_impl_check]` will be removed in the future");
- }
}
_ => {}
visit::walk_foreign_item(self, i)
}
- fn visit_ty(&mut self, t: &ast::Ty) {
- match t.node {
- ast::TyPath(None, ref p) => {
- match &*p.segments {
-
- [ast::PathSegment { identifier, .. }] => {
- let name = token::get_ident(identifier);
- let msg = if name == "int" {
- Some("the `int` type is deprecated; \
- use `isize` or a fixed-sized integer")
- } else if name == "uint" {
- Some("the `uint` type is deprecated; \
- use `usize` or a fixed-sized integer")
- } else {
- None
- };
-
- if let Some(msg) = msg {
- self.context.warn_feature("int_uint", t.span, msg)
- }
- }
- _ => {}
- }
- }
- _ => {}
- }
- visit::walk_ty(self, t);
- }
-
fn visit_expr(&mut self, e: &ast::Expr) {
match e.node {
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
"box expression syntax is experimental; \
you can call `Box::new` instead.");
}
- ast::ExprLit(ref lit) => {
- match lit.node {
- ast::LitInt(_, ty) => {
- let msg = if let ast::SignedIntLit(ast::TyIs(true), _) = ty {
- Some("the `i` and `is` suffixes on integers are deprecated; \
- use `isize` or one of the fixed-sized suffixes")
- } else if let ast::UnsignedIntLit(ast::TyUs(true)) = ty {
- Some("the `u` and `us` suffixes on integers are deprecated; \
- use `usize` or one of the fixed-sized suffixes")
- } else {
- None
- };
- if let Some(msg) = msg {
- self.context.warn_feature("int_uint", e.span, msg);
- }
- }
- _ => {}
- }
- }
_ => {}
}
visit::walk_expr(self, e);
}
}
-fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate,
- do_warnings: bool,
+fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler,
+ krate: &ast::Crate,
check: F)
-> Features
where F: FnOnce(&mut Context, &ast::Crate)
let mut cx = Context {
features: Vec::new(),
span_handler: span_handler,
- do_warnings: do_warnings,
cm: cm,
};
pub fn check_crate_macros(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate)
-> Features {
- check_crate_inner(cm, span_handler, krate, true,
+ check_crate_inner(cm, span_handler, krate,
|ctx, krate| visit::walk_crate(&mut MacroVisitor { context: ctx }, krate))
}
-pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate,
- do_warnings: bool) -> Features
+pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate)
+ -> Features
{
- check_crate_inner(cm, span_handler, krate, do_warnings,
+ check_crate_inner(cm, span_handler, krate,
|ctx, krate| visit::walk_crate(&mut PostExpansionVisitor { context: ctx },
krate))
}