提交 d91f8ab0 编写于 作者: B bors

Auto merge of #33487 - steveklabnik:rollup, r=steveklabnik

Rollup of 20 pull requests

- Successful merges: #33256, #33283, #33313, #33314, #33326, #33336, #33382, #33384, #33402, #33409, #33410, #33412, #33428, #33430, #33437, #33438, #33439, #33442, #33456, #33459
- Failed merges:
......@@ -15,14 +15,21 @@
.PHONY: TAGS.emacs TAGS.vi
CTAGS_LOCATIONS=$(wildcard ${CFG_SRC_DIR}src/lib*)
CTAGS_RUSTC_LOCATIONS=$(patsubst ${CFG_SRC_DIR}src/lib%test,, \
$(wildcard ${CFG_SRC_DIR}src/lib*)) ${CFG_SRC_DIR}src/libtest
CTAGS_LOCATIONS=$(patsubst ${CFG_SRC_DIR}src/librust%,, \
$(patsubst ${CFG_SRC_DIR}src/lib%test,, \
$(wildcard ${CFG_SRC_DIR}src/lib*))) ${CFG_SRC_DIR}src/libtest
CTAGS_OPTS=--options="${CFG_SRC_DIR}src/etc/ctags.rust" --languages=Rust --recurse ${CTAGS_LOCATIONS}
CTAGS_OPTS=--options="${CFG_SRC_DIR}src/etc/ctags.rust" --languages=Rust --recurse
TAGS.rustc.emacs:
ctags -e -f $@ ${CTAGS_OPTS} ${CTAGS_RUSTC_LOCATIONS}
TAGS.emacs:
ctags -e -f $@ ${CTAGS_OPTS}
ctags -e -f $@ ${CTAGS_OPTS} ${CTAGS_LOCATIONS}
TAGS.rustc.vi:
ctags -f $@ ${CTAGS_OPTS} ${CTAGS_RUSTC_LOCATIONS}
TAGS.vi:
ctags -f $@ ${CTAGS_OPTS}
ctags -f $@ ${CTAGS_OPTS} ${CTAGS_LOCATIONS}
......@@ -169,7 +169,7 @@ ifdef CFG_CCACHE_BASEDIR
export CCACHE_BASEDIR
endif
FIND_COMPILER = $(word 1,$(1:ccache=))
FIND_COMPILER = $(strip $(1:ccache=))
define CFG_MAKE_TOOLCHAIN
# Prepend the tools with their prefix if cross compiling
......@@ -187,7 +187,7 @@ define CFG_MAKE_TOOLCHAIN
endif
endif
CFG_COMPILE_C_$(1) = '$$(CC_$(1))' \
CFG_COMPILE_C_$(1) = '$$(call FIND_COMPILER,$$(CC_$(1)))' \
$$(CFLAGS) \
$$(CFG_GCCISH_CFLAGS) \
$$(CFG_GCCISH_CFLAGS_$(1)) \
......@@ -198,7 +198,7 @@ define CFG_MAKE_TOOLCHAIN
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
$$(call CFG_INSTALL_NAME_$(1),$$(4))
CFG_COMPILE_CXX_$(1) = '$$(CXX_$(1))' \
CFG_COMPILE_CXX_$(1) = '$$(call FIND_COMPILER,$$(CXX_$(1)))' \
$$(CXXFLAGS) \
$$(CFG_GCCISH_CFLAGS) \
$$(CFG_GCCISH_CXXFLAGS) \
......
......@@ -635,8 +635,8 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
--lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
--cc '$$(CC_$(2))' \
--cxx '$$(CXX_$(2))' \
--cc '$$(call FIND_COMPILER,$$(CC_$(2)))' \
--cxx '$$(call FIND_COMPILER,$$(CXX_$(2)))' \
--cflags "$$(CFG_GCCISH_CFLAGS_$(2))" \
--llvm-components "$$(LLVM_ALL_COMPONENTS_$(2))" \
--llvm-cxxflags "$$(LLVM_CXXFLAGS_$(2))" \
......
......@@ -54,7 +54,7 @@ pub unsafe fn setup() {
// Indicate that when all handles to the job object are gone that all
// process in the object should be killed. Note that this includes our
// entire process tree by default because we've added ourselves and and our
// entire process tree by default because we've added ourselves and our
// children will reside in the job by default.
let mut info = mem::zeroed::<JOBOBJECT_EXTENDED_LIMIT_INFORMATION>();
info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
......
......@@ -2063,33 +2063,41 @@ arbitrarily complex configurations through nesting.
The following configurations must be defined by the implementation:
* `debug_assertions` - Enabled by default when compiling without optimizations.
This can be used to enable extra debugging code in development but not in
production. For example, it controls the behavior of the standard library's
`debug_assert!` macro.
* `target_arch = "..."` - Target CPU architecture, such as `"x86"`, `"x86_64"`
`"mips"`, `"powerpc"`, `"powerpc64"`, `"arm"`, or `"aarch64"`.
* `target_endian = "..."` - Endianness of the target CPU, either `"little"` or
`"big"`.
* `target_env = ".."` - An option provided by the compiler by default
describing the runtime environment of the target platform. Some examples of
this are `musl` for builds targeting the MUSL libc implementation, `msvc` for
Windows builds targeting MSVC, and `gnu` frequently the rest of the time. This
option may also be blank on some platforms.
* `target_arch = "..."` - Target CPU architecture, such as `"x86"`,
`"x86_64"` `"mips"`, `"powerpc"`, `"powerpc64"`, `"arm"`, or
`"aarch64"`. This value is closely related to the first element of
the platform target triple, though it is not identical.
* `target_os = "..."` - Operating system of the target, examples
include `"windows"`, `"macos"`, `"ios"`, `"linux"`, `"android"`,
`"freebsd"`, `"dragonfly"`, `"bitrig"` , `"openbsd"` or
`"netbsd"`. This value is closely related to the second and third
element of the platform target triple, though it is not identical.
* `target_family = "..."` - Operating system family of the target, e. g.
`"unix"` or `"windows"`. The value of this configuration option is defined
as a configuration itself, like `unix` or `windows`.
* `target_os = "..."` - Operating system of the target, examples include
`"windows"`, `"macos"`, `"ios"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
`"bitrig"` , `"openbsd"` or `"netbsd"`.
* `unix` - See `target_family`.
* `windows` - See `target_family`.
* `target_env = ".."` - Further disambiguates the target platform with
information about the ABI/libc. Presently this value is either
`"gnu"`, `"msvc"`, `"musl"`, or the empty string. For historical
reasons this value has only been defined as non-empty when needed
for disambiguation. Thus on many GNU platforms this value will be
empty. This value is closely related to the fourth element of the
platform target triple, though it is not identical. For example,
embedded ABIs such as `gnueabihf` will simply define `target_env` as
`"gnu"`.
* `target_endian = "..."` - Endianness of the target CPU, either `"little"` or
`"big"`.
* `target_pointer_width = "..."` - Target pointer width in bits. This is set
to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for
64-bit pointers.
* `target_vendor = "..."` - Vendor of the target, for example `apple`, `pc`, or
simply `"unknown"`.
* `test` - Enabled when compiling the test harness (using the `--test` flag).
* `unix` - See `target_family`.
* `windows` - See `target_family`.
* `debug_assertions` - Enabled by default when compiling without optimizations.
This can be used to enable extra debugging code in development but not in
production. For example, it controls the behavior of the standard library's
`debug_assert!` macro.
You can also set another attribute based on a `cfg` variable with `cfg_attr`:
......
......@@ -419,8 +419,8 @@ pub fn windows(&self, size: usize) -> Windows<T> {
///
/// ```rust
/// let v = &[1, 2, 3, 4, 5];
/// for win in v.chunks(2) {
/// println!("{:?}", win);
/// for chunk in v.chunks(2) {
/// println!("{:?}", chunk);
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
......
......@@ -214,7 +214,7 @@ fn last(self) -> Option<Self::Item> where Self: Sized {
/// Like most indexing operations, the count starts from zero, so `nth(0)`
/// returns the first value, `nth(1)` the second, and so on.
///
/// `nth()` will return `None` if `n` is larger than the length of the
/// `nth()` will return `None` if `n` is greater than or equal to the length of the
/// iterator.
///
/// # Examples
......@@ -237,7 +237,7 @@ fn last(self) -> Option<Self::Item> where Self: Sized {
/// assert_eq!(iter.nth(1), None);
/// ```
///
/// Returning `None` if there are less than `n` elements:
/// Returning `None` if there are less than `n + 1` elements:
///
/// ```
/// let a = [1, 2, 3];
......
......@@ -37,6 +37,17 @@
/// `wrapping_add`, or through the `Wrapping<T>` type, which says that
/// all standard arithmetic operations on the underlying value are
/// intended to have wrapping semantics.
///
/// # Examples
///
/// ```
/// use std::num::Wrapping;
///
/// let zero = Wrapping(0u32);
/// let one = Wrapping(1u32);
///
/// assert_eq!(std::u32::MAX, (zero - one).0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
......
......@@ -176,6 +176,9 @@ pub fn main(swap_in: Receiver<Vec<DepMessage>>,
DepMessage::Query => query_out.send(edges.query()).unwrap(),
}
}
swap_out.send(messages).unwrap();
if let Err(_) = swap_out.send(messages) {
// the receiver must have been dropped already
break;
}
}
}
......@@ -1355,7 +1355,7 @@ pub fn check_nightly_options(matches: &getopts::Matches, flags: &[RustcOptGroup]
early_error(ErrorOutputType::default(), &msg);
}
OptionStability::UnstableButNotReally => {
let msg = format!("the option `{}` is is unstable and should \
let msg = format!("the option `{}` is unstable and should \
only be used on the nightly compiler, but \
it is currently accepted for backwards \
compatibility; this will soon change, \
......
......@@ -40,7 +40,7 @@
pub enum ProjectionMode {
/// FIXME (#32205)
/// At coherence-checking time, we're still constructing the
/// specialization graph, and thus we only project project
/// specialization graph, and thus we only project
/// non-`default` associated types that are defined directly in
/// the applicable impl. (This behavior should be improved over
/// time, to allow for successful projections modulo cycles
......
......@@ -176,7 +176,7 @@ pub fn record_local_impl(&self,
/// Records a trait-to-implementation mapping for a non-local impl.
///
/// The `parent_impl` is the immediately-less-specialized impl, or the
/// trait's def ID if the impl is is not a specialization -- information that
/// trait's def ID if the impl is not a specialization -- information that
/// should be pulled from the metadata.
pub fn record_remote_impl(&self,
tcx: &TyCtxt<'tcx>,
......
......@@ -272,7 +272,7 @@ fn compute_trait_ref(&mut self, trait_ref: &ty::TraitRef<'tcx>) {
/// into `self.out`.
fn compute_projection(&mut self, data: ty::ProjectionTy<'tcx>) {
// A projection is well-formed if (a) the trait ref itself is
// WF WF and (b) the trait-ref holds. (It may also be
// WF and (b) the trait-ref holds. (It may also be
// normalizable and be WF that way.)
self.compute_trait_ref(&data.trait_ref);
......
......@@ -202,7 +202,7 @@ pub struct TargetOptions {
pub post_link_args: Vec<String>,
/// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults
/// to "default".
/// to "generic".
pub cpu: String,
/// Default target features to pass to LLVM. These features will *always* be
/// passed, and cannot be disabled even via `-C`. Corresponds to `llc
......
......@@ -286,6 +286,70 @@ fn mutable() {
https://doc.rust-lang.org/std/cell/
"##,
E0389: r##"
An attempt was made to mutate data using a non-mutable reference. This
commonly occurs when attempting to assign to a non-mutable reference of a
mutable reference (`&(&mut T)`).
Example of erroneous code:
```compile_fail
struct FancyNum {
num: u8
}
fn main() {
let mut fancy = FancyNum{ num: 5 };
let fancy_ref = &(&mut fancy);
fancy_ref.num = 6; // error: cannot assign to data in a `&` reference
println!("{}", fancy_ref.num);
}
```
Here, `&mut fancy` is mutable, but `&(&mut fancy)` is not. Creating an
immutable reference to a value borrows it immutably. There can be multiple
references of type `&(&mut T)` that point to the same value, so they must be
immutable to prevent multiple mutable references to the same value.
To fix this, either remove the outer reference:
```
struct FancyNum {
num: u8
}
fn main() {
let mut fancy = FancyNum{ num: 5 };
let fancy_ref = &mut fancy;
// `fancy_ref` is now &mut FancyNum, rather than &(&mut FancyNum)
fancy_ref.num = 6; // No error!
println!("{}", fancy_ref.num);
}
```
Or make the outer reference mutable:
```
struct FancyNum {
num: u8
}
fn main() {
let mut fancy = FancyNum{ num: 5 };
let fancy_ref = &mut (&mut fancy);
// `fancy_ref` is now &mut(&mut FancyNum), rather than &(&mut FancyNum)
fancy_ref.num = 6; // No error!
println!("{}", fancy_ref.num);
}
```
"##,
E0499: r##"
A variable was borrowed as mutable more than once. Erroneous code example:
......@@ -390,6 +454,90 @@ fn foo(a: &mut i32) {
```
"##,
E0506: r##"
This error occurs when an attempt is made to assign to a borrowed value.
Example of erroneous code:
```compile_fail
struct FancyNum {
num: u8
}
fn main() {
let mut fancy_num = FancyNum { num: 5 };
let fancy_ref = &fancy_num;
fancy_num = FancyNum { num: 6 };
// error: cannot assign to `fancy_num` because it is borrowed
println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
}
```
Because `fancy_ref` still holds a reference to `fancy_num`, `fancy_num` can't
be assigned to a new value as it would invalidate the reference.
Alternatively, we can move out of `fancy_num` into a second `fancy_num`:
```
struct FancyNum {
num: u8
}
fn main() {
let mut fancy_num = FancyNum { num: 5 };
let moved_num = fancy_num;
fancy_num = FancyNum { num: 6 };
println!("Num: {}, Moved num: {}", fancy_num.num, moved_num.num);
}
```
If the value has to be borrowed, try limiting the lifetime of the borrow using
a scoped block:
```
struct FancyNum {
num: u8
}
fn main() {
let mut fancy_num = FancyNum { num: 5 };
{
let fancy_ref = &fancy_num;
println!("Ref: {}", fancy_ref.num);
}
// Works because `fancy_ref` is no longer in scope
fancy_num = FancyNum { num: 6 };
println!("Num: {}", fancy_num.num);
}
```
Or by moving the reference into a function:
```
struct FancyNum {
num: u8
}
fn main() {
let mut fancy_num = FancyNum { num: 5 };
print_fancy_ref(&fancy_num);
// Works because function borrow has ended
fancy_num = FancyNum { num: 6 };
println!("Num: {}", fancy_num.num);
}
fn print_fancy_ref(fancy_ref: &FancyNum){
println!("Ref: {}", fancy_ref.num);
}
```
"##,
E0507: r##"
You tried to move out of a value which was borrowed. Erroneous code example:
......@@ -510,13 +658,11 @@ fn main() {
register_diagnostics! {
E0385, // {} in an aliasable location
E0388, // {} in a static location
E0389, // {} in a `&` reference
E0500, // closure requires unique access to `..` but .. is already borrowed
E0502, // cannot borrow `..`.. as .. because .. is also borrowed as ...
E0503, // cannot use `..` because it was mutably borrowed
E0504, // cannot move `..` into closure because it is borrowed
E0505, // cannot move out of `..` because it is borrowed
E0506, // cannot assign to `..` because it is borrowed
E0508, // cannot move out of type `..`, a non-copy fixed-size array
E0509, // cannot move out of type `..`, which defines the `Drop` trait
E0524, // two closures require unique access to `..` at the same time
......
......@@ -352,7 +352,13 @@ fn handle_explain(code: &str,
match descriptions.find_description(&normalised) {
Some(ref description) => {
// Slice off the leading newline and print.
print!("{}", &description[1..]);
print!("{}", &(&description[1..]).split("\n").map(|x| {
format!("{}\n", if x.starts_with("```") {
"```"
} else {
x
})
}).collect::<String>());
}
None => {
early_error(output, &format!("no extended information for {}", code));
......
......@@ -1327,7 +1327,7 @@ fn generate_filter_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
// %ret = call i32 @the_real_filter_function(%ehptrs, %arg)
// ret i32 %ret
//
// The recoverfp intrinsic is used to recover the frame frame pointer of the
// The recoverfp intrinsic is used to recover the frame pointer of the
// `rust_try_fn` function, which is then in turn passed to the
// `localrecover` intrinsic (pairing with the `localescape` intrinsic
// mentioned above). Putting all this together means that we now have a
......
......@@ -145,14 +145,19 @@ pub struct Implementor {
/// Metadata about implementations for a type.
#[derive(Clone)]
pub struct Impl {
pub impl_: clean::Impl,
pub dox: Option<String>,
pub stability: Option<clean::Stability>,
pub impl_item: clean::Item,
}
impl Impl {
fn inner_impl(&self) -> &clean::Impl {
match self.impl_item.inner {
clean::ImplItem(ref impl_) => impl_,
_ => panic!("non-impl item found in impl")
}
}
fn trait_did(&self) -> Option<DefId> {
self.impl_.trait_.def_id()
self.inner_impl().trait_.def_id()
}
}
......@@ -1189,31 +1194,34 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// Once we've recursively found all the generics, then hoard off all the
// implementations elsewhere
let ret = self.fold_item_recur(item).and_then(|item| {
if let clean::Item { attrs, inner: clean::ImplItem(i), .. } = item {
if let clean::Item { inner: clean::ImplItem(_), .. } = item {
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
let did = match i.for_ {
clean::ResolvedPath { did, .. } |
clean::BorrowedRef {
type_: box clean::ResolvedPath { did, .. }, ..
} => {
Some(did)
}
ref t => {
t.primitive_type().and_then(|t| {
self.primitive_locations.get(&t).map(|n| {
let id = t.to_def_index();
DefId { krate: *n, index: id }
// Note: matching twice to restrict the lifetime of the `i` borrow.
let did = if let clean::Item { inner: clean::ImplItem(ref i), .. } = item {
match i.for_ {
clean::ResolvedPath { did, .. } |
clean::BorrowedRef {
type_: box clean::ResolvedPath { did, .. }, ..
} => {
Some(did)
}
ref t => {
t.primitive_type().and_then(|t| {
self.primitive_locations.get(&t).map(|n| {
let id = t.to_def_index();
DefId { krate: *n, index: id }
})
})
})
}
}
} else {
unreachable!()
};
if !self.seen_mod {
if let Some(did) = did {
self.impls.entry(did).or_insert(vec![]).push(Impl {
impl_: i,
dox: attrs.value("doc").map(|s|s.to_owned()),
stability: item.stability.clone(),
impl_item: item,
});
}
}
......@@ -1510,11 +1518,15 @@ fn href(&self) -> Option<String> {
// located, then we return `None`.
} else {
let cache = cache();
let path = &cache.external_paths[&self.item.def_id];
let root = match cache.extern_locations[&self.item.def_id.krate] {
(_, Remote(ref s)) => s.to_string(),
(_, Local) => self.cx.root_path.clone(),
(_, Unknown) => return None,
let path = match cache.external_paths.get(&self.item.def_id) {
Some(path) => path,
None => return None,
};
let root = match cache.extern_locations.get(&self.item.def_id.krate) {
Some(&(_, Remote(ref s))) => s.to_string(),
Some(&(_, Local)) => self.cx.root_path.clone(),
Some(&(_, Unknown)) => return None,
None => return None,
};
Some(format!("{root}{path}/{file}?gotosrc={goto}",
root = root,
......@@ -2449,7 +2461,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
None => return Ok(()),
};
let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| {
i.impl_.trait_.is_none()
i.inner_impl().trait_.is_none()
});
if !non_trait.is_empty() {
let render_header = match what {
......@@ -2473,7 +2485,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
}
if !traits.is_empty() {
let deref_impl = traits.iter().find(|t| {
t.impl_.trait_.def_id() == c.deref_trait_did
t.inner_impl().trait_.def_id() == c.deref_trait_did
});
if let Some(impl_) = deref_impl {
render_deref_methods(w, cx, impl_, containing_item)?;
......@@ -2481,11 +2493,11 @@ fn render_assoc_items(w: &mut fmt::Formatter,
write!(w, "<h2 id='implementations'>Trait \
Implementations</h2>")?;
let (derived, manual): (Vec<_>, Vec<&Impl>) = traits.iter().partition(|i| {
i.impl_.derived
i.inner_impl().derived
});
for i in &manual {
let did = i.trait_did().unwrap();
let assoc_link = AssocItemLink::GotoSource(did, &i.impl_.provided_trait_methods);
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
render_impl(w, cx, i, assoc_link, true, containing_item.stable_since())?;
}
if !derived.is_empty() {
......@@ -2494,7 +2506,8 @@ fn render_assoc_items(w: &mut fmt::Formatter,
</h3>")?;
for i in &derived {
let did = i.trait_did().unwrap();
let assoc_link = AssocItemLink::GotoSource(did, &i.impl_.provided_trait_methods);
let assoc_link = AssocItemLink::GotoSource(did,
&i.inner_impl().provided_trait_methods);
render_impl(w, cx, i, assoc_link, true, containing_item.stable_since())?;
}
}
......@@ -2504,8 +2517,8 @@ fn render_assoc_items(w: &mut fmt::Formatter,
fn render_deref_methods(w: &mut fmt::Formatter, cx: &Context, impl_: &Impl,
container_item: &clean::Item) -> fmt::Result {
let deref_type = impl_.impl_.trait_.as_ref().unwrap();
let target = impl_.impl_.items.iter().filter_map(|item| {
let deref_type = impl_.inner_impl().trait_.as_ref().unwrap();
let target = impl_.inner_impl().items.iter().filter_map(|item| {
match item.inner {
clean::TypedefItem(ref t, true) => Some(&t.type_),
_ => None,
......@@ -2531,11 +2544,18 @@ fn render_deref_methods(w: &mut fmt::Formatter, cx: &Context, impl_: &Impl,
fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLink,
render_header: bool, outer_version: Option<&str>) -> fmt::Result {
if render_header {
write!(w, "<h3 class='impl'><code>{}</code>", i.impl_)?;
let since = i.stability.as_ref().map(|s| &s.since[..]);
write!(w, "<h3 class='impl'><span class='in-band'><code>{}</code>", i.inner_impl())?;
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
render_stability_since_raw(w, since, outer_version)?;
write!(w, "</h3>")?;
if let Some(ref dox) = i.dox {
write!(w, "</span><span class='out-of-band'>")?;
if let Some(l) = (Item { item: &i.impl_item, cx: cx }).href() {
write!(w, "<a id='src-{}' class='srclink' \
href='{}' title='{}'>[src]</a>",
i.impl_item.def_id.index.as_usize(), l, "goto source code")?;
}
write!(w, "</span>")?;
write!(w, "</h3>\n")?;
if let Some(ref dox) = i.impl_item.attrs.value("doc") {
write!(w, "<div class='docblock'>{}</div>", Markdown(dox))?;
}
}
......@@ -2601,7 +2621,7 @@ fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
}
write!(w, "<div class='impl-items'>")?;
for trait_item in &i.impl_.items {
for trait_item in &i.inner_impl().items {
doctraititem(w, cx, trait_item, link, render_header, false, outer_version)?;
}
......@@ -2629,7 +2649,7 @@ fn render_default_items(w: &mut fmt::Formatter,
// default items which weren't overridden in the implementation block.
if let Some(did) = i.trait_did() {
if let Some(t) = cache().traits.get(&did) {
render_default_items(w, cx, t, &i.impl_, render_header, outer_version)?;
render_default_items(w, cx, t, &i.inner_impl(), render_header, outer_version)?;
}
}
write!(w, "</div>")?;
......
......@@ -182,11 +182,10 @@
//!
//! # fn foo() -> io::Result<()> {
//! let f = try!(File::open("foo.txt"));
//! let mut reader = BufReader::new(f);
//! let reader = BufReader::new(f);
//!
//! for line in reader.lines() {
//! let line = try!(line);
//! println!("{}", line);
//! println!("{}", try!(line));
//! }
//!
//! # Ok(())
......
......@@ -89,7 +89,7 @@ pub fn is_unspecified(&self) -> bool {
/// Returns true if this is a loopback address (127.0.0.0/8).
///
/// This property is defined by RFC 6890
/// This property is defined by RFC 6890.
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_loopback(&self) -> bool {
self.octets()[0] == 127
......@@ -97,7 +97,7 @@ pub fn is_loopback(&self) -> bool {
/// Returns true if this is a private address.
///
/// The private address ranges are defined in RFC1918 and include:
/// The private address ranges are defined in RFC 1918 and include:
///
/// - 10.0.0.0/8
/// - 172.16.0.0/12
......@@ -114,7 +114,7 @@ pub fn is_private(&self) -> bool {
/// Returns true if the address is link-local (169.254.0.0/16).
///
/// This property is defined by RFC 6890
/// This property is defined by RFC 6890.
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_link_local(&self) -> bool {
self.octets()[0] == 169 && self.octets()[1] == 254
......@@ -140,7 +140,7 @@ pub fn is_global(&self) -> bool {
/// Returns true if this is a multicast address.
///
/// Multicast addresses have a most significant octet between 224 and 239,
/// and is defined by RFC 5771
/// and is defined by RFC 5771.
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_multicast(&self) -> bool {
self.octets()[0] >= 224 && self.octets()[0] <= 239
......@@ -354,7 +354,7 @@ pub fn is_global(&self) -> bool {
/// Returns true if this is a unique local address (IPv6).
///
/// Unique local addresses are defined in RFC4193 and have the form fc00::/7.
/// Unique local addresses are defined in RFC 4193 and have the form fc00::/7.
pub fn is_unique_local(&self) -> bool {
(self.segments()[0] & 0xfe00) == 0xfc00
}
......@@ -371,7 +371,7 @@ pub fn is_unicast_site_local(&self) -> bool {
}
/// Returns true if this is an address reserved for documentation
/// This is defined to be 2001:db8::/32 in RFC RFC 3849
/// This is defined to be 2001:db8::/32 in RFC 3849.
pub fn is_documentation(&self) -> bool {
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
}
......
......@@ -215,12 +215,38 @@ impl Command {
///
/// Builder methods are provided to change these defaults and
/// otherwise configure the process.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("sh")
/// .spawn()
/// .expect("sh command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn new<S: AsRef<OsStr>>(program: S) -> Command {
Command { inner: imp::Command::new(program.as_ref()) }
}
/// Add an argument to pass to the program.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("ls")
/// .arg("-l")
/// .arg("-a")
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Command {
self.inner.arg(arg.as_ref());
......@@ -228,6 +254,19 @@ pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Command {
}
/// Add multiple arguments to pass to the program.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("ls")
/// .args(&["-l", "-a"])
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut Command {
for arg in args {
......@@ -240,6 +279,19 @@ pub fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut Command {
///
/// Note that environment variable names are case-insensitive (but case-preserving) on Windows,
/// and case-sensitive on all other platforms.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("ls")
/// .env("PATH", "/bin")
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn env<K, V>(&mut self, key: K, val: V) -> &mut Command
where K: AsRef<OsStr>, V: AsRef<OsStr>
......@@ -249,6 +301,19 @@ pub fn env<K, V>(&mut self, key: K, val: V) -> &mut Command
}
/// Removes an environment variable mapping.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("ls")
/// .env_remove("PATH")
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn env_remove<K: AsRef<OsStr>>(&mut self, key: K) -> &mut Command {
self.inner.env_remove(key.as_ref());
......@@ -256,6 +321,19 @@ pub fn env_remove<K: AsRef<OsStr>>(&mut self, key: K) -> &mut Command {
}
/// Clears the entire environment map for the child process.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("ls")
/// .env_clear()
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn env_clear(&mut self) -> &mut Command {
self.inner.env_clear();
......@@ -263,6 +341,19 @@ pub fn env_clear(&mut self) -> &mut Command {
}
/// Sets the working directory for the child process.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("ls")
/// .current_dir("/bin")
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Command {
self.inner.cwd(dir.as_ref().as_ref());
......@@ -270,6 +361,19 @@ pub fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Command {
}
/// Configuration for the child process's stdin handle (file descriptor 0).
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::{Command, Stdio};
///
/// Command::new("ls")
/// .stdin(Stdio::null())
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn stdin(&mut self, cfg: Stdio) -> &mut Command {
self.inner.stdin(cfg.0);
......@@ -277,6 +381,19 @@ pub fn stdin(&mut self, cfg: Stdio) -> &mut Command {
}
/// Configuration for the child process's stdout handle (file descriptor 1).
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::{Command, Stdio};
///
/// Command::new("ls")
/// .stdout(Stdio::null())
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn stdout(&mut self, cfg: Stdio) -> &mut Command {
self.inner.stdout(cfg.0);
......@@ -284,6 +401,19 @@ pub fn stdout(&mut self, cfg: Stdio) -> &mut Command {
}
/// Configuration for the child process's stderr handle (file descriptor 2).
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::{Command, Stdio};
///
/// Command::new("ls")
/// .stderr(Stdio::null())
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn stderr(&mut self, cfg: Stdio) -> &mut Command {
self.inner.stderr(cfg.0);
......@@ -293,6 +423,18 @@ pub fn stderr(&mut self, cfg: Stdio) -> &mut Command {
/// Executes the command as a child process, returning a handle to it.
///
/// By default, stdin, stdout and stderr are inherited from the parent.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// Command::new("ls")
/// .spawn()
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn spawn(&mut self) -> io::Result<Child> {
self.inner.spawn(imp::Stdio::Inherit, true).map(Child::from_inner)
......@@ -308,8 +450,10 @@ pub fn spawn(&mut self) -> io::Result<Child> {
///
/// ```should_panic
/// use std::process::Command;
/// let output = Command::new("/bin/cat").arg("file.txt").output()
/// .expect("failed to execute process");
/// let output = Command::new("/bin/cat")
/// .arg("file.txt")
/// .output()
/// .expect("failed to execute process");
///
/// println!("status: {}", output.status);
/// println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
......@@ -333,8 +477,10 @@ pub fn output(&mut self) -> io::Result<Output> {
/// ```should_panic
/// use std::process::Command;
///
/// let status = Command::new("/bin/cat").arg("file.txt").status()
/// .expect("failed to execute process");
/// let status = Command::new("/bin/cat")
/// .arg("file.txt")
/// .status()
/// .expect("failed to execute process");
///
/// println!("process exited with: {}", status);
///
......@@ -469,12 +615,42 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl Child {
/// Forces the child to exit. This is equivalent to sending a
/// SIGKILL on unix platforms.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// let mut command = Command::new("yes");
/// if let Ok(mut child) = command.spawn() {
/// child.kill().expect("command wasn't running");
/// } else {
/// println!("yes command didn't start");
/// }
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn kill(&mut self) -> io::Result<()> {
self.handle.kill()
}
/// Returns the OS-assigned process identifier associated with this child.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// let mut command = Command::new("ls");
/// if let Ok(child) = command.spawn() {
/// println!("Child's id is {}", child.id());
/// } else {
/// println!("ls command didn't start");
/// }
/// ```
#[stable(feature = "process_id", since = "1.3.0")]
pub fn id(&self) -> u32 {
self.handle.id()
......@@ -488,6 +664,22 @@ pub fn id(&self) -> u32 {
/// before waiting. This helps avoid deadlock: it ensures that the
/// child does not block waiting for input from the parent, while
/// the parent waits for the child to exit.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// use std::process::Command;
///
/// let mut command = Command::new("ls");
/// if let Ok(mut child) = command.spawn() {
/// child.wait().expect("command wasn't running");
/// println!("Child has finished its execution!");
/// } else {
/// println!("ls command didn't start");
/// }
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn wait(&mut self) -> io::Result<ExitStatus> {
drop(self.stdin.take());
......
......@@ -71,7 +71,7 @@ pub fn new(n: usize) -> Barrier {
}
}
/// Blocks the current thread until all threads has rendezvoused here.
/// Blocks the current thread until all threads have rendezvoused here.
///
/// Barriers are re-usable after all threads have rendezvoused once, and can
/// be used continuously.
......
......@@ -38,8 +38,8 @@
///
/// # Poisoning
///
/// RwLocks, like Mutexes, will become poisoned on panics. Note, however, that
/// an RwLock may only be poisoned if a panic occurs while it is locked
/// An `RwLock`, like `Mutex`, will become poisoned on a panic. Note, however,
/// that an `RwLock` may only be poisoned if a panic occurs while it is locked
/// exclusively (write mode). If a panic occurs in any reader, then the lock
/// will not be poisoned.
///
......
......@@ -147,7 +147,7 @@ pub fn env(&mut self, key: &OsStr, val: &OsStr) {
let new_key = pair_to_key(key, val, &mut self.saw_nul);
let (map, envp) = self.init_env_map();
// If `key` is already present then we we just update `envp` in place
// If `key` is already present then we just update `envp` in place
// (and store the owned value), but if it's not there we override the
// trailing NULL pointer, add a new NULL pointer, and store where we
// were located.
......
......@@ -13,7 +13,8 @@
//! ## The threading model
//!
//! An executing Rust program consists of a collection of native OS threads,
//! each with their own stack and local state.
//! each with their own stack and local state. Threads can be named, and
//! provide some built-in support for low-level synchronization.
//!
//! Communication between threads can be done through
//! [channels](../../std/sync/mpsc/index.html), Rust's message-passing
......@@ -37,20 +38,6 @@
//! convenient facilities for automatically waiting for the termination of a
//! child thread (i.e., join).
//!
//! ## The `Thread` type
//!
//! Threads are represented via the `Thread` type, which you can
//! get in one of two ways:
//!
//! * By spawning a new thread, e.g. using the `thread::spawn` function.
//! * By requesting the current thread, using the `thread::current` function.
//!
//! Threads can be named, and provide some built-in support for low-level
//! synchronization (described below).
//!
//! The `thread::current()` function is available even for threads not spawned
//! by the APIs of this module.
//!
//! ## Spawning a thread
//!
//! A new thread can be spawned using the `thread::spawn` function:
......@@ -99,6 +86,18 @@
//! });
//! ```
//!
//! ## The `Thread` type
//!
//! Threads are represented via the `Thread` type, which you can get in one of
//! two ways:
//!
//! * By spawning a new thread, e.g. using the `thread::spawn` function, and
//! calling `thread()` on the `JoinHandle`.
//! * By requesting the current thread, using the `thread::current` function.
//!
//! The `thread::current()` function is available even for threads not spawned
//! by the APIs of this module.
//!
//! ## Blocking support: park and unpark
//!
//! Every thread is equipped with some basic low-level blocking support, via the
......
......@@ -6013,7 +6013,7 @@ fn parse_foreign_item(&mut self) -> PResult<'a, Option<ForeignItem>> {
// FOREIGN STATIC ITEM
return Ok(Some(self.parse_item_foreign_static(visibility, lo, attrs)?));
}
if self.check_keyword(keywords::Fn) || self.check_keyword(keywords::Unsafe) {
if self.check_keyword(keywords::Fn) {
// FOREIGN FUNCTION ITEM
return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?));
}
......
......@@ -27,7 +27,7 @@ fn main() {
//~ TRANS_ITEM fn cgu_extern_closures::inlined_fn_generic[0]::{{closure}}[0]<i32>
let _ = cgu_extern_closures::inlined_fn_generic(3, 4, 5i32);
// Nothing should be generated for this call, we just link to the instance instance
// Nothing should be generated for this call, we just link to the instance
// in the extern crate.
let _ = cgu_extern_closures::non_inlined_fn(6, 7);
}
......
......@@ -11,7 +11,7 @@
// compile-flags: -Z parse-only
extern {
f(); //~ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `f`
f(); //~ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `f`
}
fn main() {
......
......@@ -12,5 +12,5 @@
extern {
const i: isize;
//~^ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `const`
//~^ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `const`
}
......@@ -9,7 +9,7 @@
// except according to those terms.
// Test a corner case of LUB coercion. In this case, one arm of the
// match requires a deref coercion and other other doesn't, and there
// match requires a deref coercion and the other doesn't, and there
// is an extra `&` on the `rc`. We want to be sure that the lifetime
// assigned to this `&rc` value is not `'a` but something smaller. In
// other words, the type from `rc` is `&'a Rc<String>` and the type
......
......@@ -110,7 +110,7 @@ fn walk(cache: &mut Cache,
if let Some(pretty_path) = pretty_path {
let entry = cache.get_mut(&pretty_path).unwrap();
// we don't need the source anymore,
// so drop to to reduce memory-usage
// so drop to reduce memory-usage
entry.source = String::new();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册