Fixes #31122.
*.elc
*.epub
*.exe
+*.pdb
*.fn
*.html
*.kdev4
1. Make sure you have installed the dependencies:
* `g++` 4.7 or `clang++` 3.x
- * `python` 2.7 or later (but not 3.x)
+ * `python` 2.7 (but not 3.x)
* GNU `make` 3.81 or later
* `curl`
* `git`
probe_need CFG_CURLORWGET curl wget
if [ -z "$CFG_PYTHON_PROVIDED" ]; then
- probe_need CFG_PYTHON python2.7 python2.6 python2 python
+ probe_need CFG_PYTHON python2.7 python2 python
fi
python_version=$($CFG_PYTHON -V 2>&1)
-if [ $(echo $python_version | grep -c '^Python 2\.[4567]') -ne 1 ]; then
- err "Found $python_version, but LLVM requires Python 2.4-2.7"
+if [ $(echo $python_version | grep -c '^Python 2\.7') -ne 1 ]; then
+ err "Found $python_version, but Python 2.7 is required"
fi
# If we have no git directory then we are probably a tarball distribution
--- /dev/null
+# i586-unknown-linux-gnu configuration
+CC_i586-unknown-linux-gnu=$(CC)
+CXX_i586-unknown-linux-gnu=$(CXX)
+CPP_i586-unknown-linux-gnu=$(CPP)
+AR_i586-unknown-linux-gnu=$(AR)
+CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so
+CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a
+CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so
+CFG_LIB_DSYM_GLOB_i586-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
+CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS)
+CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFLAGS)
+CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
+CFG_GCCISH_LINK_FLAGS_i586-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32
+CFG_GCCISH_DEF_FLAG_i586-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
+CFG_LLC_FLAGS_i586-unknown-linux-gnu :=
+CFG_INSTALL_NAME_i586-unknown-linux-gnu =
+CFG_EXE_SUFFIX_i586-unknown-linux-gnu =
+CFG_WINDOWSY_i586-unknown-linux-gnu :=
+CFG_UNIXY_i586-unknown-linux-gnu := 1
+CFG_LDPATH_i586-unknown-linux-gnu :=
+CFG_RUN_i586-unknown-linux-gnu=$(2)
+CFG_RUN_TARG_i586-unknown-linux-gnu=$(call CFG_RUN_i586-unknown-linux-gnu,,$(2))
+CFG_GNU_TRIPLE_i586-unknown-linux-gnu := i586-unknown-linux-gnu
rustc_data_structures rustc_front rustc_platform_intrinsics \
rustc_plugin rustc_metadata rustc_passes
HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros
-TOOLS := compiletest rustdoc rustc rustbook error-index-generator
+TOOLS := compiletest rustdoc rustc rustbook error_index_generator
DEPS_core :=
DEPS_alloc := core libc alloc_system
TOOL_DEPS_rustdoc := rustdoc
TOOL_DEPS_rustc := rustc_driver
TOOL_DEPS_rustbook := std rustdoc
-TOOL_DEPS_error-index-generator := rustdoc syntax serialize
+TOOL_DEPS_error_index_generator := rustdoc syntax serialize
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
TOOL_SOURCE_rustbook := $(S)src/rustbook/main.rs
-TOOL_SOURCE_error-index-generator := $(S)src/error-index-generator/main.rs
+TOOL_SOURCE_error_index_generator := $(S)src/error_index_generator/main.rs
ONLY_RLIB_core := 1
ONLY_RLIB_libc := 1
doc \
driver \
etc \
- error-index-generator \
+ error_index_generator \
$(foreach crate,$(CRATES),lib$(crate)) \
libcollectionstest \
libcoretest \
# ./configure
RUSTBOOK = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTBOOK_EXE)
-# The error-index-generator executable...
-ERR_IDX_GEN_EXE = $(HBIN2_H_$(CFG_BUILD))/error-index-generator$(X_$(CFG_BUILD))
+# The error_index_generator executable...
+ERR_IDX_GEN_EXE = $(HBIN2_H_$(CFG_BUILD))/error_index_generator$(X_$(CFG_BUILD))
ERR_IDX_GEN = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE)
ERR_IDX_GEN_MD = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE) markdown
# Metadata used to generate the index is created as a side effect of
# the build so this depends on every crate being up to date.
doc/error-index.html: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUILD)) | doc/
- $(Q)$(call E, error-index-generator: $@)
+ $(Q)$(call E, error_index_generator: $@)
$(Q)$(ERR_IDX_GEN)
doc/error-index.md: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUILD)) | doc/
- $(Q)$(call E, error-index-generator: $@)
+ $(Q)$(call E, error_index_generator: $@)
$(Q)$(ERR_IDX_GEN_MD)
endef
-PREPARE_TOOLS = $(filter-out compiletest rustbook error-index-generator, $(TOOLS))
+PREPARE_TOOLS = $(filter-out compiletest rustbook error_index_generator, $(TOOLS))
# $(1) is tool
else ifeq ($(OSTYPE_$(1)), apple-ios)
JEMALLOC_ARGS_$(1) := --disable-tls
else ifeq ($(findstring android, $(OSTYPE_$(1))), android)
- JEMALLOC_ARGS_$(1) := --disable-tls
+ # We force android to have prefixed symbols because apparently replacement of
+ # the libc allocator doesn't quite work. When this was tested (unprefixed
+ # symbols), it was found that the `realpath` function in libc would allocate
+ # with libc malloc (not jemalloc malloc), and then the standard library would
+ # free with jemalloc free, causing a segfault.
+ #
+ # If the test suite passes, however, without symbol prefixes then we should be
+ # good to go!
+ JEMALLOC_ARGS_$(1) := --disable-tls --with-jemalloc-prefix=je_
endif
ifdef CFG_ENABLE_DEBUG_JEMALLOC
$$(JEMALLOC_LOCAL_$(1)): $$(JEMALLOC_DEPS) $$(MKFILE_DEPS)
@$$(call E, make: jemalloc)
cd "$$(JEMALLOC_BUILD_DIR_$(1))"; "$(S)src/jemalloc/configure" \
- $$(JEMALLOC_ARGS_$(1)) --with-jemalloc-prefix=je_ $(CFG_JEMALLOC_FLAGS) \
+ $$(JEMALLOC_ARGS_$(1)) $(CFG_JEMALLOC_FLAGS) \
--build=$$(CFG_GNU_TRIPLE_$(CFG_BUILD)) --host=$$(CFG_GNU_TRIPLE_$(1)) \
CC="$$(CC_$(1)) $$(CFG_JEMALLOC_CFLAGS_$(1))" \
AR="$$(AR_$(1))" \
$$(S) \
$(3) \
"$$(LLVM_LIBDIR_RUSTFLAGS_$(3))" \
- "$$(LLVM_ALL_COMPONENTS_$(3))"
+ "$$(LLVM_ALL_COMPONENTS_$(3))" \
+ "$$(LLVM_CXXFLAGS_$(3))"
@touch -r $$@.start_time $$@ && rm $$@.start_time
else
# FIXME #11094 - The above rule doesn't work right for multiple targets
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::fs;
+use std::path::Path;
+
+use build::Build;
+
+pub fn clean(build: &Build) {
+ for host in build.config.host.iter() {
+
+ let out = build.out.join(host);
+
+ rm_rf(build, &out.join("compiler-rt"));
+
+ for stage in 0..4 {
+ rm_rf(build, &out.join(format!("stage{}", stage)));
+ rm_rf(build, &out.join(format!("stage{}-std", stage)));
+ rm_rf(build, &out.join(format!("stage{}-rustc", stage)));
+ }
+ }
+}
+
+fn rm_rf(build: &Build, path: &Path) {
+ if path.exists() {
+ build.verbose(&format!("removing `{}`", path.display()));
+ t!(fs::remove_dir_all(path));
+ }
+}
pub src: Option<PathBuf>,
pub jobs: Option<u32>,
pub args: Vec<String>,
+ pub clean: bool,
}
pub struct Filter {
opts.optopt("", "stage", "stage to build", "N");
opts.optopt("", "src", "path to repo root", "DIR");
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
+ opts.optflag("", "clean", "clean output directory");
opts.optflag("h", "help", "print this help message");
let usage = |n| -> ! {
Flags {
verbose: m.opt_present("v"),
+ clean: m.opt_present("clean"),
stage: m.opt_str("stage").map(|j| j.parse().unwrap()),
build: m.opt_str("build").unwrap(),
host: Filter { values: m.opt_strs("host") },
mem::size_of_val(&info) as DWORD);
assert!(r != 0, "{}", io::Error::last_os_error());
- // Assign our process to this job object
+ // Assign our process to this job object. Note that if this fails, one very
+ // likely reason is that we are ourselves already in a job object! This can
+ // happen on the build bots that we've got for Windows, or if just anyone
+ // else is instrumenting the build. In this case we just bail out
+ // immediately and assume that they take care of it.
+ //
+ // Also note that nested jobs (why this might fail) are supported in recent
+ // versions of Windows, but the version of Windows that our bots are running
+ // at least don't support nested job objects.
let r = AssignProcessToJobObject(job, GetCurrentProcess());
- assert!(r != 0, "{}", io::Error::last_os_error());
+ if r == 0 {
+ CloseHandle(job);
+ return
+ }
// If we've got a parent process (e.g. the python script that called us)
// then move ownership of this job object up to them. That way if the python
mod cc;
mod channel;
+mod clean;
mod compile;
mod config;
mod flags;
#[cfg(not(windows))] fn setup_job() {}
setup_job();
+ if self.flags.clean {
+ return clean::clean(self);
+ }
+
cc::find(self);
sanity::check(self);
channel::collect(self);
all:
$(Q)$(BOOTSTRAP)
+
+clean:
+ $(Q)$(BOOTSTRAP) --clean
fn main() {
let data = Arc::new(Mutex::new(0));
+ // `tx` is the "transmitter" or "sender"
+ // `rx` is the "receiver"
let (tx, rx) = mpsc::channel();
for _ in 0..10 {
```text
First, we set `x` to five:
- ```text
+ ```rust
let x = 5;
# let y = 6;
# println!("{}", x + y);
Next, we set `y` to six:
- ```text
+ ```rust
# let x = 5;
let y = 6;
# println!("{}", x + y);
Finally, we print the sum of `x` and `y`:
- ```text
+ ```rust
# let x = 5;
# let y = 6;
println!("{}", x + y);
```text
expected one of `!`, `:`, or `@`, found `)`
-fn print_number(x, y) {
+fn print_sum(x, y) {
```
This is a deliberate design decision. While full-program inference is possible,
}
```
-When `v` comes into scope, a new [vector] is created, and it allocates space on
-[the heap][heap] for each of its elements. When `v` goes out of scope at the
-end of `foo()`, Rust will clean up everything related to the vector, even the
-heap-allocated memory. This happens deterministically, at the end of the scope.
+When `v` comes into scope, a new [vector] is created on [the stack][stack],
+and it allocates space on [the heap][heap] for its elements. When `v` goes out
+of scope at the end of `foo()`, Rust will clean up everything related to the
+vector, even the heap-allocated memory. This happens deterministically, at the
+end of the scope.
We'll cover [vectors] in detail later in this chapter; we only use them
here as an example of a type that allocates space on the heap at runtime. They
[arrays]: primitive-types.html#arrays
[vectors]: vectors.html
[heap]: the-stack-and-the-heap.html
+[stack]: the-stack-and-the-heap.html#the-stack
[bindings]: variable-bindings.html
[generics]: generics.html
```rust
let s = "foo\
- bar";
+ bar";
assert_eq!("foobar", s);
```
> For details on binaries without the standard library, see [the nightly
> chapter on `#![no_std]`](no-stdlib.html)
-To use `#![no_std]`, add a it to your crate root:
+To use `#![no_std]`, add it to your crate root:
```rust
#![no_std]
```
(Notice that unlike the `println!` macro we’ve used in the past, we use square
-brackets `[]` with `vec!` macro. Rust allows you to use either in either situation,
-this is just convention.)
+brackets `[]` with `vec!` macro. Rust allows you to use either in either
+situation, this is just convention.)
There’s an alternate form of `vec!` for repeating an initial value:
let v = vec![0; 10]; // ten zeroes
```
+Vectors store their contents as contiguous arrays of `T` on the heap. This means
+that they must be able to know the size of `T` at compile time (that is, how
+many bytes are needed to store a `T`?). The size of some things can't be known
+at compile time. For these you'll have to store a pointer to that thing:
+thankfully, the [`Box`][box] type works perfectly for this.
+
## Accessing elements
To get the value at a particular index in the vector, we use `[]`s:
API documentation][vec].
[vec]: ../std/vec/index.html
+[box]: ../std/boxed/index.html
[generic]: generics.html
[panic]: concurrency.html#panics
[get]: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.get
+++ /dev/null
-\usepackage{newunicodechar}
-\newunicodechar⊥{{$\bot$}}
+++ /dev/null
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(rustc_private, rustdoc)]
-
-extern crate syntax;
-extern crate rustdoc;
-extern crate serialize as rustc_serialize;
-
-use std::collections::BTreeMap;
-use std::fs::{read_dir, File};
-use std::io::{Read, Write};
-use std::env;
-use std::path::Path;
-use std::error::Error;
-
-use syntax::diagnostics::metadata::{get_metadata_dir, ErrorMetadataMap, ErrorMetadata};
-
-use rustdoc::html::markdown::Markdown;
-use rustc_serialize::json;
-
-enum OutputFormat {
- HTML(HTMLFormatter),
- Markdown(MarkdownFormatter),
- Unknown(String),
-}
-
-impl OutputFormat {
- fn from(format: &str) -> OutputFormat {
- match &*format.to_lowercase() {
- "html" => OutputFormat::HTML(HTMLFormatter),
- "markdown" => OutputFormat::Markdown(MarkdownFormatter),
- s => OutputFormat::Unknown(s.to_owned()),
- }
- }
-}
-
-trait Formatter {
- fn header(&self, output: &mut Write) -> Result<(), Box<Error>>;
- fn title(&self, output: &mut Write) -> Result<(), Box<Error>>;
- fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
- err_code: &str) -> Result<(), Box<Error>>;
- fn footer(&self, output: &mut Write) -> Result<(), Box<Error>>;
-}
-
-struct HTMLFormatter;
-struct MarkdownFormatter;
-
-impl Formatter for HTMLFormatter {
- fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
- try!(write!(output, r##"<!DOCTYPE html>
-<html>
-<head>
-<title>Rust Compiler Error Index</title>
-<meta charset="utf-8">
-<!-- Include rust.css after main.css so its rules take priority. -->
-<link rel="stylesheet" type="text/css" href="main.css"/>
-<link rel="stylesheet" type="text/css" href="rust.css"/>
-<style>
-.error-undescribed {{
- display: none;
-}}
-</style>
-</head>
-<body>
-"##));
- Ok(())
- }
-
- fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
- try!(write!(output, "<h1>Rust Compiler Error Index</h1>\n"));
- Ok(())
- }
-
- fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
- err_code: &str) -> Result<(), Box<Error>> {
- // Enclose each error in a div so they can be shown/hidden en masse.
- let desc_desc = match info.description {
- Some(_) => "error-described",
- None => "error-undescribed",
- };
- let use_desc = match info.use_site {
- Some(_) => "error-used",
- None => "error-unused",
- };
- try!(write!(output, "<div class=\"{} {}\">", desc_desc, use_desc));
-
- // Error title (with self-link).
- try!(write!(output,
- "<h2 id=\"{0}\" class=\"section-header\"><a href=\"#{0}\">{0}</a></h2>\n",
- err_code));
-
- // Description rendered as markdown.
- match info.description {
- Some(ref desc) => try!(write!(output, "{}", Markdown(desc))),
- None => try!(write!(output, "<p>No description.</p>\n")),
- }
-
- try!(write!(output, "</div>\n"));
- Ok(())
- }
-
- fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
- try!(write!(output, "</body>\n</html>"));
- Ok(())
- }
-}
-
-impl Formatter for MarkdownFormatter {
- #[allow(unused_variables)]
- fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
- Ok(())
- }
-
- fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
- try!(write!(output, "# Rust Compiler Error Index\n"));
- Ok(())
- }
-
- fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
- err_code: &str) -> Result<(), Box<Error>> {
- Ok(match info.description {
- Some(ref desc) => try!(write!(output, "## {}\n{}\n", err_code, desc)),
- None => (),
- })
- }
-
- #[allow(unused_variables)]
- fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
- Ok(())
- }
-}
-
-/// Load all the metadata files from `metadata_dir` into an in-memory map.
-fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<Error>> {
- let mut all_errors = BTreeMap::new();
-
- for entry in try!(read_dir(metadata_dir)) {
- let path = try!(entry).path();
-
- let mut metadata_str = String::new();
- try!(File::open(&path).and_then(|mut f| f.read_to_string(&mut metadata_str)));
-
- let some_errors: ErrorMetadataMap = try!(json::decode(&metadata_str));
-
- for (err_code, info) in some_errors {
- all_errors.insert(err_code, info);
- }
- }
-
- Ok(all_errors)
-}
-
-/// Output an HTML page for the errors in `err_map` to `output_path`.
-fn render_error_page<T: Formatter>(err_map: &ErrorMetadataMap, output_path: &Path,
- formatter: T) -> Result<(), Box<Error>> {
- let mut output_file = try!(File::create(output_path));
-
- try!(formatter.header(&mut output_file));
- try!(formatter.title(&mut output_file));
-
- for (err_code, info) in err_map {
- try!(formatter.error_code_block(&mut output_file, info, err_code));
- }
-
- formatter.footer(&mut output_file)
-}
-
-fn main_with_result(format: OutputFormat) -> Result<(), Box<Error>> {
- let build_arch = try!(env::var("CFG_BUILD"));
- let metadata_dir = get_metadata_dir(&build_arch);
- let err_map = try!(load_all_errors(&metadata_dir));
- match format {
- OutputFormat::Unknown(s) => panic!("Unknown output format: {}", s),
- OutputFormat::HTML(h) => try!(render_error_page(&err_map,
- Path::new("doc/error-index.html"),
- h)),
- OutputFormat::Markdown(m) => try!(render_error_page(&err_map,
- Path::new("doc/error-index.md"),
- m)),
- }
- Ok(())
-}
-
-fn parse_args() -> OutputFormat {
- for arg in env::args().skip(1) {
- return OutputFormat::from(&arg);
- }
- OutputFormat::from("html")
-}
-
-fn main() {
- if let Err(e) = main_with_result(parse_args()) {
- panic!("{}", e.description());
- }
-}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(rustc_private, rustdoc)]
+
+extern crate syntax;
+extern crate rustdoc;
+extern crate serialize as rustc_serialize;
+
+use std::collections::BTreeMap;
+use std::fs::{read_dir, File};
+use std::io::{Read, Write};
+use std::env;
+use std::path::Path;
+use std::error::Error;
+
+use syntax::diagnostics::metadata::{get_metadata_dir, ErrorMetadataMap, ErrorMetadata};
+
+use rustdoc::html::markdown::Markdown;
+use rustc_serialize::json;
+
+enum OutputFormat {
+ HTML(HTMLFormatter),
+ Markdown(MarkdownFormatter),
+ Unknown(String),
+}
+
+impl OutputFormat {
+ fn from(format: &str) -> OutputFormat {
+ match &*format.to_lowercase() {
+ "html" => OutputFormat::HTML(HTMLFormatter),
+ "markdown" => OutputFormat::Markdown(MarkdownFormatter),
+ s => OutputFormat::Unknown(s.to_owned()),
+ }
+ }
+}
+
+trait Formatter {
+ fn header(&self, output: &mut Write) -> Result<(), Box<Error>>;
+ fn title(&self, output: &mut Write) -> Result<(), Box<Error>>;
+ fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
+ err_code: &str) -> Result<(), Box<Error>>;
+ fn footer(&self, output: &mut Write) -> Result<(), Box<Error>>;
+}
+
+struct HTMLFormatter;
+struct MarkdownFormatter;
+
+impl Formatter for HTMLFormatter {
+ fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
+ try!(write!(output, r##"<!DOCTYPE html>
+<html>
+<head>
+<title>Rust Compiler Error Index</title>
+<meta charset="utf-8">
+<!-- Include rust.css after main.css so its rules take priority. -->
+<link rel="stylesheet" type="text/css" href="main.css"/>
+<link rel="stylesheet" type="text/css" href="rust.css"/>
+<style>
+.error-undescribed {{
+ display: none;
+}}
+</style>
+</head>
+<body>
+"##));
+ Ok(())
+ }
+
+ fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
+ try!(write!(output, "<h1>Rust Compiler Error Index</h1>\n"));
+ Ok(())
+ }
+
+ fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
+ err_code: &str) -> Result<(), Box<Error>> {
+ // Enclose each error in a div so they can be shown/hidden en masse.
+ let desc_desc = match info.description {
+ Some(_) => "error-described",
+ None => "error-undescribed",
+ };
+ let use_desc = match info.use_site {
+ Some(_) => "error-used",
+ None => "error-unused",
+ };
+ try!(write!(output, "<div class=\"{} {}\">", desc_desc, use_desc));
+
+ // Error title (with self-link).
+ try!(write!(output,
+ "<h2 id=\"{0}\" class=\"section-header\"><a href=\"#{0}\">{0}</a></h2>\n",
+ err_code));
+
+ // Description rendered as markdown.
+ match info.description {
+ Some(ref desc) => try!(write!(output, "{}", Markdown(desc))),
+ None => try!(write!(output, "<p>No description.</p>\n")),
+ }
+
+ try!(write!(output, "</div>\n"));
+ Ok(())
+ }
+
+ fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
+ try!(write!(output, "</body>\n</html>"));
+ Ok(())
+ }
+}
+
+impl Formatter for MarkdownFormatter {
+ #[allow(unused_variables)]
+ fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
+ Ok(())
+ }
+
+ fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
+ try!(write!(output, "# Rust Compiler Error Index\n"));
+ Ok(())
+ }
+
+ fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
+ err_code: &str) -> Result<(), Box<Error>> {
+ Ok(match info.description {
+ Some(ref desc) => try!(write!(output, "## {}\n{}\n", err_code, desc)),
+ None => (),
+ })
+ }
+
+ #[allow(unused_variables)]
+ fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
+ Ok(())
+ }
+}
+
+/// Load all the metadata files from `metadata_dir` into an in-memory map.
+fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<Error>> {
+ let mut all_errors = BTreeMap::new();
+
+ for entry in try!(read_dir(metadata_dir)) {
+ let path = try!(entry).path();
+
+ let mut metadata_str = String::new();
+ try!(File::open(&path).and_then(|mut f| f.read_to_string(&mut metadata_str)));
+
+ let some_errors: ErrorMetadataMap = try!(json::decode(&metadata_str));
+
+ for (err_code, info) in some_errors {
+ all_errors.insert(err_code, info);
+ }
+ }
+
+ Ok(all_errors)
+}
+
+/// Output an HTML page for the errors in `err_map` to `output_path`.
+fn render_error_page<T: Formatter>(err_map: &ErrorMetadataMap, output_path: &Path,
+ formatter: T) -> Result<(), Box<Error>> {
+ let mut output_file = try!(File::create(output_path));
+
+ try!(formatter.header(&mut output_file));
+ try!(formatter.title(&mut output_file));
+
+ for (err_code, info) in err_map {
+ try!(formatter.error_code_block(&mut output_file, info, err_code));
+ }
+
+ formatter.footer(&mut output_file)
+}
+
+fn main_with_result(format: OutputFormat) -> Result<(), Box<Error>> {
+ let build_arch = try!(env::var("CFG_BUILD"));
+ let metadata_dir = get_metadata_dir(&build_arch);
+ let err_map = try!(load_all_errors(&metadata_dir));
+ match format {
+ OutputFormat::Unknown(s) => panic!("Unknown output format: {}", s),
+ OutputFormat::HTML(h) => try!(render_error_page(&err_map,
+ Path::new("doc/error-index.html"),
+ h)),
+ OutputFormat::Markdown(m) => try!(render_error_page(&err_map,
+ Path::new("doc/error-index.md"),
+ m)),
+ }
+ Ok(())
+}
+
+fn parse_args() -> OutputFormat {
+ for arg in env::args().skip(1) {
+ return OutputFormat::from(&arg);
+ }
+ OutputFormat::from("html")
+}
+
+fn main() {
+ if let Err(e) = main_with_result(parse_args()) {
+ panic!("{}", e.description());
+ }
+}
putenv('RUSTC', os.path.abspath(sys.argv[3]))
putenv('TMPDIR', os.path.abspath(sys.argv[4]))
putenv('CC', sys.argv[5] + ' ' + sys.argv[6])
+putenv('CFLAGS', sys.argv[6])
putenv('RUSTDOC', os.path.abspath(sys.argv[7]))
filt = sys.argv[8]
putenv('LD_LIB_PATH_ENVVAR', sys.argv[9])
putenv('S', os.path.abspath(sys.argv[13]))
putenv('RUSTFLAGS', sys.argv[15])
putenv('LLVM_COMPONENTS', sys.argv[16])
+putenv('LLVM_CXXFLAGS', sys.argv[17])
putenv('PYTHON', sys.executable)
os.putenv('TARGET', target_triple)
+++ /dev/null
-#!/usr/bin/env python2
-
-# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import datetime
-import os.path as path
-
-
-def print_tests(tests):
- print('\n'.join([test_tostr(t) for t in tests]))
-
-
-def read_tests(f):
- basename, _ = path.splitext(path.basename(f))
- tests = []
- for lineno, line in enumerate(open(f), 1):
- fields = filter(None, map(str.strip, line.split('\t')))
- if not (4 <= len(fields) <= 5) \
- or 'E' not in fields[0] or fields[0][0] == '#':
- continue
-
- opts, pat, text, sgroups = fields[0:4]
- groups = [] # groups as integer ranges
- if sgroups == 'NOMATCH':
- groups = [None]
- elif ',' in sgroups:
- noparen = map(lambda s: s.strip('()'), sgroups.split(')('))
- for g in noparen:
- s, e = map(str.strip, g.split(','))
- if s == '?' and e == '?':
- groups.append(None)
- else:
- groups.append((int(s), int(e)))
- else:
- # This skips tests that should result in an error.
- # There aren't many, so I think we can just capture those
- # manually. Possibly fix this in future.
- continue
-
- if pat == 'SAME':
- pat = tests[-1][1]
- if '$' in opts:
- pat = pat.decode('string_escape')
- text = text.decode('string_escape')
- if 'i' in opts:
- pat = '(?i)%s' % pat
-
- name = '%s_%d' % (basename, lineno)
- tests.append((name, pat, text, groups))
- return tests
-
-
-def test_tostr(t):
- lineno, pat, text, groups = t
- options = map(group_tostr, groups)
- return 'mat!{match_%s, r"%s", r"%s", %s}' \
- % (lineno, pat, '' if text == "NULL" else text, ', '.join(options))
-
-
-def group_tostr(g):
- if g is None:
- return 'None'
- else:
- return 'Some((%d, %d))' % (g[0], g[1])
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description='Generate match tests from an AT&T POSIX test file.')
- aa = parser.add_argument
- aa('files', nargs='+',
- help='A list of dat AT&T POSIX test files. See src/libregexp/testdata')
- args = parser.parse_args()
-
- tests = []
- for f in args.files:
- tests += read_tests(f)
-
- tpl = '''// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// ignore-tidy-linelength
-
-// DO NOT EDIT. Automatically generated by 'src/etc/regexp-match-tests'
-// on {date}.
-'''
- print(tpl.format(date=str(datetime.datetime.now())))
-
- for f in args.files:
- print('// Tests from %s' % path.basename(f))
- print_tests(read_tests(f))
- print('')
.env("AR", &ar)
.env("RANLIB", format!("{} s", ar.display()));
- if target.contains("windows-gnu") {
+ if target.contains("windows") {
// A bit of history here, this used to be --enable-lazy-lock added in
// #14006 which was filed with jemalloc in jemalloc/jemalloc#83 which
// was also reported to MinGW:
// locking, but requires passing an option due to a historical
// default with jemalloc.
cmd.arg("--disable-lazy-lock");
- } else if target.contains("ios") || target.contains("android") {
+ } else if target.contains("ios") {
+ cmd.arg("--disable-tls");
+ } else if target.contains("android") {
+ // We force android to have prefixed symbols because apparently
+ // replacement of the libc allocator doesn't quite work. When this was
+ // tested (unprefixed symbols), it was found that the `realpath`
+ // function in libc would allocate with libc malloc (not jemalloc
+ // malloc), and then the standard library would free with jemalloc free,
+ // causing a segfault.
+ //
+ // If the test suite passes, however, without symbol prefixes then we
+ // should be good to go!
+ cmd.arg("--with-jemalloc-prefix=je_");
cmd.arg("--disable-tls");
}
// Turn off broken quarantine (see jemalloc/jemalloc#161)
cmd.arg("--disable-fill");
- cmd.arg("--with-jemalloc-prefix=je_");
cmd.arg(format!("--host={}", build_helper::gnu_target(&target)));
cmd.arg(format!("--build={}", build_helper::gnu_target(&host)));
#[cfg(not(cargobuild))]
extern {}
+// Note that the symbols here are prefixed by default on OSX (we don't
+// explicitly request it), and on Android we explicitly request it as
+// unprefixing cause segfaults (mismatches in allocators).
extern {
- fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
- fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
- fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
- fn je_sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
- fn je_nallocx(size: size_t, flags: c_int) -> size_t;
+ #[cfg_attr(any(target_os = "macos", target_os = "android"),
+ link_name = "je_mallocx")]
+ fn mallocx(size: size_t, flags: c_int) -> *mut c_void;
+ #[cfg_attr(any(target_os = "macos", target_os = "android"),
+ link_name = "je_rallocx")]
+ fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
+ #[cfg_attr(any(target_os = "macos", target_os = "android"),
+ link_name = "je_xallocx")]
+ fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
+ #[cfg_attr(any(target_os = "macos", target_os = "android"),
+ link_name = "je_sdallocx")]
+ fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
+ #[cfg_attr(any(target_os = "macos", target_os = "android"),
+ link_name = "je_nallocx")]
+ fn nallocx(size: size_t, flags: c_int) -> size_t;
}
// The minimum alignment guaranteed by the architecture. This value is used to
#[no_mangle]
pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
let flags = align_to_flags(align);
- unsafe { je_mallocx(size as size_t, flags) as *mut u8 }
+ unsafe { mallocx(size as size_t, flags) as *mut u8 }
}
#[no_mangle]
align: usize)
-> *mut u8 {
let flags = align_to_flags(align);
- unsafe { je_rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 }
+ unsafe { rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 }
}
#[no_mangle]
align: usize)
-> usize {
let flags = align_to_flags(align);
- unsafe { je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize }
+ unsafe { xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize }
}
#[no_mangle]
pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
let flags = align_to_flags(align);
- unsafe { je_sdallocx(ptr as *mut c_void, old_size as size_t, flags) }
+ unsafe { sdallocx(ptr as *mut c_void, old_size as size_t, flags) }
}
#[no_mangle]
pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
let flags = align_to_flags(align);
- unsafe { je_nallocx(size as size_t, flags) as usize }
+ unsafe { nallocx(size as size_t, flags) as usize }
}
// These symbols are used by jemalloc on android but the really old android
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-//! A growable list type with heap-allocated contents, written `Vec<T>` but
-//! pronounced 'vector.'
+//! A contiguous growable array type with heap-allocated contents, written
+//! `Vec<T>` but pronounced 'vector.'
//!
//! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
//! `O(1)` pop (from the end).
use super::range::RangeArgument;
-/// A growable list type, written `Vec<T>` but pronounced 'vector.'
+/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.'
///
/// # Examples
///
}
/// Inserts an element at position `index` within the vector, shifting all
- /// elements after position `i` one position to the right.
+ /// elements after it to the right.
///
/// # Panics
///
}
/// Removes and returns the element at position `index` within the vector,
- /// shifting all elements after position `index` one position to the left.
+ /// shifting all elements after it to the left.
///
/// # Panics
///
}
}
- /// Checked negation. Computes `!self`, returning `None` if `self ==
+ /// Checked negation. Computes `-self`, returning `None` if `self ==
/// MIN`.
///
/// # Examples
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
///
+ /// Note that this is *not* the same as a rotate-left; the
+ /// RHS of a wrapping shift-left is restricted to the range
+ /// of the type, rather than the bits shifted out of the LHS
+ /// being returned to the other end. The primitive integer
+ /// types all implement a `rotate_left` function, which may
+ /// be what you want instead.
+ ///
/// # Examples
///
/// Basic usage:
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
///
+ /// Note that this is *not* the same as a rotate-right; the
+ /// RHS of a wrapping shift-right is restricted to the range
+ /// of the type, rather than the bits shifted out of the LHS
+ /// being returned to the other end. The primitive integer
+ /// types all implement a `rotate_right` function, which may
+ /// be what you want instead.
+ ///
/// # Examples
///
/// Basic usage:
#![stable(feature = "rust1", since = "1.0.0")]
-uint_module! { u16, i16, 16 }
+uint_module! { u16, 16 }
#![stable(feature = "rust1", since = "1.0.0")]
-uint_module! { u32, i32, 32 }
+uint_module! { u32, 32 }
#![stable(feature = "rust1", since = "1.0.0")]
-uint_module! { u64, i64, 64 }
+uint_module! { u64, 64 }
#![stable(feature = "rust1", since = "1.0.0")]
-uint_module! { u8, i8, 8 }
+uint_module! { u8, 8 }
#![doc(hidden)]
-macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => (
+macro_rules! uint_module { ($T:ty, $bits:expr) => (
#[unstable(feature = "num_bits_bytes",
reason = "may want to be an associated function",
#![stable(feature = "rust1", since = "1.0.0")]
#[cfg(target_pointer_width = "32")]
-uint_module! { usize, isize, 32 }
+uint_module! { usize, 32 }
#[cfg(target_pointer_width = "64")]
-uint_module! { usize, isize, 64 }
+uint_module! { usize, 64 }
tmp
}
-/// Variant of read_and_zero that writes the specific drop-flag byte
-/// (which may be more appropriate than zero).
+#[allow(missing_docs)]
#[inline(always)]
#[unstable(feature = "filling_drop",
reason = "may play a larger role in std::ptr future extensions",
/// // std::str::from_utf8 returns a Utf8Error
/// let error = str::from_utf8(&sparkle_heart).unwrap_err();
///
- /// // the first byte is invalid here
+ /// // the second byte is invalid here
/// assert_eq!(1, error.valid_up_to());
/// ```
#[stable(feature = "utf8_error", since = "1.5.0")]
///
/// If you are sure that the byte slice is valid UTF-8, and you don't want to
/// incur the overhead of the validity check, there is an unsafe version of
-/// this function, [`from_utf8_unchecked()`][fromutf8], which has the same
+/// this function, [`from_utf8_unchecked()`][fromutf8u], which has the same
/// behavior but skips the check.
///
-/// [fromutf8]: fn.from_utf8.html
+/// [fromutf8u]: fn.from_utf8_unchecked.html
///
/// If you need a `String` instead of a `&str`, consider
/// [`String::from_utf8()`][string].
/// Converts a slice of bytes to a string slice without checking
/// that the string contains valid UTF-8.
///
-/// See the safe version, [`from_utf8()`][fromutf8], for more.
+/// See the safe version, [`from_utf8()`][fromutf8], for more information.
///
/// [fromutf8]: fn.from_utf8.html
///
pub parameter_environment: ty::ParameterEnvironment<'a, 'tcx>,
- pub fulfillment_cx: RefCell<traits::FulfillmentContext<'tcx>>,
-
// the set of predicates on which errors have been reported, to
// avoid reporting the same error twice.
pub reported_trait_errors: RefCell<FnvHashSet<traits::TraitErrorKey<'tcx>>>,
float_unification_table: RefCell::new(UnificationTable::new()),
region_vars: RegionVarBindings::new(tcx),
parameter_environment: param_env.unwrap_or(tcx.empty_parameter_environment()),
- fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
reported_trait_errors: RefCell::new(FnvHashSet()),
normalize: false,
err_count_on_creation: tcx.sess.err_count()
result,
obligations);
- let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+ let mut fulfill_cx = traits::FulfillmentContext::new();
for obligation in obligations {
fulfill_cx.register_predicate_obligation(&infcx, obligation);
cause: ObligationCause<'tcx>)
-> Ty<'tcx>
{
- debug!("normalize_associated_type(projection_ty={:?})",
+ debug!("normalize_projection_type(projection_ty={:?})",
projection_ty);
assert!(!projection_ty.has_escaping_regions());
self.register_predicate_obligation(infcx, obligation);
}
- debug!("normalize_associated_type: result={:?}", normalized.value);
+ debug!("normalize_projection_type: result={:?}", normalized.value);
normalized.value
}
assert!(!obligation.has_escaping_regions());
if self.is_duplicate_or_add(infcx.tcx, &obligation.predicate) {
- debug!("register_predicate({:?}) -- already seen, skip", obligation);
+ debug!("register_predicate_obligation({:?}) -- already seen, skip", obligation);
return;
}
- debug!("register_predicate({:?})", obligation);
+ debug!("register_predicate_obligation({:?})", obligation);
let obligation = PendingPredicateObligation {
obligation: obligation,
stalled_on: vec![]
let mut errors = Vec::new();
loop {
- debug!("select_where_possible: starting another iteration");
+ debug!("select: starting another iteration");
// Process pending obligations.
let outcome = {
region_obligations))
};
- debug!("select_where_possible: outcome={:?}", outcome);
+ debug!("select: outcome={:?}", outcome);
// these are obligations that were proven to be true.
for pending_obligation in outcome.completed {
use syntax::attr::AttrMetaMethods;
use syntax::errors::{ColorConfig, Handler};
use syntax::parse;
+use syntax::parse::lexer::Reader;
use syntax::parse::token::InternedString;
use syntax::feature_gate::UnstableFeatures;
link_args: Option<Vec<String>> = (None, parse_opt_list,
"extra arguments to pass to the linker (space separated)"),
link_dead_code: bool = (false, parse_bool,
- "let the linker strip dead coded (turning it on can be used for code coverage)"),
+ "don't let linker strip dead code (turning it on can be used for code coverage)"),
lto: bool = (false, parse_bool,
"perform LLVM link-time optimizations"),
target_cpu: Option<String> = (None, parse_opt_string,
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
cfgspecs.into_iter().map(|s| {
- parse::parse_meta_from_source_str("cfgspec".to_string(),
- s.to_string(),
- Vec::new(),
- &parse::ParseSess::new())
+ let sess = parse::ParseSess::new();
+ let mut parser = parse::new_parser_from_source_str(&sess,
+ Vec::new(),
+ "cfgspec".to_string(),
+ s.to_string());
+ let meta_item = panictry!(parser.parse_meta_item());
+
+ if !parser.reader.is_eof() {
+ early_error(ErrorOutputType::default(), &format!("invalid --cfg argument: {}",
+ s))
+ }
+
+ meta_item
}).collect::<ast::CrateConfig>()
}
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use target::Target;
+
+pub fn target() -> Target {
+ let mut base = super::linux_base::opts();
+ base.cpu = "pentium".to_string();
+ base.pre_link_args.push("-m32".to_string());
+
+ Target {
+ llvm_target: "i586-unknown-linux-gnu".to_string(),
+ target_endian: "little".to_string(),
+ target_pointer_width: "32".to_string(),
+ arch: "x86".to_string(),
+ target_os: "linux".to_string(),
+ target_env: "gnu".to_string(),
+ target_vendor: "unknown".to_string(),
+ options: base,
+ }
+}
let mut base = super::windows_msvc_base::opts();
base.cpu = "pentium4".to_string();
+ // Mark all dynamic libraries and executables as compatible with the larger 4GiB address
+ // space available to x86 Windows binaries on x86_64.
+ base.pre_link_args.push("/LARGEADDRESSAWARE".to_string());
+
+ // Ensure the linker will only produce an image if it can also produce a table of
+ // the image's safe exception handlers.
+ // https://msdn.microsoft.com/en-us/library/9a89h429.aspx
+ base.pre_link_args.push("/SAFESEH".to_string());
+
Target {
llvm_target: "i686-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
supported_targets! {
("x86_64-unknown-linux-gnu", x86_64_unknown_linux_gnu),
("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
+ ("i586-unknown-linux-gnu", i586_unknown_linux_gnu),
("mips-unknown-linux-gnu", mips_unknown_linux_gnu),
("mipsel-unknown-linux-gnu", mipsel_unknown_linux_gnu),
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
pub struct FnvHasher(u64);
impl Default for FnvHasher {
+ #[inline]
fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) }
}
impl Hasher for FnvHasher {
+ #[inline]
fn write(&mut self, bytes: &[u8]) {
let FnvHasher(mut hash) = *self;
for byte in bytes {
}
*self = FnvHasher(hash);
}
+
+ #[inline]
fn finish(&self) -> u64 { self.0 }
}
use rustc_resolve as resolve;
use rustc_metadata::cstore::CStore;
+use rustc_mir::pretty::write_mir_pretty;
+
use syntax::ast::{self, BlockCheckMode};
use syntax::codemap;
use syntax::fold::{self, Folder};
PpmSource(PpSourceMode),
PpmHir(PpSourceMode),
PpmFlowGraph(PpFlowGraphMode),
+ PpmMir,
}
pub fn parse_pretty(sess: &Session,
("hir", true) => PpmHir(PpmNormal),
("hir,identified", true) => PpmHir(PpmIdentified),
("hir,typed", true) => PpmHir(PpmTyped),
+ ("mir", true) => PpmMir,
("flowgraph", true) => PpmFlowGraph(PpFlowGraphMode::Default),
("flowgraph,unlabelled", true) => PpmFlowGraph(PpFlowGraphMode::UnlabelledEdges),
_ => {
sess.fatal(&format!("argument to `unpretty` must be one of `normal`, \
`expanded`, `flowgraph[,unlabelled]=<nodeid>`, \
`identified`, `expanded,identified`, `everybody_loops`, \
- `hir`, `hir,identified`, or `hir,typed`; got {}",
+ `hir`, `hir,identified`, `hir,typed`, or `mir`; got {}",
name));
} else {
sess.fatal(&format!("argument to `pretty` must be one of `normal`, `expanded`, \
PpmSource(PpmExpandedIdentified) |
PpmSource(PpmExpandedHygiene) |
PpmHir(_) |
+ PpmMir |
PpmFlowGraph(_) => true,
PpmSource(PpmTyped) => panic!("invalid state"),
}
PpmSource(PpmExpandedIdentified) |
PpmSource(PpmExpandedHygiene) |
PpmHir(_) |
+ PpmMir |
PpmFlowGraph(_) => true,
PpmSource(PpmTyped) => panic!("invalid state"),
}
})
}
+ (PpmMir, None) => {
+ debug!("pretty printing MIR for whole crate");
+ let ast_map = ast_map.expect("--unpretty mir missing ast_map");
+ abort_on_err(driver::phase_3_run_analysis_passes(&sess,
+ &cstore,
+ ast_map,
+ &arenas,
+ &id,
+ resolve::MakeGlobMap::No,
+ |tcx, mir_map, _, _| {
+ let mir_map = mir_map.unwrap();
+
+ for (nodeid, mir) in &mir_map.map {
+ try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(*nodeid)));
+ try!(write_mir_pretty(mir, &mut out));
+ }
+
+ Ok(())
+ }), &sess)
+ }
+
+ (PpmMir, Some(uii)) => {
+ debug!("pretty printing MIR for {:?}", uii);
+ let ast_map = ast_map.expect("--unpretty mir missing ast_map");
+ let nodeid = uii.to_one_node_id("--unpretty", &sess, &ast_map);
+
+ abort_on_err(driver::phase_3_run_analysis_passes(&sess,
+ &cstore,
+ ast_map,
+ &arenas,
+ &id,
+ resolve::MakeGlobMap::No,
+ |tcx, mir_map, _, _| {
+ let mir_map = mir_map.unwrap();
+ try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(nodeid)));
+ let mir = mir_map.map.get(&nodeid).unwrap_or_else(|| {
+ sess.fatal(&format!("no MIR map entry for node {}", nodeid))
+ });
+ write_mir_pretty(mir, &mut out)
+ }), &sess)
+ }
+
(PpmFlowGraph(mode), opt_uii) => {
debug!("pretty printing flow graph for {:?}", opt_uii);
let uii = opt_uii.unwrap_or_else(|| {
P(hir::Pat {
id: p.id,
node: match p.node {
- PatWild => hir::PatWild,
- PatIdent(ref binding_mode, pth1, ref sub) => {
+ PatKind::Wild => hir::PatWild,
+ PatKind::Ident(ref binding_mode, pth1, ref sub) => {
hir::PatIdent(lower_binding_mode(lctx, binding_mode),
respan(pth1.span, lower_ident(lctx, pth1.node)),
sub.as_ref().map(|x| lower_pat(lctx, x)))
}
- PatLit(ref e) => hir::PatLit(lower_expr(lctx, e)),
- PatEnum(ref pth, ref pats) => {
+ PatKind::Lit(ref e) => hir::PatLit(lower_expr(lctx, e)),
+ PatKind::TupleStruct(ref pth, ref pats) => {
hir::PatEnum(lower_path(lctx, pth),
pats.as_ref()
.map(|pats| pats.iter().map(|x| lower_pat(lctx, x)).collect()))
}
- PatQPath(ref qself, ref pth) => {
+ PatKind::Path(ref pth) => {
+ hir::PatEnum(lower_path(lctx, pth), Some(hir::HirVec::new()))
+ }
+ PatKind::QPath(ref qself, ref pth) => {
let qself = hir::QSelf {
ty: lower_ty(lctx, &qself.ty),
position: qself.position,
};
hir::PatQPath(qself, lower_path(lctx, pth))
}
- PatStruct(ref pth, ref fields, etc) => {
+ PatKind::Struct(ref pth, ref fields, etc) => {
let pth = lower_path(lctx, pth);
let fs = fields.iter()
.map(|f| {
.collect();
hir::PatStruct(pth, fs, etc)
}
- PatTup(ref elts) => hir::PatTup(elts.iter().map(|x| lower_pat(lctx, x)).collect()),
- PatBox(ref inner) => hir::PatBox(lower_pat(lctx, inner)),
- PatRegion(ref inner, mutbl) => {
+ PatKind::Tup(ref elts) => {
+ hir::PatTup(elts.iter().map(|x| lower_pat(lctx, x)).collect())
+ }
+ PatKind::Box(ref inner) => hir::PatBox(lower_pat(lctx, inner)),
+ PatKind::Ref(ref inner, mutbl) => {
hir::PatRegion(lower_pat(lctx, inner), lower_mutability(lctx, mutbl))
}
- PatRange(ref e1, ref e2) => {
+ PatKind::Range(ref e1, ref e2) => {
hir::PatRange(lower_expr(lctx, e1), lower_expr(lctx, e2))
}
- PatVec(ref before, ref slice, ref after) => {
+ PatKind::Vec(ref before, ref slice, ref after) => {
hir::PatVec(before.iter().map(|x| lower_pat(lctx, x)).collect(),
slice.as_ref().map(|x| lower_pat(lctx, x)),
after.iter().map(|x| lower_pat(lctx, x)).collect())
}
- PatMac(_) => panic!("Shouldn't exist here"),
+ PatKind::Mac(_) => panic!("Shouldn't exist here"),
},
span: p.span,
})
unit_temp: Lvalue<'tcx>,
data: &FreeData<'tcx>,
target: BasicBlock) -> Terminator<'tcx> {
- let free_func = tcx.lang_items.box_free_fn()
- .expect("box_free language item is missing");
+ let free_func = tcx.lang_items.require(lang_items::BoxFreeFnLangItem)
+ .unwrap_or_else(|e| tcx.sess.fatal(&e));
let substs = tcx.mk_substs(Substs::new(
VecPerParamSpace::new(vec![], vec![], vec![data.item_ty]),
VecPerParamSpace::new(vec![], vec![], vec![])
use rustc::session::{Session, CompileResult};
-use syntax::ast;
+use syntax::ast::{self, PatKind};
use syntax::visit::{self, Visitor, FnKind};
use syntax::codemap::Span;
// Ensure the arguments are simple, not mutable/by-ref or patterns.
for arg in &fd.inputs {
match arg.pat.node {
- ast::PatWild => {}
- ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
+ PatKind::Wild => {}
+ PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
_ => {
span_err!(self.sess, arg.pat.span, E0022,
"arguments of constant functions can only \
let ty = self.tcx.node_id_to_type(e.id);
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
- let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
- fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
- match fulfill_cx.select_all_or_error(&infcx) {
+ let mut fulfillment_cx = traits::FulfillmentContext::new();
+ fulfillment_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
+ match fulfillment_cx.select_all_or_error(&infcx) {
Ok(()) => { },
Err(ref errors) => {
traits::report_fulfillment_errors(&infcx, errors);
let def = Def::Mod(self.ast_map.local_def_id(item.id));
let module = self.new_module(parent_link, Some(def), false, is_public);
self.define(parent, name, TypeNS, (module, sp));
+ parent.module_children.borrow_mut().insert(item.id, module);
module
}
let parent_link = BlockParentLink(parent, block_id);
let new_module = self.new_module(parent_link, None, false, false);
- parent.anonymous_children.borrow_mut().insert(block_id, new_module);
+ parent.module_children.borrow_mut().insert(block_id, new_module);
new_module
} else {
parent
is_public: bool,
is_extern_crate: bool,
- children: RefCell<HashMap<(Name, Namespace), NameResolution<'a>>>,
+ resolutions: RefCell<HashMap<(Name, Namespace), NameResolution<'a>>>,
imports: RefCell<Vec<ImportDirective>>,
- // The anonymous children of this node. Anonymous children are pseudo-
- // modules that are implicitly created around items contained within
- // blocks.
+ // The module children of this node, including normal modules and anonymous modules.
+ // Anonymous children are pseudo-modules that are implicitly created around items
+ // contained within blocks.
//
// For example, if we have this:
//
//
// There will be an anonymous module created around `g` with the ID of the
// entry block for `f`.
- anonymous_children: RefCell<NodeMap<Module<'a>>>,
+ module_children: RefCell<NodeMap<Module<'a>>>,
shadowed_traits: RefCell<Vec<&'a NameBinding<'a>>>,
def: def,
is_public: is_public,
is_extern_crate: false,
- children: RefCell::new(HashMap::new()),
+ resolutions: RefCell::new(HashMap::new()),
imports: RefCell::new(Vec::new()),
- anonymous_children: RefCell::new(NodeMap()),
+ module_children: RefCell::new(NodeMap()),
shadowed_traits: RefCell::new(Vec::new()),
glob_count: Cell::new(0),
pub_count: Cell::new(0),
let glob_count =
if allow_private_imports { self.glob_count.get() } else { self.pub_glob_count.get() };
- self.children.borrow().get(&(name, ns)).cloned().unwrap_or_default().result(glob_count)
+ self.resolutions.borrow().get(&(name, ns)).cloned().unwrap_or_default().result(glob_count)
.and_then(|binding| {
let allowed = allow_private_imports || !binding.is_import() || binding.is_public();
if allowed { Success(binding) } else { Failed(None) }
// Define the name or return the existing binding if there is a collision.
fn try_define_child(&self, name: Name, ns: Namespace, binding: &'a NameBinding<'a>)
-> Result<(), &'a NameBinding<'a>> {
- let mut children = self.children.borrow_mut();
+ let mut children = self.resolutions.borrow_mut();
let resolution = children.entry((name, ns)).or_insert_with(Default::default);
// FIXME #31379: We can use methods from imported traits shadowed by non-import items
}
fn increment_outstanding_references_for(&self, name: Name, ns: Namespace) {
- let mut children = self.children.borrow_mut();
+ let mut children = self.resolutions.borrow_mut();
children.entry((name, ns)).or_insert_with(Default::default).outstanding_references += 1;
}
fn decrement_outstanding_references_for(&self, name: Name, ns: Namespace) {
- match self.children.borrow_mut().get_mut(&(name, ns)).unwrap().outstanding_references {
+ match self.resolutions.borrow_mut().get_mut(&(name, ns)).unwrap().outstanding_references {
0 => panic!("No more outstanding references!"),
ref mut outstanding_references => { *outstanding_references -= 1; }
}
}
fn for_each_child<F: FnMut(Name, Namespace, &'a NameBinding<'a>)>(&self, mut f: F) {
- for (&(name, ns), name_resolution) in self.children.borrow().iter() {
+ for (&(name, ns), name_resolution) in self.resolutions.borrow().iter() {
name_resolution.binding.map(|binding| f(name, ns, binding));
}
}
- fn for_each_local_child<F: FnMut(Name, Namespace, &'a NameBinding<'a>)>(&self, mut f: F) {
- self.for_each_child(|name, ns, name_binding| {
- if !name_binding.is_import() && !name_binding.is_extern_crate() {
- f(name, ns, name_binding)
- }
- })
- }
-
fn def_id(&self) -> Option<DefId> {
self.def.as_ref().map(Def::def_id)
}
}
// Descend into children and anonymous children.
- build_reduced_graph::populate_module_if_necessary(self, module_);
-
- module_.for_each_local_child(|_, _, child_node| {
- match child_node.module() {
- None => {
- // Continue.
- }
- Some(child_module) => {
- self.report_unresolved_imports(child_module);
- }
- }
- });
-
- for (_, module_) in module_.anonymous_children.borrow().iter() {
+ for (_, module_) in module_.module_children.borrow().iter() {
self.report_unresolved_imports(module_);
}
}
// generate a fake "implementation scope" containing all the
// implementations thus found, for compatibility with old resolve pass.
- fn with_scope<F>(&mut self, name: Option<Name>, f: F)
+ fn with_scope<F>(&mut self, id: NodeId, f: F)
where F: FnOnce(&mut Resolver)
{
let orig_module = self.current_module;
// Move down in the graph.
- match name {
- None => {
- // Nothing to do.
- }
- Some(name) => {
- build_reduced_graph::populate_module_if_necessary(self, &orig_module);
-
- if let Success(name_binding) = orig_module.resolve_name(name, TypeNS, false) {
- match name_binding.module() {
- None => {
- debug!("!!! (with scope) didn't find module for `{}` in `{}`",
- name,
- module_to_string(orig_module));
- }
- Some(module) => {
- self.current_module = module;
- }
- }
- }
- }
+ if let Some(module) = orig_module.module_children.borrow().get(&id) {
+ self.current_module = module;
}
f(self);
}
ItemMod(_) | ItemForeignMod(_) => {
- self.with_scope(Some(name), |this| {
+ self.with_scope(item.id, |this| {
intravisit::walk_item(this, item);
});
}
// Move down in the graph, if there's an anonymous module rooted here.
let orig_module = self.current_module;
let anonymous_module =
- orig_module.anonymous_children.borrow().get(&block.id).map(|module| *module);
+ orig_module.module_children.borrow().get(&block.id).map(|module| *module);
if let Some(anonymous_module) = anonymous_module {
debug!("(resolving block) found anonymous module, moving down");
errors.extend(self.resolve_imports_for_module(module_));
self.resolver.current_module = orig_module;
- build_reduced_graph::populate_module_if_necessary(self.resolver, module_);
- module_.for_each_local_child(|_, _, child_node| {
- match child_node.module() {
- None => {
- // Nothing to do.
- }
- Some(child_module) => {
- errors.extend(self.resolve_imports_for_module_subtree(child_module));
- }
- }
- });
-
- for (_, child_module) in module_.anonymous_children.borrow().iter() {
+ for (_, child_module) in module_.module_children.borrow().iter() {
errors.extend(self.resolve_imports_for_module_subtree(child_module));
}
module_.increment_outstanding_references_for(target, TypeNS);
}
+ match (&value_result, &type_result) {
+ (&Indeterminate, _) | (_, &Indeterminate) => return Indeterminate,
+ (&Failed(_), &Failed(_)) => {
+ let children = target_module.resolutions.borrow();
+ let names = children.keys().map(|&(ref name, _)| name);
+ let lev_suggestion = match find_best_match_for_name(names, &source.as_str(), None) {
+ Some(name) => format!(". Did you mean to use `{}`?", name),
+ None => "".to_owned(),
+ };
+ let msg = format!("There is no `{}` in `{}`{}",
+ source,
+ module_to_string(target_module), lev_suggestion);
+ return Failed(Some((directive.span, msg)));
+ }
+ _ => (),
+ }
+
match (&value_result, &type_result) {
(&Success(name_binding), _) if !name_binding.is_import() &&
directive.is_public &&
_ => {}
}
- match (&value_result, &type_result) {
- (&Indeterminate, _) | (_, &Indeterminate) => return Indeterminate,
- (&Failed(_), &Failed(_)) => {
- let children = target_module.children.borrow();
- let names = children.keys().map(|&(ref name, _)| name);
- let lev_suggestion = match find_best_match_for_name(names, &source.as_str(), None) {
- Some(name) => format!(". Did you mean to use `{}`?", name),
- None => "".to_owned(),
- };
- let msg = format!("There is no `{}` in `{}`{}",
- source,
- module_to_string(target_module), lev_suggestion);
- return Failed(Some((directive.span, msg)));
- }
- _ => (),
- }
-
for &(ns, result) in &[(ValueNS, &value_result), (TypeNS, &type_result)] {
if let Success(binding) = *result {
if !binding.defined_with(DefModifiers::IMPORTABLE) {
build_reduced_graph::populate_module_if_necessary(self.resolver, target_module);
target_module.for_each_child(|name, ns, binding| {
if !binding.defined_with(DefModifiers::IMPORTABLE | DefModifiers::PUBLIC) { return }
+ if binding.is_extern_crate() { return }
self.define(module_, name, ns, directive.import(binding));
if ns == TypeNS && directive.is_public &&
if any_objects {
archive.build();
- cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
+ if dylib {
+ cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
+ } else {
+ cmd.link_rlib(&fix_windows_verbatim_for_gcc(&dst));
+ }
}
});
}
use std::hash::*;
use std::collections::HashSet;
-use syntax::ast::{self, NodeId};
+use syntax::ast::{self, NodeId, PatKind};
use syntax::codemap::*;
use syntax::parse::token::{self, keywords};
use syntax::visit::{self, Visitor};
fn process_pat(&mut self, p: &ast::Pat) {
match p.node {
- ast::PatStruct(ref path, ref fields, _) => {
+ PatKind::Struct(ref path, ref fields, _) => {
visit::walk_path(self, path);
let adt = self.tcx.node_id_to_type(p.id).ty_adt_def().unwrap();
let def = self.tcx.def_map.borrow()[&p.id].full_def();
use rustc::front::map::NodeItem;
use rustc::session::config::CrateType::CrateTypeExecutable;
-use syntax::ast::{self, NodeId};
+use syntax::ast::{self, NodeId, PatKind};
use syntax::ast_util;
use syntax::codemap::*;
use syntax::parse::token::{self, keywords};
impl<'v> Visitor<'v> for PathCollector {
fn visit_pat(&mut self, p: &ast::Pat) {
match p.node {
- ast::PatStruct(ref path, _, _) => {
+ PatKind::Struct(ref path, _, _) => {
self.collected_paths.push((p.id, path.clone(),
ast::Mutability::Mutable, recorder::TypeRef));
}
- ast::PatEnum(ref path, _) |
- ast::PatQPath(_, ref path) => {
+ PatKind::TupleStruct(ref path, _) |
+ PatKind::Path(ref path) |
+ PatKind::QPath(_, ref path) => {
self.collected_paths.push((p.id, path.clone(),
ast::Mutability::Mutable, recorder::VarRef));
}
- ast::PatIdent(bm, ref path1, _) => {
+ PatKind::Ident(bm, ref path1, _) => {
debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
path1.node,
p.span,
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use trans::cabi::FnType;
-use trans::cabi_arm;
+#![allow(non_upper_case_globals)]
+
+use llvm::{Struct, Array, Attribute};
+use trans::cabi::{FnType, ArgType};
use trans::context::CrateContext;
use trans::type_::Type;
+// Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128
+
+// See the https://github.com/kripken/emscripten-fastcomp-clang repository.
+// The class `EmscriptenABIInfo` in `/lib/CodeGen/TargetInfo.cpp` contains the ABI definitions.
+
+fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
+ match ty.kind() {
+ Struct => {
+ let field_types = ty.field_types();
+ if field_types.len() == 1 {
+ ArgType::direct(ty, Some(field_types[0]), None, None)
+ } else {
+ ArgType::indirect(ty, Some(Attribute::StructRet))
+ }
+ },
+ Array => {
+ ArgType::indirect(ty, Some(Attribute::StructRet))
+ },
+ _ => {
+ let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
+ ArgType::direct(ty, None, None, attr)
+ }
+ }
+}
+
+fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
+ if ty.is_aggregate() {
+ ArgType::indirect(ty, Some(Attribute::ByVal))
+ } else {
+ let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
+ ArgType::direct(ty, None, None, attr)
+ }
+}
+
pub fn compute_abi_info(ccx: &CrateContext,
atys: &[Type],
rty: Type,
ret_def: bool) -> FnType {
- cabi_arm::compute_abi_info(ccx, atys, rty, ret_def,
- cabi_arm::Flavor::General)
+ let mut arg_tys = Vec::new();
+ for &aty in atys {
+ let ty = classify_arg_ty(ccx, aty);
+ arg_tys.push(ty);
+ }
+
+ let ret_ty = if ret_def {
+ classify_ret_ty(ccx, rty)
+ } else {
+ ArgType::direct(Type::void(ccx), None, None, None)
+ };
+
+ return FnType {
+ arg_tys: arg_tys,
+ ret_ty: ret_ty,
+ };
}
.tcx()
.lang_items
.require(ExchangeMallocFnLangItem)
- .expect("Could not find ExchangeMallocFnLangItem");
+ .unwrap_or_else(|e| self.ccx.sess().fatal(&e));
assert!(can_have_local_instance(self.ccx, exchange_malloc_fn_def_id));
let exchange_malloc_fn_trans_item =
let exchange_free_fn_def_id = ccx.tcx()
.lang_items
.require(ExchangeFreeFnLangItem)
- .expect("Could not find ExchangeFreeFnLangItem");
+ .unwrap_or_else(|e| ccx.sess().fatal(&e));
assert!(can_have_local_instance(ccx, exchange_free_fn_def_id));
let exchange_free_fn_trans_item =
// Currently, we use a fulfillment context to completely resolve
// all nested obligations. This is because they can inform the
// inference of the impl's type parameters.
- let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+ let mut fulfill_cx = traits::FulfillmentContext::new();
let vtable = selection.map(|predicate| {
fulfill_cx.register_predicate_obligation(&infcx, predicate);
});
let tcx = ccx.tcx();
let infcx = infer::normalizing_infer_ctxt(tcx, &tcx.tables);
let mut selcx = traits::SelectionContext::new(&infcx);
- let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+ let mut fulfill_cx = traits::FulfillmentContext::new();
let cause = traits::ObligationCause::dummy();
let traits::Normalized { value: predicates, obligations } =
traits::normalize(&mut selcx, cause.clone(), &predicates);
expected_vid: ty::TyVid)
-> (Option<ty::FnSig<'tcx>>, Option<ty::ClosureKind>)
{
- let fulfillment_cx = fcx.inh.infcx.fulfillment_cx.borrow();
+ let fulfillment_cx = fcx.inh.fulfillment_cx.borrow();
// Here `expected_ty` is known to be a type inference variable.
let expected_sig =
impl_trait_ref);
let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
- let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
+ let mut fulfillment_cx = traits::FulfillmentContext::new();
let trait_to_impl_substs = &impl_trait_ref.substs;
impl_trait_ref);
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
- let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
+ let mut fulfillment_cx = traits::FulfillmentContext::new();
// The below is for the most part highly similar to the procedure
// for methods above. It is simpler in many respects, especially
let impl_param_env = ty::ParameterEnvironment::for_item(tcx, self_type_node_id);
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(impl_param_env));
+ let mut fulfillment_cx = traits::FulfillmentContext::new();
let named_type = tcx.lookup_item_type(self_type_did).ty;
let named_type = named_type.subst(tcx, &infcx.parameter_environment.free_substs);
return Err(());
}
- if let Err(ref errors) = infcx.fulfillment_cx.borrow_mut().select_all_or_error(&infcx) {
+ if let Err(ref errors) = fulfillment_cx.select_all_or_error(&infcx) {
// this could be reached when we get lazy normalization
traits::report_fulfillment_errors(&infcx, errors);
return Err(());
infcx: infer::InferCtxt<'a, 'tcx>,
locals: RefCell<NodeMap<Ty<'tcx>>>,
+ fulfillment_cx: RefCell<traits::FulfillmentContext<'tcx>>,
+
tables: &'a RefCell<ty::Tables<'tcx>>,
// When we process a call like `c()` where `c` is a closure type,
Inherited {
infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env)),
+ fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
locals: RefCell::new(NodeMap()),
tables: tables,
deferred_call_resolutions: RefCell::new(DefIdMap()),
-> T
where T : TypeFoldable<'tcx>
{
- let mut fulfillment_cx = self.infcx.fulfillment_cx.borrow_mut();
assoc::normalize_associated_types_in(&self.infcx,
- &mut fulfillment_cx,
+ &mut self.fulfillment_cx.borrow_mut(),
span,
body_id,
value)
self.body_id,
traits::ObligationCauseCode::MiscObligation);
self.inh
- .infcx
.fulfillment_cx
.borrow_mut()
.normalize_projection_type(self.infcx(),
builtin_bound: ty::BuiltinBound,
cause: traits::ObligationCause<'tcx>)
{
- self.inh.infcx.fulfillment_cx.borrow_mut()
+ self.inh.fulfillment_cx.borrow_mut()
.register_builtin_bound(self.infcx(), ty, builtin_bound, cause);
}
{
debug!("register_predicate({:?})",
obligation);
- self.inh.infcx.fulfillment_cx
+ self.inh.fulfillment_cx
.borrow_mut()
.register_predicate_obligation(self.infcx(), obligation);
}
region: ty::Region,
cause: traits::ObligationCause<'tcx>)
{
- let mut fulfillment_cx = self.inh.infcx.fulfillment_cx.borrow_mut();
+ let mut fulfillment_cx = self.inh.fulfillment_cx.borrow_mut();
fulfillment_cx.register_region_obligation(ty, region, cause);
}
self.select_all_obligations_and_apply_defaults();
- let mut fulfillment_cx = self.inh.infcx.fulfillment_cx.borrow_mut();
+ let mut fulfillment_cx = self.inh.fulfillment_cx.borrow_mut();
match fulfillment_cx.select_all_or_error(self.infcx()) {
Ok(()) => { }
Err(errors) => { report_fulfillment_errors(self.infcx(), &errors); }
/// Select as many obligations as we can at present.
fn select_obligations_where_possible(&self) {
match
- self.inh.infcx.fulfillment_cx
+ self.inh.fulfillment_cx
.borrow_mut()
.select_where_possible(self.infcx())
{
/// for examples of where this comes up,.
fn rvalue_hint(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
match tcx.struct_tail(ty).sty {
- ty::TySlice(_) | ty::TyTrait(..) => {
+ ty::TySlice(_) | ty::TyStr | ty::TyTrait(..) => {
ExpectRvalueLikeUnsized(ty)
}
_ => ExpectHasType(ty)
let region_obligations =
self.fcx
.inh
- .infcx
.fulfillment_cx
.borrow()
.region_obligations(node_id)
// Processing the region obligations should not cause the list to grow further:
assert_eq!(region_obligations.len(),
- self.fcx.inh.infcx.fulfillment_cx.borrow().region_obligations(node_id).len());
+ self.fcx.inh.fulfillment_cx.borrow().region_obligations(node_id).len());
}
fn code_to_origin(&self,
}
};
- let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+ let mut fulfill_cx = traits::FulfillmentContext::new();
// Register an obligation for `A: Trait<B>`.
let cause = traits::ObligationCause::misc(span, impl_node_id);
fn clean(&self, cx: &DocContext) -> Item {
let inner = match self.node {
hir::ImplItemKind::Const(ref ty, ref expr) => {
- ConstantItem(Constant{
- type_: ty.clean(cx),
- expr: expr.span.to_src(cx),
- })
+ AssociatedConstItem(ty.clean(cx),
+ Some(expr.span.to_src(cx)))
}
hir::ImplItemKind::Method(ref sig, _) => {
MethodItem(sig.clean(cx))
<p>
Search functions by type signature (e.g.
- <code>vec -> usize</code>)
+ <code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
ty: shortty(item),
name: item.name.clone().unwrap(),
path: fqp[..fqp.len() - 1].join("::"),
- desc: shorter(item.doc_value()),
+ desc: Escape(&shorter(item.doc_value())).to_string(),
parent: Some(did),
search_type: get_index_search_type(&item, parent_basename),
});
ty: shortty(&item),
name: s.to_string(),
path: path.join("::").to_string(),
- desc: shorter(item.doc_value()),
+ desc: Escape(&shorter(item.doc_value())).to_string(),
parent: parent,
search_type: get_index_search_type(&item, parent_basename),
});
true, |component| {
path.push(component.to_string());
});
- Some(format!("{root}src/{krate}/{path}.html#{href}",
- root = self.cx.root_path,
- krate = self.cx.layout.krate,
- path = path.join("/"),
- href = href))
+ // If the span points into an external macro the
+ // source-file will be bogus, i.e `<foo macros>`
+ if Path::new(&self.item.source.filename).is_file() {
+ Some(format!("{root}src/{krate}/{path}.html#{href}",
+ root = self.cx.root_path,
+ krate = self.cx.layout.krate,
+ path = path.join("/"),
+ href = href))
+ } else {
+ None
+ }
// If this item is not part of the local crate, then things get a little
// trickier. We don't actually know the span of the external item, but
#[inline]
fn plain_summary_line(s: Option<&str>) -> String {
- let line = shorter(s).replace("\n", " ");
- markdown::plain_summary_line(&line[..])
+ let md = markdown::plain_summary_line(s.unwrap_or(""));
+ shorter(Some(&md)).replace("\n", " ")
}
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
} else {
String::new()
};
+ let doc_value = myitem.doc_value().unwrap_or("");
try!(write!(w, "
<tr class='{stab} module-item'>
<td><a class='{class}' href='{href}'
",
name = *myitem.name.as_ref().unwrap(),
stab_docs = stab_docs,
- docs = Markdown(&shorter(myitem.doc_value())),
+ docs = shorter(Some(&Markdown(doc_value).to_string())),
class = shortty(myitem),
stab = myitem.stability_class(),
href = item_path(myitem),
}
}
clean::TypedefItem(ref tydef, _) => {
- let id = derive_id(format!("assoc_type.{}", name));
+ let id = derive_id(format!("associatedtype.{}", name));
try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(write!(w, "type {} = {}", name, tydef.type_));
try!(write!(w, "</code></h4>\n"));
}
clean::AssociatedConstItem(ref ty, ref default) => {
- let id = derive_id(format!("assoc_const.{}", name));
+ let id = derive_id(format!("associatedconstant.{}", name));
try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(assoc_const(w, item, ty, default.as_ref()));
try!(write!(w, "</code></h4>\n"));
}
clean::ConstantItem(ref c) => {
- let id = derive_id(format!("assoc_const.{}", name));
+ let id = derive_id(format!("associatedconstant.{}", name));
try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(assoc_const(w, item, &c.type_, Some(&c.expr)));
try!(write!(w, "</code></h4>\n"));
}
clean::AssociatedTypeItem(ref bounds, ref default) => {
- let id = derive_id(format!("assoc_type.{}", name));
+ let id = derive_id(format!("associatedtype.{}", name));
try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(assoc_type(w, item, bounds, default));
try!(write!(w, "</code></h4>\n"));
var parts = val.split("->").map(trimmer);
var input = parts[0];
// sort inputs so that order does not matter
- var inputs = input.split(",").map(trimmer).sort();
+ var inputs = input.split(",").map(trimmer).sort().toString();
var output = parts[1];
for (var i = 0; i < nSearchWords; ++i) {
// allow searching for void (no output) functions as well
var typeOutput = type.output ? type.output.name : "";
- if (inputs.toString() === typeInputs.toString() &&
- output == typeOutput) {
+ if ((inputs === "*" || inputs === typeInputs.toString()) &&
+ (output === "*" || output == typeOutput)) {
results.push({id: i, index: -1, dontValidate: true});
}
}
#[stable(feature = "rust1", since = "1.0.0")]
type Owned;
- /// Checks if within the ASCII range.
+ /// Checks if the value is within the ASCII range.
///
/// # Examples
///
/// let ascii = 'a';
/// let utf8 = '❤';
///
- /// assert_eq!(true, ascii.is_ascii());
- /// assert_eq!(false, utf8.is_ascii())
+ /// assert!(ascii.is_ascii());
+ /// assert!(!utf8.is_ascii());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn is_ascii(&self) -> bool;
/// let ascii3 = 'A';
/// let ascii4 = 'z';
///
- /// assert_eq!(true, ascii1.eq_ignore_ascii_case(&ascii2));
- /// assert_eq!(true, ascii1.eq_ignore_ascii_case(&ascii3));
- /// assert_eq!(false, ascii1.eq_ignore_ascii_case(&ascii4));
+ /// assert!(ascii1.eq_ignore_ascii_case(&ascii2));
+ /// assert!(ascii1.eq_ignore_ascii_case(&ascii3));
+ /// assert!(!ascii1.eq_ignore_ascii_case(&ascii4));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn eq_ignore_ascii_case(&self, other: &Self) -> bool;
"foo");
}
+ #[test]
+ fn read_link() {
+ if cfg!(windows) {
+ // directory symlink
+ assert_eq!(check!(fs::read_link(r"C:\Users\All Users")).to_str().unwrap(),
+ r"C:\ProgramData");
+ // junction
+ assert_eq!(check!(fs::read_link(r"C:\Users\Default User")).to_str().unwrap(),
+ r"C:\Users\Default");
+ // junction with special permissions
+ assert_eq!(check!(fs::read_link(r"C:\Documents and Settings\")).to_str().unwrap(),
+ r"C:\Users");
+ }
+ let tmpdir = tmpdir();
+ let link = tmpdir.join("link");
+ if !got_symlink_permission(&tmpdir) { return };
+ check!(symlink_file(&"foo", &link));
+ assert_eq!(check!(fs::read_link(&link)).to_str().unwrap(), "foo");
+ }
+
#[test]
fn readlink_not_symlink() {
let tmpdir = tmpdir();
/// This macro takes any number of comma-separated identifiers, and
/// concatenates them all into one, yielding an expression which is a new
/// identifier. Note that hygiene makes it such that this macro cannot
- /// capture local variables, and macros are only allowed in item,
- /// statement or expression position, meaning this macro may be difficult to
- /// use in some situations.
+ /// capture local variables. Also, as a general rule, macros are only
+ /// allowed in item, statement or expression position. That means while
+ /// you may use this macro for referring to existing variables, functions or
+ /// modules etc, you cannot define a new one with it.
///
/// # Examples
///
///
/// let f = concat_idents!(foo, bar);
/// println!("{}", f());
+ ///
+ /// // fn concat_idents!(new, fun, name) { } // not usable in this way!
/// # }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::android::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! Android-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t};
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type dev_t = u32;
+ pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type mode_t = u16;
+ pub type mode_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type blkcnt_t = u32;
+ pub type blkcnt_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type blksize_t = u32;
+ pub type blksize_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type ino_t = u32;
+ pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type nlink_t = u16;
+ pub type nlink_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type off_t = i32;
+ pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type time_t = i32;
+ pub type time_t = i64;
#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad0: [c_uchar; 4],
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub __st_ino: ino_t,
+ pub __st_ino: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mode: c_uint,
#[stable(feature = "raw_ext", since = "1.1.0")]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_size: c_longlong,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blocks: c_ulonglong,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub type blkcnt_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type blksize_t = u32;
+ pub type blksize_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type nlink_t = u32;
+ pub type nlink_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub type off_t = i64;
+ pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub type time_t = i64;
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::bitrig::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_flags(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gen(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_birthtime(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime as i64
+ }
+ fn st_birthtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+ fn st_gen(&self) -> u32 {
+ self.as_inner().as_inner().st_gen as u32
+ }
+ fn st_flags(&self) -> u32 {
+ self.as_inner().as_inner().st_flags as u32
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! Bitrig-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t};
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime_nsec: c_long,
+ pub st_atime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime_nsec: c_long,
+ pub st_mtime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime_nsec: c_long,
+ pub st_ctime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_flags: fflags_t,
+ pub st_flags: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gen: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime: time_t,
+ pub st_birthtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime_nsec: c_long,
+ pub st_birthtime_nsec: i64,
}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::dragonfly::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_flags(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gen(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_lspare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_birthtime(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime as i64
+ }
+ fn st_birthtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+ fn st_gen(&self) -> u32 {
+ self.as_inner().as_inner().st_gen as u32
+ }
+ fn st_flags(&self) -> u32 {
+ self.as_inner().as_inner().st_flags as u32
+ }
+ fn st_lspare(&self) -> u32 {
+ self.as_inner().as_inner().st_lspare as u32
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! Dragonfly-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t};
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_dev: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_ino: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_mode: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_nlink: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_padding1: u16,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_rdev: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_atime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime_nsec: c_long,
+ pub st_mtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime_nsec: c_long,
+ pub st_ctime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime_nsec: c_long,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blksize: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_flags: fflags_t,
+ pub st_flags: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gen: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_lspare: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_qspare1: i64,
+ pub st_birthtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_qspare2: i64,
+ pub st_birthtime_nsec: i64,
}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::freebsd::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_flags(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gen(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_lspare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_birthtime(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime as i64
+ }
+ fn st_birthtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+ fn st_gen(&self) -> u32 {
+ self.as_inner().as_inner().st_gen as u32
+ }
+ fn st_flags(&self) -> u32 {
+ self.as_inner().as_inner().st_flags as u32
+ }
+ fn st_lspare(&self) -> u32 {
+ self.as_inner().as_inner().st_lspare as u32
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! FreeBSD-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t};
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime_nsec: c_long,
+ pub st_atime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime_nsec: c_long,
+ pub st_mtime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime_nsec: c_long,
+ pub st_ctime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_flags: fflags_t,
+ pub st_flags: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gen: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_lspare: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime: time_t,
+ pub st_birthtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime_nsec: c_long,
+ pub st_birthtime_nsec: i64,
}
}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::ios::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_flags(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gen(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_lspare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_birthtime(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime as i64
+ }
+ fn st_birthtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+ fn st_gen(&self) -> u32 {
+ self.as_inner().as_inner().st_gen as u32
+ }
+ fn st_flags(&self) -> u32 {
+ self.as_inner().as_inner().st_flags as u32
+ }
+ fn st_lspare(&self) -> u32 {
+ self.as_inner().as_inner().st_lspare as u32
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! iOS-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime: time_t,
+ pub st_birthtime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_birthtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_flags: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::linux::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat64
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+}
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! Linux-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_ulong;
target_arch = "arm",
target_arch = "asmjs"))]
mod arch {
- use super::{dev_t, mode_t};
- use os::raw::{c_long, c_short};
- use os::unix::raw::{gid_t, uid_t};
+ use os::raw::{c_long, c_short, c_uint};
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-
- #[stable(feature = "raw_ext", since = "1.1.0")]
- #[cfg(not(any(target_env = "musl", target_arch = "asmjs")))]
- pub type ino_t = u32;
- #[stable(feature = "raw_ext", since = "1.1.0")]
- #[cfg(any(target_env = "musl", target_arch = "asmjs"))]
- pub type ino_t = u64;
-
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad1: c_short,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub __st_ino: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub __pad2: c_short,
+ pub __pad2: c_uint,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub __unused4: c_long,
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub __unused5: c_long,
+ pub st_ino: u64,
}
}
#[cfg(target_arch = "mips")]
mod arch {
- use super::mode_t;
use os::raw::{c_long, c_ulong};
- use os::unix::raw::{gid_t, uid_t};
#[cfg(target_env = "musl")]
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
#[cfg(not(target_env = "musl"))]
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
#[cfg(target_env = "musl")]
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[cfg(not(target_env = "musl"))]
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
#[cfg(target_env = "musl")]
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[cfg(not(target_env = "musl"))]
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_pad1: [c_long; 3],
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_rdev: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_pad2: [c_long; 2],
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_pad3: c_long,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_pad5: [c_long; 14],
}
#[cfg(target_arch = "aarch64")]
mod arch {
- use super::{dev_t, mode_t};
use os::raw::{c_long, c_int};
- use os::unix::raw::{gid_t, uid_t};
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[repr(C)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub __pad1: dev_t,
+ pub __pad1: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad2: c_int,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
#[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))]
mod arch {
- use super::{dev_t, mode_t};
use os::raw::{c_long, c_int};
- use os::unix::raw::{gid_t, uid_t};
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
- #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+ #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[repr(C)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad0: c_int,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::macos::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_flags(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gen(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_lspare(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_qspare(&self) -> [u64; 2];
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_birthtime(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime as i64
+ }
+ fn st_birthtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+ fn st_gen(&self) -> u32 {
+ self.as_inner().as_inner().st_gen as u32
+ }
+ fn st_flags(&self) -> u32 {
+ self.as_inner().as_inner().st_flags as u32
+ }
+ fn st_lspare(&self) -> u32 {
+ self.as_inner().as_inner().st_lspare as u32
+ }
+ fn st_qspare(&self) -> [u64; 2] {
+ let qspare = self.as_inner().as_inner().st_qspare;
+ [qspare[0] as u64, qspare[1] as u64]
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! MacOS-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u16,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime: time_t,
+ pub st_birthtime: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_birthtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_flags: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::nacl::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat64
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+}
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! Nacl-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::netbsd::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_flags(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gen(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_spare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_birthtime(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime as i64
+ }
+ fn st_birthtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+ fn st_gen(&self) -> u32 {
+ self.as_inner().as_inner().st_gen as u32
+ }
+ fn st_flags(&self) -> u32 {
+ self.as_inner().as_inner().st_flags as u32
+ }
+ fn st_spare(&self) -> u32 {
+ self.as_inner().as_inner().st_spare as u32
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! NetBSD-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t};
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_dev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_mode: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime: time_t,
+ pub st_birthtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_birthtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_flags: fflags_t,
+ pub st_flags: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gen: u32,
st_spare: [u32; 2],
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::openbsd::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_birthtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_flags(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gen(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_birthtime(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime as i64
+ }
+ fn st_birthtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_birthtime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+ fn st_gen(&self) -> u32 {
+ self.as_inner().as_inner().st_gen as u32
+ }
+ fn st_flags(&self) -> u32 {
+ self.as_inner().as_inner().st_flags as u32
+ }
+}
+
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! OpenBSD-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mode: mode_t,
+ pub st_mode: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_dev: dev_t,
+ pub st_dev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ino: ino_t,
+ pub st_ino: u64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_nlink: nlink_t,
+ pub st_nlink: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_uid: uid_t,
+ pub st_uid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_gid: gid_t,
+ pub st_gid: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_rdev: dev_t,
+ pub st_rdev: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_atime: time_t,
+ pub st_atime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_mtime: time_t,
+ pub st_mtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_ctime: time_t,
+ pub st_ctime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_size: off_t,
+ pub st_size: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blocks: blkcnt_t,
+ pub st_blocks: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_blksize: blksize_t,
+ pub st_blksize: i32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_flags: fflags_t,
+ pub st_flags: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gen: u32,
#[stable(feature = "raw_ext", since = "1.1.0")]
- pub st_birthtime: time_t,
+ pub st_birthtime: i64,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_birthtime_nsec: c_long,
}
)*}
}
- macro_rules! ok_size {
- ($($t:ident)*) => {$(
- assert!(mem::size_of::<libc::$t>() == mem::size_of::<raw::$t>(),
- "{} is wrong", stringify!($t));
- )*}
- }
-
#[test]
fn same() {
use os::raw;
ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
c_longlong c_ulonglong c_float c_double);
}
-
- #[cfg(all(unix, not(target_os = "android")))]
- #[test]
- fn unix() {
- {
- use os::unix::raw;
- ok!(uid_t gid_t dev_t ino_t mode_t nlink_t off_t blksize_t blkcnt_t);
- }
- {
- use sys::platform::raw;
- ok_size!(stat);
- }
- }
-
- #[cfg(windows)]
- #[test]
- fn windows() {
- use os::windows::raw;
- }
}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::solaris::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+ /// Gain a reference to the underlying `stat` structure which contains
+ /// the raw information returned by the OS.
+ ///
+ /// The contents of the returned `stat` are **not** consistent across
+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+ /// cross-Unix abstractions contained within the raw stat.
+ #[stable(feature = "metadata_ext", since = "1.1.0")]
+ #[rustc_deprecated(since = "1.8.0",
+ reason = "deprecated in favor of the accessor \
+ methods of this trait")]
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat;
+
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_dev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ino(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mode(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_nlink(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_uid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_gid(&self) -> u32;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_rdev(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_size(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_atime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_mtime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_ctime_nsec(&self) -> i64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blksize(&self) -> u64;
+ #[stable(feature = "metadata_ext2", since = "1.8.0")]
+ fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+ #[allow(deprecated)]
+ fn as_raw_stat(&self) -> &raw::stat {
+ unsafe {
+ &*(self.as_inner().as_inner() as *const libc::stat64
+ as *const raw::stat)
+ }
+ }
+ fn st_dev(&self) -> u64 {
+ self.as_inner().as_inner().st_dev as u64
+ }
+ fn st_ino(&self) -> u64 {
+ self.as_inner().as_inner().st_ino as u64
+ }
+ fn st_mode(&self) -> u32 {
+ self.as_inner().as_inner().st_mode as u32
+ }
+ fn st_nlink(&self) -> u64 {
+ self.as_inner().as_inner().st_nlink as u64
+ }
+ fn st_uid(&self) -> u32 {
+ self.as_inner().as_inner().st_uid as u32
+ }
+ fn st_gid(&self) -> u32 {
+ self.as_inner().as_inner().st_gid as u32
+ }
+ fn st_rdev(&self) -> u64 {
+ self.as_inner().as_inner().st_rdev as u64
+ }
+ fn st_size(&self) -> u64 {
+ self.as_inner().as_inner().st_size as u64
+ }
+ fn st_atime(&self) -> i64 {
+ self.as_inner().as_inner().st_atime as i64
+ }
+ fn st_atime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_atime_nsec as i64
+ }
+ fn st_mtime(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime as i64
+ }
+ fn st_mtime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_mtime_nsec as i64
+ }
+ fn st_ctime(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime as i64
+ }
+ fn st_ctime_nsec(&self) -> i64 {
+ self.as_inner().as_inner().st_ctime_nsec as i64
+ }
+ fn st_blksize(&self) -> u64 {
+ self.as_inner().as_inner().st_blksize as u64
+ }
+ fn st_blocks(&self) -> u64 {
+ self.as_inner().as_inner().st_blocks as u64
+ }
+}
#![stable(feature = "raw_ext", since = "1.1.0")]
pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
- #[stable(feature = "raw_ext", since = "1.1.0")]
- pub use sys::fs::MetadataExt;
-}
+pub mod fs;
//! Solaris-specific raw type definitions
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t};
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`]}. The marker
//! traits indicate fundamental properties of types.
//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}. Various
-//! operations for both destuctors and overloading `()`.
+//! operations for both destructors and overloading `()`.
//! * [`std::mem`]::[`drop`], a convenience function for explicitly dropping a
//! value.
//! * [`std::boxed`]::[`Box`], a way to allocate values on the heap.
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Send + Reflect> Error for PoisonError<T> {
+impl<T: Reflect> Error for PoisonError<T> {
fn description(&self) -> &str {
"poisoned lock: another task failed inside"
}
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Send + Reflect> fmt::Display for TryLockError<T> {
+impl<T> fmt::Display for TryLockError<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.description().fmt(f)
+ match *self {
+ TryLockError::Poisoned(..) => "poisoned lock: another task failed inside",
+ TryLockError::WouldBlock => "try_lock failed because the operation would block"
+ }.fmt(f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Send + Reflect> Error for TryLockError<T> {
+impl<T: Reflect> Error for TryLockError<T> {
fn description(&self) -> &str {
match *self {
TryLockError::Poisoned(ref p) => p.description(),
use fs::{self, Permissions, OpenOptions};
use io;
use libc;
-use os::raw::c_long;
+#[allow(deprecated)]
use os::unix::raw;
use path::Path;
-use sys::fs::MetadataExt as UnixMetadataExt;
use sys;
use sys_common::{FromInner, AsInner, AsInnerMut};
+use sys::platform::fs::MetadataExt as UnixMetadataExt;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const USER_READ: raw::mode_t = 0o400;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const USER_WRITE: raw::mode_t = 0o200;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const USER_EXECUTE: raw::mode_t = 0o100;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const USER_RWX: raw::mode_t = 0o700;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const GROUP_READ: raw::mode_t = 0o040;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const GROUP_WRITE: raw::mode_t = 0o020;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const GROUP_EXECUTE: raw::mode_t = 0o010;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const GROUP_RWX: raw::mode_t = 0o070;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const OTHER_READ: raw::mode_t = 0o004;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const OTHER_WRITE: raw::mode_t = 0o002;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const OTHER_EXECUTE: raw::mode_t = 0o001;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const OTHER_RWX: raw::mode_t = 0o007;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const ALL_READ: raw::mode_t = 0o444;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const ALL_WRITE: raw::mode_t = 0o222;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const ALL_EXECUTE: raw::mode_t = 0o111;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const ALL_RWX: raw::mode_t = 0o777;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const SETUID: raw::mode_t = 0o4000;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const SETGID: raw::mode_t = 0o2000;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
pub const STICKY_BIT: raw::mode_t = 0o1000;
/// Unix-specific extensions to `Permissions`
/// Returns the underlying raw `mode_t` bits that are the standard Unix
/// permissions for this file.
#[stable(feature = "fs_ext", since = "1.1.0")]
- fn mode(&self) -> raw::mode_t;
+ fn mode(&self) -> u32;
- /// Sets the underlying raw `mode_t` bits for this set of permissions.
+ /// Sets the underlying raw bits for this set of permissions.
#[stable(feature = "fs_ext", since = "1.1.0")]
- fn set_mode(&mut self, mode: raw::mode_t);
+ fn set_mode(&mut self, mode: u32);
/// Creates a new instance of `Permissions` from the given set of Unix
/// permission bits.
#[stable(feature = "fs_ext", since = "1.1.0")]
- fn from_mode(mode: raw::mode_t) -> Self;
+ fn from_mode(mode: u32) -> Self;
}
#[stable(feature = "fs_ext", since = "1.1.0")]
impl PermissionsExt for Permissions {
- fn mode(&self) -> raw::mode_t { self.as_inner().mode() }
+ fn mode(&self) -> u32 {
+ self.as_inner().mode()
+ }
- fn set_mode(&mut self, mode: raw::mode_t) {
- *self = FromInner::from_inner(FromInner::from_inner(mode));
+ fn set_mode(&mut self, mode: u32) {
+ *self = Permissions::from_inner(FromInner::from_inner(mode));
}
- fn from_mode(mode: raw::mode_t) -> Permissions {
- FromInner::from_inner(FromInner::from_inner(mode))
+ fn from_mode(mode: u32) -> Permissions {
+ Permissions::from_inner(FromInner::from_inner(mode))
}
}
/// The operating system masks out bits with the systems `umask`, to produce
/// the final permissions.
#[stable(feature = "fs_ext", since = "1.1.0")]
- fn mode(&mut self, mode: raw::mode_t) -> &mut Self;
+ fn mode(&mut self, mode: u32) -> &mut Self;
/// Pass custom flags to the `flags` agument of `open`.
///
#[stable(feature = "fs_ext", since = "1.1.0")]
impl OpenOptionsExt for OpenOptions {
- fn mode(&mut self, mode: raw::mode_t) -> &mut OpenOptions {
+ fn mode(&mut self, mode: u32) -> &mut OpenOptions {
self.as_inner_mut().mode(mode); self
}
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn dev(&self) -> raw::dev_t;
+ fn dev(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn ino(&self) -> raw::ino_t;
+ fn ino(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn mode(&self) -> raw::mode_t;
+ fn mode(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn nlink(&self) -> raw::nlink_t;
+ fn nlink(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn uid(&self) -> raw::uid_t;
+ fn uid(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn gid(&self) -> raw::gid_t;
+ fn gid(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn rdev(&self) -> raw::dev_t;
+ fn rdev(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn size(&self) -> raw::off_t;
+ fn size(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn atime(&self) -> raw::time_t;
+ fn atime(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn atime_nsec(&self) -> c_long;
+ fn atime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn mtime(&self) -> raw::time_t;
+ fn mtime(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn mtime_nsec(&self) -> c_long;
+ fn mtime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn ctime(&self) -> raw::time_t;
+ fn ctime(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn ctime_nsec(&self) -> c_long;
+ fn ctime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn blksize(&self) -> raw::blksize_t;
+ fn blksize(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
- fn blocks(&self) -> raw::blkcnt_t;
+ fn blocks(&self) -> u64;
}
#[stable(feature = "metadata_ext", since = "1.1.0")]
impl MetadataExt for fs::Metadata {
- fn dev(&self) -> raw::dev_t { self.as_raw_stat().st_dev as raw::dev_t }
- fn ino(&self) -> raw::ino_t { self.as_raw_stat().st_ino as raw::ino_t }
- fn mode(&self) -> raw::mode_t { self.as_raw_stat().st_mode as raw::mode_t }
- fn nlink(&self) -> raw::nlink_t { self.as_raw_stat().st_nlink as raw::nlink_t }
- fn uid(&self) -> raw::uid_t { self.as_raw_stat().st_uid as raw::uid_t }
- fn gid(&self) -> raw::gid_t { self.as_raw_stat().st_gid as raw::gid_t }
- fn rdev(&self) -> raw::dev_t { self.as_raw_stat().st_rdev as raw::dev_t }
- fn size(&self) -> raw::off_t { self.as_raw_stat().st_size as raw::off_t }
- fn atime(&self) -> raw::time_t { self.as_raw_stat().st_atime }
- fn atime_nsec(&self) -> c_long { self.as_raw_stat().st_atime_nsec as c_long }
- fn mtime(&self) -> raw::time_t { self.as_raw_stat().st_mtime }
- fn mtime_nsec(&self) -> c_long { self.as_raw_stat().st_mtime_nsec as c_long }
- fn ctime(&self) -> raw::time_t { self.as_raw_stat().st_ctime }
- fn ctime_nsec(&self) -> c_long { self.as_raw_stat().st_ctime_nsec as c_long }
-
- fn blksize(&self) -> raw::blksize_t {
- self.as_raw_stat().st_blksize as raw::blksize_t
- }
- fn blocks(&self) -> raw::blkcnt_t {
- self.as_raw_stat().st_blocks as raw::blkcnt_t
- }
+ fn dev(&self) -> u64 { self.st_dev() }
+ fn ino(&self) -> u64 { self.st_ino() }
+ fn mode(&self) -> u32 { self.st_mode() }
+ fn nlink(&self) -> u64 { self.st_nlink() }
+ fn uid(&self) -> u32 { self.st_uid() }
+ fn gid(&self) -> u32 { self.st_gid() }
+ fn rdev(&self) -> u64 { self.st_rdev() }
+ fn size(&self) -> u64 { self.st_size() }
+ fn atime(&self) -> i64 { self.st_atime() }
+ fn atime_nsec(&self) -> i64 { self.st_atime_nsec() }
+ fn mtime(&self) -> i64 { self.st_mtime() }
+ fn mtime_nsec(&self) -> i64 { self.st_mtime_nsec() }
+ fn ctime(&self) -> i64 { self.st_ctime() }
+ fn ctime_nsec(&self) -> i64 { self.st_ctime_nsec() }
+ fn blksize(&self) -> u64 { self.st_blksize() }
+ fn blocks(&self) -> u64 { self.st_blocks() }
}
/// Add special unix types (block/char device, fifo and socket)
/// Returns the underlying `d_ino` field in the contained `dirent`
/// structure.
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
- fn ino(&self) -> raw::ino_t;
+ fn ino(&self) -> u64;
}
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
impl DirEntryExt for fs::DirEntry {
- fn ino(&self) -> raw::ino_t { self.as_inner().ino() }
+ fn ino(&self) -> u64 { self.as_inner().ino() }
}
/// Creates a new symbolic link on the filesystem.
/// Sets the mode to create new directories with. This option defaults to
/// 0o777.
#[stable(feature = "dir_builder", since = "1.6.0")]
- fn mode(&mut self, mode: raw::mode_t) -> &mut Self;
+ fn mode(&mut self, mode: u32) -> &mut Self;
}
#[stable(feature = "dir_builder", since = "1.6.0")]
impl DirBuilderExt for fs::DirBuilder {
- fn mode(&mut self, mode: raw::mode_t) -> &mut fs::DirBuilder {
+ fn mode(&mut self, mode: u32) -> &mut fs::DirBuilder {
self.as_inner_mut().set_mode(mode);
self
}
use io;
use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
-use os::unix::raw::{uid_t, gid_t};
use process;
use sys;
use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
/// `setuid` call in the child process. Failure in the `setuid`
/// call will cause the spawn to fail.
#[stable(feature = "rust1", since = "1.0.0")]
- fn uid(&mut self, id: uid_t) -> &mut process::Command;
+ fn uid(&mut self, id: u32) -> &mut process::Command;
/// Similar to `uid`, but sets the group id of the child process. This has
/// the same semantics as the `uid` field.
#[stable(feature = "rust1", since = "1.0.0")]
- fn gid(&mut self, id: gid_t) -> &mut process::Command;
+ fn gid(&mut self, id: u32) -> &mut process::Command;
/// Create a new session (cf. `setsid(2)`) for the child process. This means
/// that the child is the leader of a new process group. The parent process
#[stable(feature = "rust1", since = "1.0.0")]
impl CommandExt for process::Command {
- fn uid(&mut self, id: uid_t) -> &mut process::Command {
+ fn uid(&mut self, id: u32) -> &mut process::Command {
self.as_inner_mut().uid(id);
self
}
- fn gid(&mut self, id: gid_t) -> &mut process::Command {
+ fn gid(&mut self, id: u32) -> &mut process::Command {
self.as_inner_mut().gid(id);
self
}
//! Unix-specific primitives available on all unix platforms
#![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+ reason = "these type aliases are no longer supported by \
+ the standard library, the `libc` crate on \
+ crates.io should be used instead for the correct \
+ definitions")]
+#![allow(deprecated)]
#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
#![unstable(feature = "thread_extensions", issue = "29791")]
-use os::unix::raw::{pthread_t};
+#[allow(deprecated)]
+use os::unix::raw::pthread_t;
use sys_common::{AsInner, IntoInner};
-use thread::{JoinHandle};
+use thread::JoinHandle;
#[unstable(feature = "thread_extensions", issue = "29791")]
+#[allow(deprecated)]
pub type RawPthread = pthread_t;
/// Unix-specific extensions to `std::thread::JoinHandle`
use ptr;
use sync::Arc;
use sys::fd::FileDesc;
-use sys::platform::raw;
use sys::time::SystemTime;
use sys::{cvt, cvt_r};
use sys_common::{AsInner, FromInner};
+#[cfg(target_os = "linux")]
+use libc::{stat64, fstat64, lstat64};
+#[cfg(not(target_os = "linux"))]
+use libc::{stat as stat64, fstat as fstat64, lstat as lstat64};
+
pub struct File(FileDesc);
#[derive(Clone)]
pub struct FileAttr {
- stat: raw::stat,
+ stat: stat64,
}
pub struct ReadDir {
impl FileAttr {
pub fn modified(&self) -> io::Result<SystemTime> {
Ok(SystemTime::from(libc::timespec {
- tv_sec: self.stat.st_mtime,
+ tv_sec: self.stat.st_mtime as libc::time_t,
tv_nsec: self.stat.st_mtime_nsec as libc::c_long,
}))
}
pub fn accessed(&self) -> io::Result<SystemTime> {
Ok(SystemTime::from(libc::timespec {
- tv_sec: self.stat.st_atime,
+ tv_sec: self.stat.st_atime as libc::time_t,
tv_nsec: self.stat.st_atime_nsec as libc::c_long,
}))
}
target_os = "openbsd"))]
pub fn created(&self) -> io::Result<SystemTime> {
Ok(SystemTime::from(libc::timespec {
- tv_sec: self.stat.st_birthtime,
+ tv_sec: self.stat.st_birthtime as libc::time_t,
tv_nsec: self.stat.st_birthtime_nsec as libc::c_long,
}))
}
}
}
-impl AsInner<raw::stat> for FileAttr {
- fn as_inner(&self) -> &raw::stat { &self.stat }
-}
-
-/// OS-specific extension methods for `fs::Metadata`
-#[stable(feature = "metadata_ext", since = "1.1.0")]
-pub trait MetadataExt {
- /// Gain a reference to the underlying `stat` structure which contains the
- /// raw information returned by the OS.
- ///
- /// The contents of the returned `stat` are **not** consistent across Unix
- /// platforms. The `os::unix::fs::MetadataExt` trait contains the cross-Unix
- /// abstractions contained within the raw stat.
- #[stable(feature = "metadata_ext", since = "1.1.0")]
- fn as_raw_stat(&self) -> &raw::stat;
-}
-
-#[stable(feature = "metadata_ext", since = "1.1.0")]
-impl MetadataExt for ::fs::Metadata {
- fn as_raw_stat(&self) -> &raw::stat { &self.as_inner().stat }
+impl AsInner<stat64> for FileAttr {
+ fn as_inner(&self) -> &stat64 { &self.stat }
}
impl FilePermissions {
self.mode |= 0o222;
}
}
- pub fn mode(&self) -> raw::mode_t { self.mode }
+ pub fn mode(&self) -> u32 { self.mode as u32 }
}
impl FileType {
pub fn is(&self, mode: mode_t) -> bool { self.mode & libc::S_IFMT == mode }
}
-impl FromInner<raw::mode_t> for FilePermissions {
- fn from_inner(mode: raw::mode_t) -> FilePermissions {
+impl FromInner<u32> for FilePermissions {
+ fn from_inner(mode: u32) -> FilePermissions {
FilePermissions { mode: mode as mode_t }
}
}
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "linux",
- target_os = "solaris",
- target_os = "emscripten"))]
- pub fn ino(&self) -> raw::ino_t {
- self.entry.d_ino
- }
-
- #[cfg(target_os = "android")]
- pub fn ino(&self) -> raw::ino_t {
- self.entry.d_ino as raw::ino_t
+ target_os = "emscripten",
+ target_os = "android",
+ target_os = "solaris"))]
+ pub fn ino(&self) -> u64 {
+ self.entry.d_ino as u64
}
#[cfg(any(target_os = "freebsd",
target_os = "bitrig",
target_os = "netbsd",
target_os = "dragonfly"))]
- pub fn ino(&self) -> raw::ino_t {
- self.entry.d_fileno
+ pub fn ino(&self) -> u64 {
+ self.entry.d_fileno as u64
}
#[cfg(any(target_os = "macos",
pub fn create_new(&mut self, create_new: bool) { self.create_new = create_new; }
pub fn custom_flags(&mut self, flags: i32) { self.custom_flags = flags; }
- pub fn mode(&mut self, mode: raw::mode_t) { self.mode = mode as mode_t; }
+ pub fn mode(&mut self, mode: u32) { self.mode = mode as mode_t; }
fn get_access_mode(&self) -> io::Result<c_int> {
match (self.read, self.write, self.append) {
}
pub fn file_attr(&self) -> io::Result<FileAttr> {
- let mut stat: raw::stat = unsafe { mem::zeroed() };
+ let mut stat: stat64 = unsafe { mem::zeroed() };
try!(cvt(unsafe {
- libc::fstat(self.0.raw(), &mut stat as *mut _ as *mut _)
+ fstat64(self.0.raw(), &mut stat)
}));
Ok(FileAttr { stat: stat })
}
Ok(())
}
- pub fn set_mode(&mut self, mode: mode_t) {
- self.mode = mode;
+ pub fn set_mode(&mut self, mode: u32) {
+ self.mode = mode as mode_t;
}
}
pub fn stat(p: &Path) -> io::Result<FileAttr> {
let p = try!(cstr(p));
- let mut stat: raw::stat = unsafe { mem::zeroed() };
+ let mut stat: stat64 = unsafe { mem::zeroed() };
try!(cvt(unsafe {
- libc::stat(p.as_ptr(), &mut stat as *mut _ as *mut _)
+ stat64(p.as_ptr(), &mut stat as *mut _ as *mut _)
}));
Ok(FileAttr { stat: stat })
}
pub fn lstat(p: &Path) -> io::Result<FileAttr> {
let p = try!(cstr(p));
- let mut stat: raw::stat = unsafe { mem::zeroed() };
+ let mut stat: stat64 = unsafe { mem::zeroed() };
try!(cvt(unsafe {
- libc::lstat(p.as_ptr(), &mut stat as *mut _ as *mut _)
+ lstat64(p.as_ptr(), &mut stat as *mut _ as *mut _)
}));
Ok(FileAttr { stat: stat })
}
pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
pub const IO_REPARSE_TAG_SYMLINK: DWORD = 0xa000000c;
pub const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xa0000003;
+pub const SYMLINK_FLAG_RELATIVE: DWORD = 0x00000001;
pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
pub const FSCTL_DELETE_REPARSE_POINT: DWORD = 0x900ac;
pub PathBuffer: WCHAR,
}
+#[repr(C)]
+pub struct MOUNT_POINT_REPARSE_BUFFER {
+ pub SubstituteNameOffset: c_ushort,
+ pub SubstituteNameLength: c_ushort,
+ pub PrintNameOffset: c_ushort,
+ pub PrintNameLength: c_ushort,
+ pub PathBuffer: WCHAR,
+}
+
pub type LPPROGRESS_ROUTINE = ::option::Option<unsafe extern "system" fn(
TotalFileSize: LARGE_INTEGER,
TotalBytesTransferred: LARGE_INTEGER,
nFileSizeHigh: self.data.nFileSizeHigh,
nFileSizeLow: self.data.nFileSizeLow,
},
- reparse_tag: self.data.dwReserved0,
+ reparse_tag: if self.data.dwFileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 {
+ // reserved unless this is a reparse point
+ self.data.dwReserved0
+ } else {
+ 0
+ },
})
}
}
}
impl File {
- fn open_reparse_point(path: &Path, write: bool) -> io::Result<File> {
- let mut opts = OpenOptions::new();
- opts.read(!write);
- opts.write(write);
- opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
- c::FILE_FLAG_BACKUP_SEMANTICS);
- File::open(path, &opts)
- }
-
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
let path = try!(to_u16s(path));
let handle = unsafe {
fn readlink(&self) -> io::Result<PathBuf> {
let mut space = [0u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
let (_bytes, buf) = try!(self.reparse_point(&mut space));
- if buf.ReparseTag != c::IO_REPARSE_TAG_SYMLINK {
- return Err(io::Error::new(io::ErrorKind::Other, "not a symlink"))
- }
-
unsafe {
- let info: *const c::SYMBOLIC_LINK_REPARSE_BUFFER =
- &buf.rest as *const _ as *const _;
- let path_buffer = &(*info).PathBuffer as *const _ as *const u16;
- let subst_off = (*info).SubstituteNameOffset / 2;
+ let (path_buffer, subst_off, subst_len, relative) = match buf.ReparseTag {
+ c::IO_REPARSE_TAG_SYMLINK => {
+ let info: *const c::SYMBOLIC_LINK_REPARSE_BUFFER =
+ &buf.rest as *const _ as *const _;
+ (&(*info).PathBuffer as *const _ as *const u16,
+ (*info).SubstituteNameOffset / 2,
+ (*info).SubstituteNameLength / 2,
+ (*info).Flags & c::SYMLINK_FLAG_RELATIVE != 0)
+ },
+ c::IO_REPARSE_TAG_MOUNT_POINT => {
+ let info: *const c::MOUNT_POINT_REPARSE_BUFFER =
+ &buf.rest as *const _ as *const _;
+ (&(*info).PathBuffer as *const _ as *const u16,
+ (*info).SubstituteNameOffset / 2,
+ (*info).SubstituteNameLength / 2,
+ false)
+ },
+ _ => return Err(io::Error::new(io::ErrorKind::Other,
+ "Unsupported reparse point type"))
+ };
let subst_ptr = path_buffer.offset(subst_off as isize);
- let subst_len = (*info).SubstituteNameLength / 2;
- let subst = slice::from_raw_parts(subst_ptr, subst_len as usize);
-
+ let mut subst = slice::from_raw_parts(subst_ptr, subst_len as usize);
+ // Absolute paths start with an NT internal namespace prefix `\??\`
+ // We should not let it leak through.
+ if !relative && subst.starts_with(&[92u16, 63u16, 63u16, 92u16]) {
+ subst = &subst[4..];
+ }
Ok(PathBuf::from(OsString::from_wide(subst)))
}
}
rmdir(path)
}
-pub fn readlink(p: &Path) -> io::Result<PathBuf> {
- let file = try!(File::open_reparse_point(p, false));
+pub fn readlink(path: &Path) -> io::Result<PathBuf> {
+ // Open the link with no access mode, instead of generic read.
+ // By default FILE_LIST_DIRECTORY is denied for the junction "C:\Documents and Settings", so
+ // this is needed for a common case.
+ let mut opts = OpenOptions::new();
+ opts.access_mode(0);
+ opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
+ c::FILE_FLAG_BACKUP_SEMANTICS);
+ let file = try!(File::open(&path, &opts));
file.readlink()
}
Ok(())
}
-pub fn stat(p: &Path) -> io::Result<FileAttr> {
- let attr = try!(lstat(p));
-
- // If this is a reparse point, then we need to reopen the file to get the
- // actual destination. We also pass the FILE_FLAG_BACKUP_SEMANTICS flag to
- // ensure that we can open directories (this path may be a directory
- // junction). Once the file is opened we ask the opened handle what its
- // metadata information is.
- if attr.is_reparse_point() {
- let mut opts = OpenOptions::new();
- // No read or write permissions are necessary
- opts.access_mode(0);
- // This flag is so we can open directories too
- opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS);
- let file = try!(File::open(p, &opts));
- file.file_attr()
- } else {
- Ok(attr)
- }
+pub fn stat(path: &Path) -> io::Result<FileAttr> {
+ let mut opts = OpenOptions::new();
+ // No read or write permissions are necessary
+ opts.access_mode(0);
+ // This flag is so we can open directories too
+ opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS);
+ let file = try!(File::open(path, &opts));
+ file.file_attr()
}
-pub fn lstat(p: &Path) -> io::Result<FileAttr> {
- let u16s = try!(to_u16s(p));
- unsafe {
- let mut attr: FileAttr = mem::zeroed();
- try!(cvt(c::GetFileAttributesExW(u16s.as_ptr(),
- c::GetFileExInfoStandard,
- &mut attr.data as *mut _ as *mut _)));
- if attr.is_reparse_point() {
- attr.reparse_tag = File::open_reparse_point(p, false).and_then(|f| {
- let mut b = [0; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
- f.reparse_point(&mut b).map(|(_, b)| b.ReparseTag)
- }).unwrap_or(0);
- }
- Ok(attr)
- }
+pub fn lstat(path: &Path) -> io::Result<FileAttr> {
+ let mut opts = OpenOptions::new();
+ // No read or write permissions are necessary
+ opts.access_mode(0);
+ opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS | c::FILE_FLAG_OPEN_REPARSE_POINT);
+ let file = try!(File::open(path, &opts));
+ file.file_attr()
}
pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
let d = DirBuilder::new();
try!(d.mkdir(&junction));
- let f = try!(File::open_reparse_point(junction, true));
+
+ let mut opts = OpenOptions::new();
+ opts.write(true);
+ opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
+ c::FILE_FLAG_BACKUP_SEMANTICS);
+ let f = try!(File::open(junction, &opts));
let h = f.handle().raw();
unsafe {
// The Rust abstract syntax tree.
-pub use self::Pat_::*;
pub use self::StructFieldKind::*;
pub use self::TyParamBound::*;
pub use self::UnsafeSource::*;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
pub struct Pat {
pub id: NodeId,
- pub node: Pat_,
+ pub node: PatKind,
pub span: Span,
}
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub enum Pat_ {
+pub enum PatKind {
/// Represents a wildcard pattern (`_`)
- PatWild,
+ Wild,
- /// A PatIdent may either be a new bound variable,
- /// or a nullary enum (in which case the third field
- /// is None).
+ /// A `PatKind::Ident` may either be a new bound variable,
+ /// or a unit struct/variant pattern, or a const pattern (in the last two cases
+ /// the third field must be `None`).
///
- /// In the nullary enum case, the parser can't determine
+ /// In the unit or const pattern case, the parser can't determine
/// which it is. The resolver determines this, and
- /// records this pattern's NodeId in an auxiliary
- /// set (of "PatIdents that refer to nullary enums")
- PatIdent(BindingMode, SpannedIdent, Option<P<Pat>>),
+ /// records this pattern's `NodeId` in an auxiliary
+ /// set (of "PatIdents that refer to unit patterns or constants").
+ Ident(BindingMode, SpannedIdent, Option<P<Pat>>),
+ /// A struct or struct variant pattern, e.g. `Variant {x, y, ..}`.
+ /// The `bool` is `true` in the presence of a `..`.
+ Struct(Path, Vec<Spanned<FieldPat>>, bool),
+
+ /// A tuple struct/variant pattern `Variant(x, y, z)`.
/// "None" means a `Variant(..)` pattern where we don't bind the fields to names.
- PatEnum(Path, Option<Vec<P<Pat>>>),
+ TupleStruct(Path, Option<Vec<P<Pat>>>),
+
+ /// A path pattern.
+ /// Such pattern can be resolved to a unit struct/variant or a constant.
+ Path(Path),
/// An associated const named using the qualified path `<T>::CONST` or
/// `<T as Trait>::CONST`. Associated consts from inherent impls can be
/// referred to as simply `T::CONST`, in which case they will end up as
- /// PatEnum, and the resolver will have to sort that out.
- PatQPath(QSelf, Path),
+ /// PatKind::Enum, and the resolver will have to sort that out.
+ QPath(QSelf, Path),
- /// Destructuring of a struct, e.g. `Foo {x, y, ..}`
- /// The `bool` is `true` in the presence of a `..`
- PatStruct(Path, Vec<Spanned<FieldPat>>, bool),
/// A tuple pattern `(a, b)`
- PatTup(Vec<P<Pat>>),
+ Tup(Vec<P<Pat>>),
/// A `box` pattern
- PatBox(P<Pat>),
+ Box(P<Pat>),
/// A reference pattern, e.g. `&mut (a, b)`
- PatRegion(P<Pat>, Mutability),
+ Ref(P<Pat>, Mutability),
/// A literal
- PatLit(P<Expr>),
+ Lit(P<Expr>),
/// A range pattern, e.g. `1...2`
- PatRange(P<Expr>, P<Expr>),
+ Range(P<Expr>, P<Expr>),
/// `[a, b, ..i, y, z]` is represented as:
- /// `PatVec(box [a, b], Some(i), box [y, z])`
- PatVec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
+ /// `PatKind::Vec(box [a, b], Some(i), box [y, z])`
+ Vec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
/// A macro pattern; pre-expansion
- PatMac(Mac),
+ Mac(Mac),
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
}),
pat: P(Pat {
id: DUMMY_NODE_ID,
- node: PatIdent(BindingMode::ByValue(mutability), path, None),
+ node: PatKind::Ident(BindingMode::ByValue(mutability), path, None),
span: span
}),
id: DUMMY_NODE_ID
let spanned = codemap::Spanned{ span: s, node: i };
P(Pat {
id: id,
- node: PatIdent(BindingMode::ByValue(Mutability::Immutable), spanned, None),
+ node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), spanned, None),
span: s
})
}
/// and false otherwise.
pub fn pat_is_ident(pat: P<ast::Pat>) -> bool {
match pat.node {
- ast::PatIdent(..) => true,
+ PatKind::Ident(..) => true,
_ => false,
}
}
for idx in 0.. {
if let Some(sp_trim) = sp.trim_start(prev) {
// Implies `sp.hi > prev.hi`
- let cur = match self.spans.as_slice().get(idx) {
+ let cur = match self.spans.get(idx) {
Some(s) => *s,
None => {
sp = sp_trim;
pub use self::SyntaxExtension::*;
use ast;
-use ast::Name;
+use ast::{Name, PatKind};
use codemap;
use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION};
use errors::DiagnosticBuilder;
return Some(P(ast::Pat {
id: ast::DUMMY_NODE_ID,
span: e.span,
- node: ast::PatLit(e),
+ node: PatKind::Lit(e),
}));
}
}
pub fn raw_pat(sp: Span) -> ast::Pat {
ast::Pat {
id: ast::DUMMY_NODE_ID,
- node: ast::PatWild,
+ node: PatKind::Wild,
span: sp,
}
}
// except according to those terms.
use abi::Abi;
-use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp};
+use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind};
use attr;
use codemap::{Span, respan, Spanned, DUMMY_SP, Pos};
use ext::base::ExtCtxt;
fn expr_err(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
fn expr_try(&self, span: Span, head: P<ast::Expr>) -> P<ast::Expr>;
- fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat>;
+ fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat>;
fn pat_wild(&self, span: Span) -> P<ast::Pat>;
fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat>;
fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat>;
}
- fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat> {
+ fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat> {
P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span })
}
fn pat_wild(&self, span: Span) -> P<ast::Pat> {
- self.pat(span, ast::PatWild)
+ self.pat(span, PatKind::Wild)
}
fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat> {
- self.pat(span, ast::PatLit(expr))
+ self.pat(span, PatKind::Lit(expr))
}
fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Immutable);
span: Span,
ident: ast::Ident,
bm: ast::BindingMode) -> P<ast::Pat> {
- let pat = ast::PatIdent(bm, Spanned{span: span, node: ident}, None);
+ let pat = PatKind::Ident(bm, Spanned{span: span, node: ident}, None);
self.pat(span, pat)
}
fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
- let pat = ast::PatEnum(path, Some(subpats));
+ let pat = if subpats.is_empty() {
+ PatKind::Path(path)
+ } else {
+ PatKind::TupleStruct(path, Some(subpats))
+ };
self.pat(span, pat)
}
fn pat_struct(&self, span: Span,
path: ast::Path, field_pats: Vec<Spanned<ast::FieldPat>>) -> P<ast::Pat> {
- let pat = ast::PatStruct(path, field_pats, false);
+ let pat = PatKind::Struct(path, field_pats, false);
self.pat(span, pat)
}
fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
- self.pat(span, ast::PatTup(pats))
+ self.pat(span, PatKind::Tup(pats))
}
fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use ast::{Block, Crate, DeclKind, PatMac};
+use ast::{Block, Crate, DeclKind, PatKind};
use ast::{Local, Ident, Mac_, Name};
use ast::{MacStmtStyle, Mrk, Stmt, StmtKind, ItemKind};
use ast::TokenTree;
(f(&mut rename_fld, fld, x), rewritten_pats)
}
-/// A visitor that extracts the PatIdent (binding) paths
+/// A visitor that extracts the PatKind::Ident (binding) paths
/// from a given thingy and puts them in a mutable
/// array
#[derive(Clone)]
impl<'v> Visitor<'v> for PatIdentFinder {
fn visit_pat(&mut self, pattern: &ast::Pat) {
match *pattern {
- ast::Pat { id: _, node: ast::PatIdent(_, ref path1, ref inner), span: _ } => {
+ ast::Pat { id: _, node: PatKind::Ident(_, ref path1, ref inner), span: _ } => {
self.ident_accumulator.push(path1.node);
- // visit optional subpattern of PatIdent:
+ // visit optional subpattern of PatKind::Ident:
if let Some(ref subpat) = *inner {
self.visit_pat(subpat)
}
}
}
-/// find the PatIdent paths in a pattern
+/// find the PatKind::Ident paths in a pattern
fn pattern_bindings(pat: &ast::Pat) -> Vec<ast::Ident> {
let mut name_finder = PatIdentFinder{ident_accumulator:Vec::new()};
name_finder.visit_pat(pat);
name_finder.ident_accumulator
}
-/// find the PatIdent paths in a
+/// find the PatKind::Ident paths in a
fn fn_decl_arg_bindings(fn_decl: &ast::FnDecl) -> Vec<ast::Ident> {
let mut pat_idents = PatIdentFinder{ident_accumulator:Vec::new()};
for arg in &fn_decl.inputs {
fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
match p.node {
- PatMac(_) => {}
+ PatKind::Mac(_) => {}
_ => return noop_fold_pat(p, fld)
}
p.map(|ast::Pat {node, span, ..}| {
let (pth, tts) = match node {
- PatMac(mac) => (mac.node.path, mac.node.tts),
+ PatKind::Mac(mac) => (mac.node.path, mac.node.tts),
_ => unreachable!()
};
if pth.segments.len() > 1 {
}
/// A tree-folder that applies every rename in its list to
-/// the idents that are in PatIdent patterns. This is more narrowly
+/// the idents that are in PatKind::Ident patterns. This is more narrowly
/// focused than IdentRenamer, and is needed for FnDecl,
/// where we want to rename the args but not the fn name or the generics etc.
pub struct PatIdentRenamer<'a> {
impl<'a> Folder for PatIdentRenamer<'a> {
fn fold_pat(&mut self, pat: P<ast::Pat>) -> P<ast::Pat> {
match pat.node {
- ast::PatIdent(..) => {},
+ PatKind::Ident(..) => {},
_ => return noop_fold_pat(pat, self)
}
pat.map(|ast::Pat {id, node, span}| match node {
- ast::PatIdent(binding_mode, Spanned{span: sp, node: ident}, sub) => {
+ PatKind::Ident(binding_mode, Spanned{span: sp, node: ident}, sub) => {
let new_ident = Ident::new(ident.name,
mtwt::apply_renames(self.renames, ident.ctxt));
let new_node =
- ast::PatIdent(binding_mode,
+ PatKind::Ident(binding_mode,
Spanned{span: self.new_span(sp), node: new_ident},
sub.map(|p| self.fold_pat(p)));
ast::Pat {
use self::AttributeGate::*;
use abi::Abi;
-use ast::NodeId;
+use ast::{NodeId, PatKind};
use ast;
use attr;
use attr::AttrMetaMethods;
fn visit_pat(&mut self, pattern: &ast::Pat) {
match pattern.node {
- ast::PatVec(_, Some(_), ref last) if !last.is_empty() => {
+ PatKind::Vec(_, Some(_), ref last) if !last.is_empty() => {
self.gate_feature("advanced_slice_patterns",
pattern.span,
"multiple-element slice matches anywhere \
but at the end of a slice (e.g. \
`[0, ..xs, 0]`) are experimental")
}
- ast::PatVec(..) => {
+ PatKind::Vec(..) => {
self.gate_feature("slice_patterns",
pattern.span,
"slice pattern syntax is experimental");
}
- ast::PatBox(..) => {
+ PatKind::Box(..) => {
self.gate_feature("box_patterns",
pattern.span,
"box pattern syntax is experimental");
p.map(|Pat {id, node, span}| Pat {
id: folder.new_id(id),
node: match node {
- PatWild => PatWild,
- PatIdent(binding_mode, pth1, sub) => {
- PatIdent(binding_mode,
+ PatKind::Wild => PatKind::Wild,
+ PatKind::Ident(binding_mode, pth1, sub) => {
+ PatKind::Ident(binding_mode,
Spanned{span: folder.new_span(pth1.span),
node: folder.fold_ident(pth1.node)},
sub.map(|x| folder.fold_pat(x)))
}
- PatLit(e) => PatLit(folder.fold_expr(e)),
- PatEnum(pth, pats) => {
- PatEnum(folder.fold_path(pth),
+ PatKind::Lit(e) => PatKind::Lit(folder.fold_expr(e)),
+ PatKind::TupleStruct(pth, pats) => {
+ PatKind::TupleStruct(folder.fold_path(pth),
pats.map(|pats| pats.move_map(|x| folder.fold_pat(x))))
}
- PatQPath(qself, pth) => {
+ PatKind::Path(pth) => {
+ PatKind::Path(folder.fold_path(pth))
+ }
+ PatKind::QPath(qself, pth) => {
let qself = QSelf {ty: folder.fold_ty(qself.ty), .. qself};
- PatQPath(qself, folder.fold_path(pth))
+ PatKind::QPath(qself, folder.fold_path(pth))
}
- PatStruct(pth, fields, etc) => {
+ PatKind::Struct(pth, fields, etc) => {
let pth = folder.fold_path(pth);
let fs = fields.move_map(|f| {
Spanned { span: folder.new_span(f.span),
is_shorthand: f.node.is_shorthand,
}}
});
- PatStruct(pth, fs, etc)
+ PatKind::Struct(pth, fs, etc)
}
- PatTup(elts) => PatTup(elts.move_map(|x| folder.fold_pat(x))),
- PatBox(inner) => PatBox(folder.fold_pat(inner)),
- PatRegion(inner, mutbl) => PatRegion(folder.fold_pat(inner), mutbl),
- PatRange(e1, e2) => {
- PatRange(folder.fold_expr(e1), folder.fold_expr(e2))
+ PatKind::Tup(elts) => PatKind::Tup(elts.move_map(|x| folder.fold_pat(x))),
+ PatKind::Box(inner) => PatKind::Box(folder.fold_pat(inner)),
+ PatKind::Ref(inner, mutbl) => PatKind::Ref(folder.fold_pat(inner), mutbl),
+ PatKind::Range(e1, e2) => {
+ PatKind::Range(folder.fold_expr(e1), folder.fold_expr(e2))
},
- PatVec(before, slice, after) => {
- PatVec(before.move_map(|x| folder.fold_pat(x)),
+ PatKind::Vec(before, slice, after) => {
+ PatKind::Vec(before.move_map(|x| folder.fold_pat(x)),
slice.map(|x| folder.fold_pat(x)),
after.move_map(|x| folder.fold_pat(x)))
}
- PatMac(mac) => PatMac(folder.fold_mac(mac))
+ PatKind::Mac(mac) => PatKind::Mac(folder.fold_mac(mac))
},
span: folder.new_span(span)
})
use super::*;
use std::rc::Rc;
use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION};
- use ast::{self, TokenTree};
+ use ast::{self, TokenTree, PatKind};
use abi::Abi;
use attr::{first_attr_value_str_by_name, AttrMetaMethods};
use parse;
assert!(panictry!(parser.parse_pat())
== P(ast::Pat{
id: ast::DUMMY_NODE_ID,
- node: ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable),
+ node: PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable),
Spanned{ span:sp(0, 1),
node: str_to_ident("b")
},
}),
pat: P(ast::Pat {
id: ast::DUMMY_NODE_ID,
- node: ast::PatIdent(
+ node: PatKind::Ident(
ast::BindingMode::ByValue(ast::Mutability::Immutable),
Spanned{
span: sp(6,7),
impl<'v> ::visit::Visitor<'v> for PatIdentVisitor {
fn visit_pat(&mut self, p: &'v ast::Pat) {
match p.node {
- ast::PatIdent(_ , ref spannedident, _) => {
+ PatKind::Ident(_ , ref spannedident, _) => {
self.spans.push(spannedident.span.clone());
}
_ => {
use ast::Mac_;
use ast::{MutTy, Mutability};
use ast::NamedField;
-use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange};
-use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild};
+use ast::{Pat, PatKind};
use ast::{PolyTraitRef, QSelf};
use ast::{Stmt, StmtKind};
use ast::{VariantData, StructField};
No,
}
+#[derive(Clone, Copy, PartialEq)]
+pub enum SemiColonMode {
+ Break,
+ Ignore,
+}
+
/// Possibly accept an `token::Interpolated` expression (a pre-parsed expression
/// dropped into the token stream, which happens while parsing the result of
/// macro expansion). Placement of these is not as complex as I feared it would
/// Check if the next token is `tok`, and return `true` if so.
///
- /// This method is will automatically add `tok` to `expected_tokens` if `tok` is not
+ /// This method will automatically add `tok` to `expected_tokens` if `tok` is not
/// encountered.
pub fn check(&mut self, tok: &token::Token) -> bool {
let is_present = self.token == *tok;
return Ok((v, returned));
}
+ /// Eat and discard tokens until one of `kets` is encountered. Respects token trees,
+ /// passes through any errors encountered. Used for error recovery.
+ pub fn eat_to_tokens(&mut self, kets: &[&token::Token]) {
+ self.parse_seq_to_before_tokens(kets,
+ seq_sep_none(),
+ |p| p.parse_token_tree(),
+ |mut e| e.cancel());
+ }
+
/// Parse a sequence, including the closing delimiter. The function
/// f must consume tokens until reaching the next separator or
/// closing bracket.
-> PResult<'a, Vec<T>> where
F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
{
- let val = try!(self.parse_seq_to_before_end(ket, sep, f));
+ let val = self.parse_seq_to_before_end(ket, sep, f);
self.bump();
Ok(val)
}
pub fn parse_seq_to_before_end<T, F>(&mut self,
ket: &token::Token,
sep: SeqSep,
- mut f: F)
- -> PResult<'a, Vec<T>> where
- F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
+ f: F)
+ -> Vec<T>
+ where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
+ {
+ self.parse_seq_to_before_tokens(&[ket], sep, f, |mut e| e.emit())
+ }
+
+ // `fe` is an error handler.
+ fn parse_seq_to_before_tokens<T, F, Fe>(&mut self,
+ kets: &[&token::Token],
+ sep: SeqSep,
+ mut f: F,
+ mut fe: Fe)
+ -> Vec<T>
+ where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
+ Fe: FnMut(DiagnosticBuilder)
{
let mut first: bool = true;
let mut v = vec!();
- while self.token != *ket {
+ while !kets.contains(&&self.token) {
match sep.sep {
- Some(ref t) => {
- if first { first = false; }
- else { try!(self.expect(t)); }
- }
- _ => ()
+ Some(ref t) => {
+ if first {
+ first = false;
+ } else {
+ if let Err(e) = self.expect(t) {
+ fe(e);
+ break;
+ }
+ }
+ }
+ _ => ()
+ }
+ if sep.trailing_sep_allowed && kets.iter().any(|k| self.check(k)) {
+ break;
+ }
+
+ match f(self) {
+ Ok(t) => v.push(t),
+ Err(e) => {
+ fe(e);
+ break;
+ }
}
- if sep.trailing_sep_allowed && self.check(ket) { break; }
- v.push(try!(f(self)));
}
- return Ok(v);
+
+ v
}
/// Parse a sequence, including the closing delimiter. The function
F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
{
try!(self.expect(bra));
- let result = try!(self.parse_seq_to_before_end(ket, sep, f));
+ let result = self.parse_seq_to_before_end(ket, sep, f);
self.bump();
Ok(result)
}
{
let lo = self.span.lo;
try!(self.expect(bra));
- let result = try!(self.parse_seq_to_before_end(ket, sep, f));
+ let result = self.parse_seq_to_before_end(ket, sep, f);
let hi = self.span.hi;
self.bump();
Ok(spanned(lo, hi, result))
};
(ident, TraitItemKind::Const(ty, default))
} else {
- let (constness, unsafety, abi) = try!(p.parse_fn_front_matter());
+ let (constness, unsafety, abi) = match p.parse_fn_front_matter() {
+ Ok(cua) => cua,
+ Err(e) => {
+ loop {
+ p.bump();
+ if p.token == token::Semi {
+ p.bump();
+ break;
+ }
+
+ if p.token == token::OpenDelim(token::DelimToken::Brace) {
+ try!(p.parse_token_tree());
+ break;
+ }
+ }
+
+ return Err(e);
+ }
+ };
let ident = try!(p.parse_ident());
let mut generics = try!(p.parse_generics());
while self.token != token::CloseDelim(token::Brace) {
if self.eat(&token::DotDot) {
- base = Some(try!(self.parse_expr()));
+ match self.parse_expr() {
+ Ok(e) => {
+ base = Some(e);
+ }
+ Err(mut e) => {
+ e.emit();
+ self.recover_stmt();
+ }
+ }
break;
}
- fields.push(try!(self.parse_field()));
- try!(self.commit_expr(&fields.last().unwrap().expr,
- &[token::Comma],
- &[token::CloseDelim(token::Brace)]));
+ match self.parse_field() {
+ Ok(f) => fields.push(f),
+ Err(mut e) => {
+ e.emit();
+ self.recover_stmt();
+ break;
+ }
+ }
+
+ match self.commit_expr(&fields.last().unwrap().expr,
+ &[token::Comma],
+ &[token::CloseDelim(token::Brace)]) {
+ Ok(()) => {}
+ Err(mut e) => {
+ e.emit();
+ self.recover_stmt();
+ break;
+ }
+ }
}
hi = self.span.hi;
// yet.
maybe_whole!(deref self, NtTT);
- // this is the fall-through for the 'match' below.
- // invariants: the current token is not a left-delimiter,
- // not an EOF, and not the desired right-delimiter (if
- // it were, parse_seq_to_before_end would have prevented
- // reaching this point.
- fn parse_non_delim_tt_tok<'b>(p: &mut Parser<'b>) -> PResult<'b, TokenTree> {
- maybe_whole!(deref p, NtTT);
- match p.token {
- token::CloseDelim(_) => {
- let token_str = p.this_token_to_string();
- let mut err = p.fatal(
- &format!("incorrect close delimiter: `{}`", token_str));
- // This is a conservative error: only report the last unclosed delimiter. The
- // previous unclosed delimiters could actually be closed! The parser just hasn't
- // gotten to them yet.
- if let Some(&sp) = p.open_braces.last() {
- err.span_note(sp, "unclosed delimiter");
- };
- Err(err)
- },
- /* we ought to allow different depths of unquotation */
- token::Dollar | token::SubstNt(..) if p.quote_depth > 0 => {
- p.parse_unquoted()
- }
- _ => {
- Ok(TokenTree::Token(p.span, p.bump_and_get()))
- }
- }
- }
-
match self.token {
token::Eof => {
- let open_braces = self.open_braces.clone();
let mut err: DiagnosticBuilder<'a> =
- self.fatal("this file contains an un-closed delimiter");
- for sp in &open_braces {
+ self.diagnostic().struct_span_err(self.span,
+ "this file contains an un-closed delimiter");
+ for sp in &self.open_braces {
err.span_help(*sp, "did you mean to close this delimiter?");
}
- return Err(err);
+
+ Err(err)
},
token::OpenDelim(delim) => {
// The span for beginning of the delimited section
self.bump();
// Parse the token trees within the delimiters
- let tts = try!(self.parse_seq_to_before_end(
- &token::CloseDelim(delim),
- seq_sep_none(),
- |p| p.parse_token_tree()
- ));
+ let tts = self.parse_seq_to_before_end(&token::CloseDelim(delim),
+ seq_sep_none(),
+ |p| p.parse_token_tree());
// Parse the close delimiter.
let close_span = self.span;
close_span: close_span,
})))
},
- _ => parse_non_delim_tt_tok(self),
+ _ => {
+ // invariants: the current token is not a left-delimiter,
+ // not an EOF, and not the desired right-delimiter (if
+ // it were, parse_seq_to_before_end would have prevented
+ // reaching this point.
+ maybe_whole!(deref self, NtTT);
+ match self.token {
+ token::CloseDelim(_) => {
+ let token_str = self.this_token_to_string();
+ let mut err = self.diagnostic().struct_span_err(self.span,
+ &format!("incorrect close delimiter: `{}`", token_str));
+ // This is a conservative error: only report the last unclosed delimiter.
+ // The previous unclosed delimiters could actually be closed! The parser
+ // just hasn't gotten to them yet.
+ if let Some(&sp) = self.open_braces.last() {
+ err.span_note(sp, "unclosed delimiter");
+ };
+
+ Err(err)
+ },
+ /* we ought to allow different depths of unquotation */
+ token::Dollar | token::SubstNt(..) if self.quote_depth > 0 => {
+ self.parse_unquoted()
+ }
+ _ => {
+ Ok(TokenTree::Token(self.span, self.bump_and_get()))
+ }
+ }
+ }
}
}
fn parse_match_expr(&mut self, attrs: ThinAttributes) -> PResult<'a, P<Expr>> {
let match_span = self.last_span;
let lo = self.last_span.lo;
- let discriminant = try!(self.parse_expr_res(
- Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None));
+ let discriminant = try!(self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL,
+ None));
if let Err(mut e) = self.commit_expr_expecting(&discriminant,
token::OpenDelim(token::Brace)) {
if self.token == token::Token::Semi {
try!(self.parse_inner_attributes()).into_thin_attrs());
let mut arms: Vec<Arm> = Vec::new();
while self.token != token::CloseDelim(token::Brace) {
- arms.push(try!(self.parse_arm()));
+ match self.parse_arm() {
+ Ok(arm) => arms.push(arm),
+ Err(mut e) => {
+ // Recover by skipping to the end of the block.
+ e.emit();
+ self.recover_stmt();
+ let hi = self.span.hi;
+ if self.token == token::CloseDelim(token::Brace) {
+ self.bump();
+ }
+ return Ok(self.mk_expr(lo, hi, ExprKind::Match(discriminant, arms), attrs));
+ }
+ }
}
let hi = self.span.hi;
self.bump();
self.check(&token::CloseDelim(token::Bracket)) {
slice = Some(P(ast::Pat {
id: ast::DUMMY_NODE_ID,
- node: PatWild,
+ node: PatKind::Wild,
span: self.span,
}));
before_slice = false;
let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname};
let fieldpat = P(ast::Pat{
id: ast::DUMMY_NODE_ID,
- node: PatIdent(bind_type, fieldpath, None),
+ node: PatKind::Ident(bind_type, fieldpath, None),
span: mk_sp(boxed_span_lo, hi),
});
let subpat = if is_box {
P(ast::Pat{
id: ast::DUMMY_NODE_ID,
- node: PatBox(fieldpat),
+ node: PatKind::Box(fieldpat),
span: mk_sp(lo, hi),
})
} else {
token::Underscore => {
// Parse _
self.bump();
- pat = PatWild;
+ pat = PatKind::Wild;
}
token::BinOp(token::And) | token::AndAnd => {
// Parse &pat / &mut pat
}
let subpat = try!(self.parse_pat());
- pat = PatRegion(subpat, mutbl);
+ pat = PatKind::Ref(subpat, mutbl);
}
token::OpenDelim(token::Paren) => {
// Parse (pat,pat,pat,...) as tuple pattern
self.bump();
let fields = try!(self.parse_pat_tuple_elements());
try!(self.expect(&token::CloseDelim(token::Paren)));
- pat = PatTup(fields);
+ pat = PatKind::Tup(fields);
}
token::OpenDelim(token::Bracket) => {
// Parse [pat,pat,...] as slice pattern
self.bump();
let (before, slice, after) = try!(self.parse_pat_vec_elements());
try!(self.expect(&token::CloseDelim(token::Bracket)));
- pat = PatVec(before, slice, after);
+ pat = PatKind::Vec(before, slice, after);
}
_ => {
// At this point, token != _, &, &&, (, [
} else if self.eat_keyword(keywords::Box) {
// Parse box pat
let subpat = try!(self.parse_pat());
- pat = PatBox(subpat);
+ pat = PatKind::Box(subpat);
} else if self.is_path_start() {
// Parse pattern starting with a path
if self.token.is_plain_ident() && self.look_ahead(1, |t| *t != token::DotDotDot &&
let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
seq_sep_none(), |p| p.parse_token_tree()));
let mac = Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT };
- pat = PatMac(codemap::Spanned {node: mac,
+ pat = PatKind::Mac(codemap::Spanned {node: mac,
span: mk_sp(lo, self.last_span.hi)});
} else {
// Parse ident @ pat
let begin = self.mk_expr(lo, hi, ExprKind::Path(qself, path), None);
self.bump();
let end = try!(self.parse_pat_range_end());
- pat = PatRange(begin, end);
+ pat = PatKind::Range(begin, end);
}
token::OpenDelim(token::Brace) => {
if qself.is_some() {
}
// Parse struct pattern
self.bump();
- let (fields, etc) = try!(self.parse_pat_fields());
+ let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
+ e.emit();
+ self.recover_stmt();
+ (vec![], false)
+ });
self.bump();
- pat = PatStruct(path, fields, etc);
+ pat = PatKind::Struct(path, fields, etc);
}
token::OpenDelim(token::Paren) => {
if qself.is_some() {
self.bump();
self.bump();
try!(self.expect(&token::CloseDelim(token::Paren)));
- pat = PatEnum(path, None);
+ pat = PatKind::TupleStruct(path, None);
} else {
let args = try!(self.parse_enum_variant_seq(
&token::OpenDelim(token::Paren),
&token::CloseDelim(token::Paren),
seq_sep_trailing_allowed(token::Comma),
|p| p.parse_pat()));
- pat = PatEnum(path, Some(args));
+ pat = PatKind::TupleStruct(path, Some(args));
}
}
_ => {
pat = match qself {
// Parse qualified path
- Some(qself) => PatQPath(qself, path),
+ Some(qself) => PatKind::QPath(qself, path),
// Parse nullary enum
- None => PatEnum(path, Some(vec![]))
+ None => PatKind::Path(path)
};
}
}
let begin = try!(self.parse_pat_literal_maybe_minus());
if self.eat(&token::DotDotDot) {
let end = try!(self.parse_pat_range_end());
- pat = PatRange(begin, end);
+ pat = PatKind::Range(begin, end);
} else {
- pat = PatLit(begin);
+ pat = PatKind::Lit(begin);
}
}
}
/// error message when parsing mistakes like ref foo(a,b)
fn parse_pat_ident(&mut self,
binding_mode: ast::BindingMode)
- -> PResult<'a, ast::Pat_> {
+ -> PResult<'a, PatKind> {
if !self.token.is_plain_ident() {
let span = self.span;
let tok_str = self.this_token_to_string();
"expected identifier, found enum pattern"))
}
- Ok(PatIdent(binding_mode, name, sub))
+ Ok(PatKind::Ident(binding_mode, name, sub))
}
/// Parse a local variable declaration
/// Parse a statement. may include decl.
pub fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> {
- Ok(try!(self.parse_stmt_()))
+ Ok(self.parse_stmt_())
+ }
+
+ // Eat tokens until we can be relatively sure we reached the end of the
+ // statement. This is something of a best-effort heuristic.
+ //
+ // We terminate when we find an unmatched `}` (without consuming it).
+ fn recover_stmt(&mut self) {
+ self.recover_stmt_(SemiColonMode::Ignore)
+ }
+ // If `break_on_semi` is `Break`, then we will stop consuming tokens after
+ // finding (and consuming) a `;` outside of `{}` or `[]` (note that this is
+ // approximate - it can mean we break too early due to macros, but that
+ // shoud only lead to sub-optimal recovery, not inaccurate parsing).
+ fn recover_stmt_(&mut self, break_on_semi: SemiColonMode) {
+ let mut brace_depth = 0;
+ let mut bracket_depth = 0;
+ loop {
+ match self.token {
+ token::OpenDelim(token::DelimToken::Brace) => {
+ brace_depth += 1;
+ self.bump();
+ }
+ token::OpenDelim(token::DelimToken::Bracket) => {
+ bracket_depth += 1;
+ self.bump();
+ }
+ token::CloseDelim(token::DelimToken::Brace) => {
+ if brace_depth == 0 {
+ return;
+ }
+ brace_depth -= 1;
+ self.bump();
+ }
+ token::CloseDelim(token::DelimToken::Bracket) => {
+ bracket_depth -= 1;
+ if bracket_depth < 0 {
+ bracket_depth = 0;
+ }
+ self.bump();
+ }
+ token::Eof => return,
+ token::Semi => {
+ self.bump();
+ if break_on_semi == SemiColonMode::Break &&
+ brace_depth == 0 &&
+ bracket_depth == 0 {
+ return;
+ }
+ }
+ _ => {
+ self.bump()
+ }
+ }
+ }
+ }
+
+ fn parse_stmt_(&mut self) -> Option<Stmt> {
+ self.parse_stmt_without_recovery().unwrap_or_else(|mut e| {
+ e.emit();
+ self.recover_stmt_(SemiColonMode::Break);
+ None
+ })
}
- fn parse_stmt_(&mut self) -> PResult<'a, Option<Stmt>> {
+ fn parse_stmt_without_recovery(&mut self) -> PResult<'a, Option<Stmt>> {
maybe_whole!(Some deref self, NtStmt);
let attrs = try!(self.parse_outer_attributes());
let lo = self.span.lo;
try!(self.expect(&token::OpenDelim(token::Brace)));
Ok((try!(self.parse_inner_attributes()),
- try!(self.parse_block_tail(lo, BlockCheckMode::Default))))
+ try!(self.parse_block_tail(lo, BlockCheckMode::Default))))
}
/// Parse the rest of a block expression or function body
let mut expr = None;
while !self.eat(&token::CloseDelim(token::Brace)) {
- let Spanned {node, span} = if let Some(s) = try!(self.parse_stmt_()) {
+ let Spanned {node, span} = if let Some(s) = self.parse_stmt_() {
s
} else {
// Found only `;` or `}`.
}))
}
- fn handle_expression_like_statement(
- &mut self,
- e: P<Expr>,
- span: Span,
- stmts: &mut Vec<Stmt>,
- last_block_expr: &mut Option<P<Expr>>) -> PResult<'a, ()> {
+ fn handle_expression_like_statement(&mut self,
+ e: P<Expr>,
+ span: Span,
+ stmts: &mut Vec<Stmt>,
+ last_block_expr: &mut Option<P<Expr>>)
+ -> PResult<'a, ()> {
// expression without semicolon
if classify::expr_requires_semi_to_be_stmt(&e) {
// Just check for errors and recover; do not eat semicolon yet.
- try!(self.commit_stmt(&[],
- &[token::Semi, token::CloseDelim(token::Brace)]));
+ if let Err(mut e) =
+ self.commit_stmt(&[], &[token::Semi, token::CloseDelim(token::Brace)])
+ {
+ e.emit();
+ self.recover_stmt();
+ }
}
match self.token {
fn forbid_lifetime(&mut self) -> PResult<'a, ()> {
if self.token.is_lifetime() {
let span = self.span;
- return Err(self.span_fatal(span, "lifetime parameters must be declared \
- prior to type parameters"))
+ return Err(self.diagnostic().struct_span_err(span, "lifetime parameters must be \
+ declared prior to type parameters"))
}
Ok(())
}
fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
-> PResult<'a, (Vec<Arg> , bool)> {
let sp = self.span;
- let mut args: Vec<Option<Arg>> =
+ let mut variadic = false;
+ let args: Vec<Option<Arg>> =
try!(self.parse_unspanned_seq(
&token::OpenDelim(token::Paren),
&token::CloseDelim(token::Paren),
if allow_variadic {
if p.token != token::CloseDelim(token::Paren) {
let span = p.span;
- return Err(p.span_fatal(span,
- "`...` must be last in argument list for variadic function"))
+ p.span_err(span,
+ "`...` must be last in argument list for variadic function");
}
} else {
let span = p.span;
- return Err(p.span_fatal(span,
- "only foreign functions are allowed to be variadic"))
+ p.span_err(span,
+ "only foreign functions are allowed to be variadic");
}
+ variadic = true;
Ok(None)
} else {
- Ok(Some(try!(p.parse_arg_general(named_args))))
+ match p.parse_arg_general(named_args) {
+ Ok(arg) => Ok(Some(arg)),
+ Err(mut e) => {
+ e.emit();
+ p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(token::Paren)]);
+ Ok(None)
+ }
+ }
}
}
));
- let variadic = match args.pop() {
- Some(None) => true,
- Some(x) => {
- // Need to put back that last arg
- args.push(x);
- false
- }
- None => false
- };
+ let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
if variadic && args.is_empty() {
self.span_err(sp,
"variadic function must be declared with at least one named argument");
}
- let args = args.into_iter().map(|x| x.unwrap()).collect();
-
Ok((args, variadic))
}
token::Comma => {
self.bump();
let sep = seq_sep_trailing_allowed(token::Comma);
- let mut fn_inputs = try!(self.parse_seq_to_before_end(
+ let mut fn_inputs = self.parse_seq_to_before_end(
&token::CloseDelim(token::Paren),
sep,
parse_arg_fn
- ));
+ );
fn_inputs.insert(0, Arg::new_self(explicit_self_sp, mutbl_self, $self_id));
fn_inputs
}
let fn_inputs = match explicit_self {
SelfKind::Static => {
let sep = seq_sep_trailing_allowed(token::Comma);
- try!(self.parse_seq_to_before_end(&token::CloseDelim(token::Paren),
- sep, parse_arg_fn))
+ self.parse_seq_to_before_end(&token::CloseDelim(token::Paren), sep, parse_arg_fn)
}
SelfKind::Value(id) => parse_remaining_arguments!(id),
SelfKind::Region(_,_,id) => parse_remaining_arguments!(id),
} else {
try!(self.expect(&token::BinOp(token::Or)));
try!(self.parse_obsolete_closure_kind());
- let args = try!(self.parse_seq_to_before_end(
+ let args = self.parse_seq_to_before_end(
&token::BinOp(token::Or),
seq_sep_trailing_allowed(token::Comma),
|p| p.parse_fn_block_arg()
- ));
+ );
self.bump();
args
}
// eat a matched-delimiter token tree:
let delim = try!(self.expect_open_delim());
let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
- seq_sep_none(),
- |p| p.parse_token_tree()));
+ seq_sep_none(),
+ |p| p.parse_token_tree()));
let m_ = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
let m: ast::Mac = codemap::Spanned { node: m_,
span: mk_sp(lo,
// eat a matched-delimiter token tree:
let delim = try!(self.expect_open_delim());
let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
- seq_sep_none(),
- |p| p.parse_token_tree()));
+ seq_sep_none(),
+ |p| p.parse_token_tree()));
// single-variant-enum... :
let m = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
let m: ast::Mac = codemap::Spanned { node: m,
pub use self::AnnNode::*;
use abi::{self, Abi};
-use ast::{self, TokenTree, BlockCheckMode};
+use ast::{self, TokenTree, BlockCheckMode, PatKind};
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
use ast::Attribute;
use attr::ThinAttributesExt;
/* Pat isn't normalized, but the beauty of it
is that it doesn't matter */
match pat.node {
- ast::PatWild => try!(word(&mut self.s, "_")),
- ast::PatIdent(binding_mode, ref path1, ref sub) => {
+ PatKind::Wild => try!(word(&mut self.s, "_")),
+ PatKind::Ident(binding_mode, ref path1, ref sub) => {
match binding_mode {
ast::BindingMode::ByRef(mutbl) => {
try!(self.word_nbsp("ref"));
None => ()
}
}
- ast::PatEnum(ref path, ref args_) => {
+ PatKind::TupleStruct(ref path, ref args_) => {
try!(self.print_path(path, true, 0));
match *args_ {
None => try!(word(&mut self.s, "(..)")),
Some(ref args) => {
- if !args.is_empty() {
- try!(self.popen());
- try!(self.commasep(Inconsistent, &args[..],
- |s, p| s.print_pat(&p)));
- try!(self.pclose());
- }
+ try!(self.popen());
+ try!(self.commasep(Inconsistent, &args[..],
+ |s, p| s.print_pat(&p)));
+ try!(self.pclose());
}
}
}
- ast::PatQPath(ref qself, ref path) => {
+ PatKind::Path(ref path) => {
+ try!(self.print_path(path, true, 0));
+ }
+ PatKind::QPath(ref qself, ref path) => {
try!(self.print_qpath(path, qself, false));
}
- ast::PatStruct(ref path, ref fields, etc) => {
+ PatKind::Struct(ref path, ref fields, etc) => {
try!(self.print_path(path, true, 0));
try!(self.nbsp());
try!(self.word_space("{"));
try!(space(&mut self.s));
try!(word(&mut self.s, "}"));
}
- ast::PatTup(ref elts) => {
+ PatKind::Tup(ref elts) => {
try!(self.popen());
try!(self.commasep(Inconsistent,
&elts[..],
}
try!(self.pclose());
}
- ast::PatBox(ref inner) => {
+ PatKind::Box(ref inner) => {
try!(word(&mut self.s, "box "));
try!(self.print_pat(&inner));
}
- ast::PatRegion(ref inner, mutbl) => {
+ PatKind::Ref(ref inner, mutbl) => {
try!(word(&mut self.s, "&"));
if mutbl == ast::Mutability::Mutable {
try!(word(&mut self.s, "mut "));
}
try!(self.print_pat(&inner));
}
- ast::PatLit(ref e) => try!(self.print_expr(&e)),
- ast::PatRange(ref begin, ref end) => {
+ PatKind::Lit(ref e) => try!(self.print_expr(&**e)),
+ PatKind::Range(ref begin, ref end) => {
try!(self.print_expr(&begin));
try!(space(&mut self.s));
try!(word(&mut self.s, "..."));
try!(self.print_expr(&end));
}
- ast::PatVec(ref before, ref slice, ref after) => {
+ PatKind::Vec(ref before, ref slice, ref after) => {
try!(word(&mut self.s, "["));
try!(self.commasep(Inconsistent,
&before[..],
|s, p| s.print_pat(&p)));
if let Some(ref p) = *slice {
if !before.is_empty() { try!(self.word_space(",")); }
- if p.node != ast::PatWild {
+ if p.node != PatKind::Wild {
try!(self.print_pat(&p));
}
try!(word(&mut self.s, ".."));
|s, p| s.print_pat(&p)));
try!(word(&mut self.s, "]"));
}
- ast::PatMac(ref m) => try!(self.print_mac(m, token::Paren)),
+ PatKind::Mac(ref m) => try!(self.print_mac(m, token::Paren)),
}
self.ann.post(self, NodePat(pat))
}
let m = match *explicit_self {
ast::SelfKind::Static => ast::Mutability::Immutable,
_ => match decl.inputs[0].pat.node {
- ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
+ PatKind::Ident(ast::BindingMode::ByValue(m), _, _) => m,
_ => ast::Mutability::Immutable
}
};
ast::TyKind::Infer if is_closure => try!(self.print_pat(&input.pat)),
_ => {
match input.pat.node {
- ast::PatIdent(_, ref path1, _) if
+ PatKind::Ident(_, ref path1, _) if
path1.node.name ==
parse::token::special_idents::invalid.name => {
// Do nothing.
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
match pattern.node {
- PatEnum(ref path, ref opt_children) => {
+ PatKind::TupleStruct(ref path, ref opt_children) => {
visitor.visit_path(path, pattern.id);
if let Some(ref children) = *opt_children {
walk_list!(visitor, visit_pat, children);
}
}
- PatQPath(ref qself, ref path) => {
+ PatKind::Path(ref path) => {
+ visitor.visit_path(path, pattern.id);
+ }
+ PatKind::QPath(ref qself, ref path) => {
visitor.visit_ty(&qself.ty);
visitor.visit_path(path, pattern.id)
}
- PatStruct(ref path, ref fields, _) => {
+ PatKind::Struct(ref path, ref fields, _) => {
visitor.visit_path(path, pattern.id);
for field in fields {
visitor.visit_ident(field.span, field.node.ident);
visitor.visit_pat(&field.node.pat)
}
}
- PatTup(ref tuple_elements) => {
+ PatKind::Tup(ref tuple_elements) => {
walk_list!(visitor, visit_pat, tuple_elements);
}
- PatBox(ref subpattern) |
- PatRegion(ref subpattern, _) => {
+ PatKind::Box(ref subpattern) |
+ PatKind::Ref(ref subpattern, _) => {
visitor.visit_pat(subpattern)
}
- PatIdent(_, ref pth1, ref optional_subpattern) => {
+ PatKind::Ident(_, ref pth1, ref optional_subpattern) => {
visitor.visit_ident(pth1.span, pth1.node);
walk_list!(visitor, visit_pat, optional_subpattern);
}
- PatLit(ref expression) => visitor.visit_expr(expression),
- PatRange(ref lower_bound, ref upper_bound) => {
+ PatKind::Lit(ref expression) => visitor.visit_expr(expression),
+ PatKind::Range(ref lower_bound, ref upper_bound) => {
visitor.visit_expr(lower_bound);
visitor.visit_expr(upper_bound)
}
- PatWild => (),
- PatVec(ref prepatterns, ref slice_pattern, ref postpatterns) => {
+ PatKind::Wild => (),
+ PatKind::Vec(ref prepatterns, ref slice_pattern, ref postpatterns) => {
walk_list!(visitor, visit_pat, prepatterns);
walk_list!(visitor, visit_pat, slice_pattern);
walk_list!(visitor, visit_pat, postpatterns);
}
- PatMac(ref mac) => visitor.visit_mac(mac),
+ PatKind::Mac(ref mac) => visitor.visit_mac(mac),
}
}
use std::vec;
use syntax::abi::Abi;
-use syntax::ast::{EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, self};
+use syntax::ast::{self, EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, PatKind};
use syntax::ast_util;
use syntax::attr;
use syntax::attr::AttrMetaMethods;
variant,
self_arg_name,
ast::Mutability::Immutable);
- (cx.pat(sp, ast::PatRegion(p, ast::Mutability::Immutable)), idents)
+ (cx.pat(sp, PatKind::Ref(p, ast::Mutability::Immutable)), idents)
};
// A single arm has form (&VariantK, &VariantK, ...) => BodyK
-> Vec<P<ast::Pat>> {
field_paths.iter().map(|path| {
cx.pat(path.span,
- ast::PatIdent(ast::BindingMode::ByRef(mutbl), (*path).clone(), None))
+ PatKind::Ident(ast::BindingMode::ByRef(mutbl), (*path).clone(), None))
}).collect()
}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[macro_export]
+macro_rules! make_item (
+ ($name: ident) => (pub const $name: usize = 42;)
+);
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: --cfg a{b}
+// error-pattern: invalid --cfg argument: a{b}
+fn main() {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-mod Foo {
- pub static X: isize = 42;
+enum Foo {
+ X
}
-enum Foo { //~ ERROR duplicate definition of type or module `Foo`
- X
+mod Foo { //~ ERROR duplicate definition of type or module `Foo`
+ pub static X: isize = 42;
+ fn f() { f() } // Check that this does not result in a resolution error
}
fn main() {}
fn main() {
parallel! {
for i in 0..n {
- x += i; //~ ERROR no rules expected the token `+=`
- }
+ x += i; //~ ERROR expected `:`, found `+=`
+ } //~ ERROR unexpected end of macro invocation
}
}
macro_rules! ignored_expr {
() => ( 1, //~ ERROR unexpected token: `,`
- 2 ) //~ ERROR macro expansion ignores token `2`
+ 2 )
}
macro_rules! ignored_pat {
ignored_item!(); //~ NOTE caused by the macro expansion here
fn main() {
- ignored_expr!(); //~ NOTE caused by the macro expansion here
+ ignored_expr!();
match 1 {
ignored_pat!() => (), //~ NOTE caused by the macro expansion here
_ => (),
extern crate core;
mod T {
- use super::*;
+ pub use super::*;
}
fn main() {
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that we can recover from missing braces in the parser.
+
+trait Foo {
+ fn bar() {
+ let x = foo(); //~ ERROR unresolved name `foo`
+
+}
+
+fn main() {
+ let x = y.; //~ ERROR unexpected token
+ //~^ ERROR unresolved name `y`
+} //~ ERROR this file contains an un-closed delimiter
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that we can recover from mismatched braces in the parser.
+
+trait Foo {
+ fn bar() {
+ let x = foo(); //~ ERROR unresolved name `foo`
+ ) //~ ERROR incorrect close delimiter: `)`
+}
+
+fn main() {
+ let x = y.; //~ ERROR unexpected token
+ //~^ ERROR unresolved name `y`
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// compile-flags: -Z parse-only
+
fn foo() {
match x {
<T as Trait>::Type{key: value} => (),
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// FIXME(31528) we emit a bunch of silly errors here due to continuing past the
+// first one. This would be easy-ish to address by better recovery in tokenisation.
+
// compile-flags: -Z parse-only
-pub fn trace_option(option: Option<isize>) {
+pub fn trace_option(option: Option<isize>) { //~ HELP did you mean to close this delimiter?
option.map(|some| 42; //~ NOTE: unclosed delimiter
+ //~^ ERROR: expected one of
} //~ ERROR: incorrect close delimiter
+//~^ ERROR: expected one of
+//~ ERROR: this file contains an un-closed delimiter
fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {}
//~^ ERROR lifetime parameters must be declared prior to type parameters
+//~^^ ERROR unexpected token
fn foo() { //~ HELP did you mean to close this delimiter?
match Some(x) {
- Some(y) { panic!(); }
- None { panic!(); }
+ Some(y) => { panic!(); }
+ None => { panic!(); }
}
fn bar() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// compile-flags: -Z parse-only
+
fn main() {
let foo =
match //~ NOTE did you mean to remove this `match` keyword?
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// compile-flags: -Z parse-only
+
fn foo() {
match x {
<T as Trait>::Type(2) => (),
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// compile-flags: -Z parse-only
+
enum BtNode {
Node(u32,Box<BtNode>,Box<BtNode>),
Leaf(u32),
fn main() {
let Test(&desc[..]) = x; //~ error: expected one of `,` or `@`, found `[`
+ //~^ ERROR expected one of `:`, `;`, or `=`, found `..`
}
// except according to those terms.
fn main() {
- for thing(x[]) {} //~ error: expected one of `,` or `@`, found `[`
+ for thing(x[]) in foo {} //~ error: expected one of `,` or `@`, found `[`
+ //~^ ERROR: expected `in`, found `]`
}
fn main() {
for x in Foo {
x: 3 //~ ERROR expected type, found `3`
- }.hi() {
+ }.hi() { //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `{`
println!("yo");
}
}
fn main() {
if Foo {
x: 3 //~ ERROR expected type, found `3`
- }.hi() {
+ }.hi() { //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `{`
println!("yo");
}
}
} {
Foo {
x: x
- } => {}
+ } => {} //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `=>`
}
}
fn main() {
while Foo {
x: 3 //~ ERROR expected type, found `3`
- }.hi() {
+ }.hi() { //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `{`
println!("yo");
}
}
+++ /dev/null
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags: -Z parse-only
-
-extern {
- fn printf(...); //~ ERROR: variadic function must be declared with at least one named argument
- fn printf(..., foo: isize); //~ ERROR: `...` must be last in argument list for variadic function
-}
-
-fn main() {}
# Should not link dead code...
$(RUSTC) -Z print-link-args dummy.rs 2>&1 | \
- grep -e '--gc-sections\|-dead_strip\|/OPT:REF,ICF'
+ grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF,ICF'
# ... unless you specifically ask to keep it
$(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \
- (! grep -e '--gc-sections\|-dead_strip\|/OPT:REF,ICF')
+ (! grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF,ICF')
--- /dev/null
+-include ../tools.mk
+
+# Windows doesn't correctly handle include statements with escaping paths,
+# so this test will not get run on Windows.
+ifdef IS_WINDOWS
+all:
+else
+all: $(call NATIVE_STATICLIB,llvm-pass)
+ $(RUSTC) plugin.rs -C prefer-dynamic
+ $(RUSTC) main.rs
+
+$(TMPDIR)/libllvm-pass.o:
+ $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-pass.so.cc -o $(TMPDIR)/libllvm-pass.o
+endif
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "llvm/IR/Module.h"
+
+using namespace llvm;
+
+namespace {
+
+ class TestLLVMPass : public ModulePass {
+
+ public:
+
+ static char ID;
+ TestLLVMPass() : ModulePass(ID) { }
+
+ bool runOnModule(Module &M) override;
+
+ const char *getPassName() const override {
+ return "Some LLVM pass";
+ }
+
+ };
+
+}
+
+bool TestLLVMPass::runOnModule(Module &M) {
+ // A couple examples of operations that previously caused segmentation faults
+ // https://github.com/rust-lang/rust/issues/31067
+
+ for (auto F = M.begin(); F != M.end(); ++F) {
+ /* code */
+ }
+
+ LLVMContext &C = M.getContext();
+ IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
+ PointerType::get(Int8Ty, 0);
+ return true;
+}
+
+char TestLLVMPass::ID = 0;
+
+static RegisterPass<TestLLVMPass> RegisterAFLPass(
+ "some-llvm-pass", "Some LLVM pass");
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(plugin)]
+#![plugin(some_plugin)]
+
+fn main() {}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(plugin_registrar, rustc_private)]
+#![crate_type = "dylib"]
+#![crate_name = "some_plugin"]
+
+extern crate rustc;
+extern crate rustc_plugin;
+
+#[link(name = "llvm-pass", kind = "static")]
+extern {}
+
+use rustc_plugin::registry::Registry;
+
+#[plugin_registrar]
+pub fn plugin_registrar(reg: &mut Registry) {
+ reg.register_llvm_pass("some-llvm-pass");
+}
--- /dev/null
+# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+-include ../tools.mk
+
+all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
+ $(RUSTC) lib1.rs
+ $(RUSTC) lib2.rs
+ $(RUSTC) main.rs -Clto
+ $(call RUN,main)
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+int foo() {
+ return 2;
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+int foo() {
+ return 1;
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![crate_type = "rlib"]
+
+#[link(name = "foo", kind = "static")]
+extern {
+ fn foo() -> i32;
+}
+
+pub fn foo1() -> i32 {
+ unsafe { foo() }
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![crate_type = "rlib"]
+
+extern crate lib1;
+
+#[link(name = "bar", kind = "static")]
+extern {
+ fn foo() -> i32;
+}
+
+pub fn foo2() -> i32 {
+ unsafe { foo() }
+}
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern crate lib1;
+extern crate lib2;
+
+fn main() {
+ assert_eq!(lib1::foo1(), 2);
+ assert_eq!(lib2::foo2(), 2);
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::{env, fmt, process, sync, thread};
struct SlowFmt(u32);
// Test that we cleanup a fixed size Box<[D; k]> properly when D has a
// destructor.
+// ignore-emscripten no threads support
+
#![feature(const_fn)]
use std::thread;
// Test that we cleanup dynamic sized Box<[D]> properly when D has a
// destructor.
+// ignore-emscripten no threads support
+
#![feature(const_fn)]
use std::thread;
// that use capture clauses.
// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
extern crate cci_capture_clause;
// Reported as issue #126, child leaks the string.
// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
#![feature(std_misc)]
// It's unclear how likely such a bug is to recur, but it seems like a
// scenario worth testing.
+// ignore-emscripten no threads support
#![allow(unknown_features)]
#![feature(box_syntax)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
#![allow(unknown_features)]
#![feature(box_syntax, std_misc)]
let _: &Debug = &if true { false } else { true };
let _: &Debug = &match true { true => 'a', false => 'b' };
+ let _: &str = &{ String::new() };
+ let _: &str = &if true { String::from("...") } else { 5.to_string() };
+ let _: &str = &match true {
+ true => format!("{}", false),
+ false => ["x", "y"].join("+")
+ };
+
let _: Box<[isize]> = Box::new([1, 2, 3]);
let _: Box<Fn(isize) -> _> = Box::new(|x| (x as u8));
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// ignore-pretty
// compile-flags:--test
+// ignore-emscripten
// NB: These tests kill child processes. Valgrind sees these children as leaking
// memory, which makes for some *confusing* logs. That's why these are here
// except according to those terms.
// compile-flags: -Z force-dropflag-checks=off
+// ignore-emscripten no threads support
// Quick-and-dirty test to ensure -Z force-dropflag-checks=off works as
// expected. Note that the inlined drop-flag is slated for removal
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(libc)]
extern crate libc;
// make sure the stack pointers are maintained properly in both
// directions
+// ignore-emscripten no threads support
+
#![feature(libc, std_misc)]
extern crate libc;
// ignore-windows
// ignore-android
+// ignore-emscripten
#![feature(libc)]
// except according to those terms.
// ignore-aarch64
+// ignore-emscripten no threads support
+
#![feature(libc)]
extern crate libc;
// optimisation.
// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
#![feature(intrinsics, std_misc)]
// except according to those terms.
// compile-flags: -Z force-overflow-checks=on
+// ignore-emscripten no threads support
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
// This test is checking that the move_val_init intrinsic is
// respecting cleanups for both of its argument expressions.
//
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
// This test may not always fail, but it can be flaky if the race it used to
// expose is still present.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
#![feature(unboxed_closures)]
// DON'T REENABLE THIS UNLESS YOU'VE ACTUALLY FIXED THE UNDERLYING ISSUE
// ignore-android seems to block forever
+// ignore-emscripten no threads support
+
#![forbid(warnings)]
// Pretty printing tests complain about `use std::predule::*`
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
// Regression test for unwrapping the result of `join`, issue #21291
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
pub fn main() {
let f = || || 0;
std::thread::spawn(f());
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
struct Foo(i32);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(const_fn)]
// Check that the destructors of simple enums are run on unwinding
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
struct Foo;
// spawned thread to isolate the expected error result from the
// SIGTRAP injected by the drop-flag consistency checking.
+// ignore-emscripten no threads support
+
struct Foo;
impl Drop for Foo {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::sync::mpsc::channel;
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
use std::sync::mpsc::channel;
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(zero_one)]
use std::num::Zero;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::sync::mpsc::{TryRecvError, channel};
use std::thread;
// except according to those terms.
// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
#![feature(std_misc)]
// except according to those terms.
// ignore-windows
+// ignore-emscripten no threads support
// exec-env:RUST_LOG=debug
use std::cell::Cell;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
macro_rules! expr { ($e: expr) => { $e } }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
// Test that using the `vec!` macro nested within itself works when
// the contents implement Drop and we hit a panic in the middle of
// construction.
// except according to those terms.
// compile-flags: -Z no-landing-pads
-
+// ignore-emscripten no threads support
use std::thread;
// except according to those terms.
#![feature(panic_handler, std_panic)]
+// ignore-emscripten no threads support
+
use std::panic;
use std::thread;
// except according to those terms.
#![feature(panic_handler, const_fn, std_panic)]
+// ignore-emscripten no threads support
+
use std::sync::atomic::{AtomicUsize, Ordering};
use std::panic;
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_panic, recover, panic_propagate, panic_handler, const_fn)]
use std::sync::atomic::{AtomicUsize, Ordering};
// (instead of running forever), and that it does not print an error
// message about a broken pipe.
+// ignore-emscripten no threads support
+
use std::process;
use std::thread;
// except according to those terms.
// exec-env:RUST_LOG=rust_log_filter/foo
-
+// ignore-emscripten no threads support
#![allow(unknown_features)]
#![feature(box_syntax, std_misc, rustc_private)]
// except according to those terms.
// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
#![feature(std_misc)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![allow(unknown_features)]
#![feature(box_syntax)]
// ignore-bitrig
// compile-flags: -C codegen-units=3
+// ignore-emscripten no threads support
// Test unwinding through multiple compilation units.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
// Test that if a slicing expr[..] fails, the correct cleanups happen.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
// Test that if a slicing expr[..] fails, the correct cleanups happen.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
fn x(s: String, n: isize) {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
/*
Make sure we can spawn tasks that take different types of
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
pub fn main() {
// ignore-windows
// exec-env:RUST_LOG=debug
+// ignore-emscripten no threads support
// regression test for issue #10405, make sure we don't call println! too soon.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// except according to those terms.
// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
#![feature(std_misc)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::sync::mpsc::{channel, Sender};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::sync::mpsc::{channel, Sender};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
// pretty-expanded FIXME #23616
#![feature(std_misc)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
// pretty-expanded FIXME #23616
#![feature(std_misc)]
#![feature(std_misc)]
+// ignore-emscripten no threads support
// no-pretty-expanded FIXME #15189
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
#![feature(std_misc)]
#![allow(dead_assignment)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
// pretty-expanded FIXME #23616
#![feature(std_misc)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
#![allow(unknown_features)]
#![feature(box_syntax, std_misc)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(box_syntax, set_stdio)]
use std::io::prelude::*;
// ignore-bitrig system ulimit (Too many open files)
// ignore-netbsd system ulimit (Too many open files)
// ignore-openbsd system ulimit (Too many open files)
+// ignore-emscripten no threads or sockets support
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
// Issue #787
// Don't try to clean up uninitialized locals
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(std_misc)]
use std::thread;
// except according to those terms.
// no-prefer-dynamic
+// ignore-emscripten no threads support
static mut HIT: bool = false;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
#![feature(thread_local_state)]
use std::thread::{self, LocalKeyState};
// Tests that a heterogeneous list of existential types can be put inside an Arc
// and shared between threads as long as all types fulfill Send.
+// ignore-emscripten no threads support
// ignore-pretty
#![allow(unknown_features)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
#![allow(unknown_features)]
#![feature(box_syntax)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
// Make sure the destructor is run for unit-like structs.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::sync::mpsc::{channel, Sender};
use std::thread;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
#![allow(unknown_features)]
#![feature(box_syntax)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
#![feature(rand, num_bits_bytes)]
#![feature(const_fn)]
// aux-build:weak-lang-items.rs
+// ignore-emscripten no threads support
// pretty-expanded FIXME #23616
extern crate weak_lang_items as other;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-emscripten no threads support
+
use std::thread;
pub fn main() {
pub struct Bar;
impl Bar {
- // @has assoc_consts/struct.Bar.html '//*[@id="assoc_const.BAR"]' \
+ // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \
// 'const BAR: usize = 3'
pub const BAR: usize = 3;
}
extern crate issue_21092;
// @has issue_21092/struct.Bar.html
-// @has - '//*[@id="assoc_type.Bar"]' 'type Bar = i32'
+// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32'
pub use issue_21092::{Foo, Bar};
}
impl<T> Bar for Foo<T> {
- // @has - '//*[@id="assoc_type.Item"]//code' 'type Item = T'
+ // @has - '//*[@id="associatedtype.Item"]//code' 'type Item = T'
type Item=T;
// @has - '//*[@id="method.quux"]//code' 'fn quux(self)'
fn quux(self) {}
}
impl<'a, T> Bar for &'a Foo<T> {
- // @has - '//*[@id="assoc_type.Item-1"]//code' "type Item = &'a T"
+ // @has - '//*[@id="associatedtype.Item-1"]//code' "type Item = &'a T"
type Item=&'a T;
// @has - '//*[@id="method.quux-1"]//code' 'fn quux(self)'
fn quux(self) {}
}
impl<'a, T> Bar for &'a mut Foo<T> {
- // @has - '//*[@id="assoc_type.Item-2"]//code' "type Item = &'a mut T"
+ // @has - '//*[@id="associatedtype.Item-2"]//code' "type Item = &'a mut T"
type Item=&'a mut T;
// @has - '//*[@id="method.quux-2"]//code' 'fn quux(self)'
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:issue-26606-macro.rs
+// ignore-cross-compile
+// build-aux-docs
+
+// @has issue_26606_macro/macro.make_item!.html
+#[macro_use]
+extern crate issue_26606_macro;
+
+// @has issue_26606/constant.FOO.html
+// @!has - '//a/@href' '../src/'
+make_item!(FOO);
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/'
+
+/// Describe it. [Link somewhere][1].
+///
+/// [1]: http://www.rust-lang.org/
+pub fn here_is_a_fn() { }