From 1275c1102ef2c9b7a52f9487a62e98f99b7a0a34 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 24 Feb 2015 15:36:46 +0100 Subject: [PATCH 01/18] fix rustdoc performance problems Fixes #22325 --- src/librustdoc/html/static/main.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index aac3985f0cc9c..4e2e623c771db 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -33,23 +33,6 @@ return window.history && typeof window.history.pushState === "function"; } - function resizeShortBlocks() { - if (resizeTimeout) { - clearTimeout(resizeTimeout); - } - resizeTimeout = setTimeout(function() { - var contentWidth = $('.content').width(); - $('.docblock.short').width(function() { - return contentWidth - 40 - $(this).prev().width(); - }).addClass('nowrap'); - $('.summary-column').width(function() { - return contentWidth - 40 - $(this).prev().width(); - }) - }, 150); - } - resizeShortBlocks(); - $(window).on('resize', resizeShortBlocks); - function highlightSourceLines(ev) { var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/); if (match) { From 660b48fae5f54c4a4994b8c23550f580927775ab Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 10 Mar 2015 01:46:45 +0100 Subject: [PATCH 02/18] Add support for target-cpu=native --- src/rustllvm/PassWrapper.cpp | 8 +++++++- src/test/run-make/target-cpu-native/Makefile | 5 +++++ src/test/run-make/target-cpu-native/foo.rs | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/test/run-make/target-cpu-native/Makefile create mode 100644 src/test/run-make/target-cpu-native/foo.rs diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index ce3090390db8e..b205d87598cfe 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Host.h" #include "llvm/Target/TargetLibraryInfo.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" @@ -83,6 +84,11 @@ LLVMRustCreateTargetMachine(const char *triple, return NULL; } + StringRef real_cpu = cpu; + if (real_cpu == "native") { + real_cpu = sys::getHostCPUName(); + } + TargetOptions Options; Options.PositionIndependentExecutable = PositionIndependentExecutable; Options.NoFramePointerElim = NoFramePointerElim; @@ -96,7 +102,7 @@ LLVMRustCreateTargetMachine(const char *triple, } TargetMachine *TM = TheTarget->createTargetMachine(Trip.getTriple(), - cpu, + real_cpu, feature, Options, RM, diff --git a/src/test/run-make/target-cpu-native/Makefile b/src/test/run-make/target-cpu-native/Makefile new file mode 100644 index 0000000000000..0c9d93ecb2af7 --- /dev/null +++ b/src/test/run-make/target-cpu-native/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -C target-cpu=native + $(call RUN,foo) diff --git a/src/test/run-make/target-cpu-native/foo.rs b/src/test/run-make/target-cpu-native/foo.rs new file mode 100644 index 0000000000000..f7a9f969060ae --- /dev/null +++ b/src/test/run-make/target-cpu-native/foo.rs @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { +} From fcae449b39e5c61fa24a8c5e4d1d8a701f6d4ee1 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Tue, 10 Mar 2015 11:36:11 +0100 Subject: [PATCH 03/18] Purge `isize` from `core::iter` --- src/libcore/iter.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 88a729a3db09e..312778b2a1036 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -488,7 +488,7 @@ pub trait IteratorExt: Iterator + Sized { /// # Examples /// /// ``` - /// fn process>(it: U) -> isize { + /// fn process>(it: U) -> i32 { /// let mut it = it.fuse(); /// let mut sum = 0; /// for x in it.by_ref() { @@ -796,7 +796,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` /// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax}; /// - /// let a: [isize; 0] = []; + /// let a: [i32; 0] = []; /// assert_eq!(a.iter().min_max(), NoElements); /// /// let a = [1]; @@ -1246,7 +1246,7 @@ impl MinMaxResult { /// ``` /// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax}; /// - /// let r: MinMaxResult = NoElements; + /// let r: MinMaxResult = NoElements; /// assert_eq!(r.into_option(), None); /// /// let r = OneElement(1); From fbc10c3851c4fbaf463275ad7b667111da077ff9 Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Mon, 9 Mar 2015 16:33:48 -0400 Subject: [PATCH 04/18] configure: have --enable-debug set -C debug-assertions=on so `debug!()` works again --- mk/main.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/main.mk b/mk/main.mk index c00494be47cb7..4bfc65ad843d1 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -130,7 +130,7 @@ ifdef CFG_DISABLE_DEBUG CFG_RUSTC_FLAGS += --cfg ndebug else $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG)) - CFG_RUSTC_FLAGS += --cfg debug + CFG_RUSTC_FLAGS += --cfg debug -C debug-assertions=on endif ifdef SAVE_TEMPS From 0ad874111ef093e95e5f89862902bdd51c54a878 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 10 Mar 2015 13:45:08 -0700 Subject: [PATCH 05/18] std: Stabilize slice::from_raw_parts These new APIs have had some time to bake now, and no pressing issues have come up so they should be ok for stabilizing. Specifically, these two APIs were stabilized: * `slice::from_raw_parts` * `slice::from_raw_parts_mut` --- src/libcore/slice.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 1f58d7753549d..09b8832575171 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1446,7 +1446,7 @@ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { /// } /// ``` #[inline] -#[unstable(feature = "core")] +#[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts<'a, T>(p: *const T, len: usize) -> &'a [T] { transmute(RawSlice { data: p, len: len }) } @@ -1458,7 +1458,7 @@ pub unsafe fn from_raw_parts<'a, T>(p: *const T, len: usize) -> &'a [T] { /// as not being able to provide a non-aliasing guarantee of the returned /// mutable slice. #[inline] -#[unstable(feature = "core")] +#[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] { transmute(RawSlice { data: p, len: len }) } From d6492e24691751a54daa55c47c7062cc8b50faaf Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 10 Mar 2015 22:47:08 -0400 Subject: [PATCH 06/18] Fix markdown bullet points in function docs Markdown requires a newline before bullet points, and since there's not one here, they'll get rendered incorrectly --- src/libcollections/string.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 83c63e47e506b..cc7cd0509029f 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -314,6 +314,7 @@ impl String { /// Creates a new `String` from a length, capacity, and pointer. /// /// This is unsafe because: + /// /// * We call `Vec::from_raw_parts` to get a `Vec`; /// * We assume that the `Vec` contains valid UTF-8. #[inline] From 8e082f77cf71ad7651820b93ec0a2b7f5ff62769 Mon Sep 17 00:00:00 2001 From: Dave Huseby Date: Tue, 10 Mar 2015 10:20:05 -0700 Subject: [PATCH 07/18] disabling jemalloc on bitrig --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index b0d0c3f29b84a..73e09158539aa 100755 --- a/configure +++ b/configure @@ -760,8 +760,9 @@ fi # Force bitrig to build with clang; gcc doesn't like us there if [ $CFG_OSTYPE = unknown-bitrig ] then - step_msg "on Bitrig, forcing use of clang" + step_msg "on Bitrig, forcing use of clang, disabling jemalloc" CFG_ENABLE_CLANG=1 + CFG_ENABLE_JEMALLOC=0 fi if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ] From 33751ff8a7e2e013609d79f43da3d9a6d2c1f71e Mon Sep 17 00:00:00 2001 From: Dave Huseby Date: Tue, 10 Mar 2015 10:59:46 -0700 Subject: [PATCH 08/18] adding latest bitrig snapshot manually --- src/snapshots.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/snapshots.txt b/src/snapshots.txt index 35f46ca6d3299..a84067539e95c 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,4 +1,5 @@ S 2015-03-07 270a677 + bitrig-x86_64 4b2f11a96b1b5b3782d74bda707aca33bc179880 freebsd-x86_64 3c147d8e4cfdcb02c2569f5aca689a1d8920d17b linux-i386 50a47ef247610fb089d2c4f24e4b641eb0ba4afb linux-x86_64 ccb20709b3c984f960ddde996451be8ce2268d7c From 61004f88d1a250d2086c0ad28f005380a6a64f9f Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Wed, 11 Mar 2015 01:42:00 -0700 Subject: [PATCH 09/18] Improve -Z unstable-options diagnostics and avoid an ICE * Consumers of handle_options assume the unstable options are defined in the getopts::Matches value if -Z unstable-options is set, but that's not the case if there weren't any actual unstable options. Fix this by always reparsing options when -Z unstable-options is set. * If both argument parsing attempts fail, print the error from the second attempt rather than the first. The error from the first is very poor whenever unstable options are present. e.g.: $ rustc hello.rs -Z unstable-options --show-span error: Unrecognized option: 'show-span'. $ rustc hello.rs -Z unstable-options --pretty --pretty error: Unrecognized option: 'pretty'. $ rustc hello.rs -Z unstable-options --pretty --bad-option error: Unrecognized option: 'pretty'. * On the second parse, add a separate pass to reject unstable options if -Z unstable-options wasn't specified. Fixes #21715. r? @pnkfelix --- src/librustc_driver/lib.rs | 68 ++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index c09b018ab6345..0af5de0685252 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -688,39 +688,57 @@ pub fn handle_options(mut args: Vec) -> Option { return None; } - let matches = - match getopts::getopts(&args[..], &config::optgroups()) { - Ok(m) => m, - Err(f_stable_attempt) => { - // redo option parsing, including unstable options this time, - // in anticipation that the mishandled option was one of the - // unstable ones. - let all_groups : Vec - = config::rustc_optgroups().into_iter().map(|x|x.opt_group).collect(); - match getopts::getopts(&args, &all_groups) { - Ok(m_unstable) => { - let r = m_unstable.opt_strs("Z"); - let include_unstable_options = r.iter().any(|x| *x == "unstable-options"); - if include_unstable_options { - m_unstable + fn allows_unstable_options(matches: &getopts::Matches) -> bool { + let r = matches.opt_strs("Z"); + r.iter().any(|x| *x == "unstable-options") + } + + fn parse_all_options(args: &Vec) -> getopts::Matches { + let all_groups : Vec + = config::rustc_optgroups().into_iter().map(|x|x.opt_group).collect(); + match getopts::getopts(&args[..], &all_groups) { + Ok(m) => { + if !allows_unstable_options(&m) { + // If -Z unstable-options was not specified, verify that + // no unstable options were present. + for opt in config::rustc_optgroups().into_iter().filter(|x| !x.is_stable()) { + let opt_name = if !opt.opt_group.long_name.is_empty() { + &opt.opt_group.long_name } else { - early_error(&f_stable_attempt.to_string()); + &opt.opt_group.short_name + }; + if m.opt_present(opt_name) { + early_error(&format!("use of unstable option '{}' requires \ + -Z unstable-options", opt_name)); } } - Err(_) => { - // ignore the error from the unstable attempt; just - // pass the error we got from the first try. - early_error(&f_stable_attempt.to_string()); - } } + m } - }; + Err(f) => early_error(&f.to_string()) + } + } - let r = matches.opt_strs("Z"); - let include_unstable_options = r.iter().any(|x| *x == "unstable-options"); + // As a speed optimization, first try to parse the command-line using just + // the stable options. + let matches = match getopts::getopts(&args[..], &config::optgroups()) { + Ok(ref m) if allows_unstable_options(m) => { + // If -Z unstable-options was specified, redo parsing with the + // unstable options to ensure that unstable options are defined + // in the returned getopts::Matches. + parse_all_options(&args) + } + Ok(m) => m, + Err(_) => { + // redo option parsing, including unstable options this time, + // in anticipation that the mishandled option was one of the + // unstable ones. + parse_all_options(&args) + } + }; if matches.opt_present("h") || matches.opt_present("help") { - usage(matches.opt_present("verbose"), include_unstable_options); + usage(matches.opt_present("verbose"), allows_unstable_options(&matches)); return None; } From 8934c9b560190f06254be9cefba35a8cd300e3f1 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 11 Mar 2015 13:45:55 -0400 Subject: [PATCH 10/18] Add note about local documentation installation Fixes #23244 --- src/doc/trpl/installing-rust.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/doc/trpl/installing-rust.md b/src/doc/trpl/installing-rust.md index 6aa4bba6fa60c..0dc83f95f439d 100644 --- a/src/doc/trpl/installing-rust.md +++ b/src/doc/trpl/installing-rust.md @@ -78,6 +78,11 @@ rustc 1.0.0-nightly (f11f3e7ba 2015-01-04) (built 2015-01-06) If you did, Rust has been installed successfully! Congrats! +This installer also installs a copy of the documentation locally, so you can +read it offline. On UNIX systems, `/usr/local/share/doc/rust` is the location. +On Windows, it's in a `share/doc` directory, inside wherever you installed Rust +to. + If not, there are a number of places where you can get help. The easiest is [the #rust IRC channel on irc.mozilla.org](irc://irc.mozilla.org/#rust), which you can access through From 100e1a93dc6f02101017b89b4a15bcf85c44086f Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Wed, 11 Mar 2015 15:03:25 -0400 Subject: [PATCH 11/18] mk/tests: filter more possible debug-assertions --- mk/tests.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/tests.mk b/mk/tests.mk index ef38abcab6518..78f5ac11f06a7 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -590,7 +590,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \ # The tests select when to use debug configuration on their own; # remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898). -CTEST_RUSTC_FLAGS := $$(subst -C debug-assertions,,$$(CFG_RUSTC_FLAGS)) +CTEST_RUSTC_FLAGS := $$(subst -C debug-assertions,,$$(subst -C debug-assertions=on,,$$(CFG_RUSTC_FLAGS))) # The tests cannot be optimized while the rest of the compiler is optimized, so # filter out the optimization (if any) from rustc and then figure out if we need From 47f1d6747c01a36534ebd08bab497e7abd02c7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Sun, 8 Mar 2015 16:41:28 +0100 Subject: [PATCH 12/18] First-class struct and tuple constants Fixes #23260 --- src/librustc/middle/const_eval.rs | 81 ++++++++++++++++++++++--------- src/librustc/middle/ty.rs | 17 +++---- 2 files changed, 64 insertions(+), 34 deletions(-) diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index f215b59a6cd0e..96433729a9b96 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -17,7 +17,7 @@ use metadata::csearch; use middle::{astencode, def}; use middle::pat_util::def_to_path; use middle::ty::{self, Ty}; -use middle::astconv_util::{ast_ty_to_prim_ty}; +use middle::astconv_util::ast_ty_to_prim_ty; use syntax::ast::{self, Expr}; use syntax::codemap::Span; @@ -132,16 +132,16 @@ pub fn lookup_const_by_id<'a>(tcx: &'a ty::ctxt, def_id: ast::DefId) } } -// FIXME (#33): this doesn't handle big integer/float literals correctly -// (nor does the rest of our literal handling). #[derive(Clone, PartialEq)] pub enum const_val { const_float(f64), const_int(i64), const_uint(u64), const_str(InternedString), - const_binary(Rc >), - const_bool(bool) + const_binary(Rc>), + const_bool(bool), + Struct(ast::NodeId), + Tuple(ast::NodeId) } pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P { @@ -226,9 +226,13 @@ pub enum ErrKind { NegateOnString, NegateOnBoolean, NegateOnBinary, + NegateOnStruct, + NegateOnTuple, NotOnFloat, NotOnString, NotOnBinary, + NotOnStruct, + NotOnTuple, AddiWithOverflow(i64, i64), SubiWithOverflow(i64, i64), @@ -242,7 +246,8 @@ pub enum ErrKind { ModuloWithOverflow, MissingStructField, NonConstPath, - NonConstStruct, + ExpectedConstTuple, + ExpectedConstStruct, TupleIndexOutOfBounds, MiscBinaryOp, @@ -262,9 +267,13 @@ impl ConstEvalErr { NegateOnString => "negate on string".into_cow(), NegateOnBoolean => "negate on boolean".into_cow(), NegateOnBinary => "negate on binary literal".into_cow(), + NegateOnStruct => "negate on struct".into_cow(), + NegateOnTuple => "negate on tuple".into_cow(), NotOnFloat => "not on float or string".into_cow(), NotOnString => "not on float or string".into_cow(), NotOnBinary => "not on binary literal".into_cow(), + NotOnStruct => "not on struct".into_cow(), + NotOnTuple => "not on tuple".into_cow(), AddiWithOverflow(..) => "attempted to add with overflow".into_cow(), SubiWithOverflow(..) => "attempted to sub with overflow".into_cow(), @@ -278,7 +287,8 @@ impl ConstEvalErr { ModuloWithOverflow => "attempted remainder with overflow".into_cow(), MissingStructField => "nonexistent struct field".into_cow(), NonConstPath => "non-constant path in constant expr".into_cow(), - NonConstStruct => "non-constant struct in constant expr".into_cow(), + ExpectedConstTuple => "expected constant tuple".into_cow(), + ExpectedConstStruct => "expected constant struct".into_cow(), TupleIndexOutOfBounds => "tuple index out of bounds".into_cow(), MiscBinaryOp => "bad operands for binary".into_cow(), @@ -341,6 +351,8 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, const_str(_) => signal!(e, NegateOnString), const_bool(_) => signal!(e, NegateOnBoolean), const_binary(_) => signal!(e, NegateOnBinary), + const_val::Tuple(_) => signal!(e, NegateOnTuple), + const_val::Struct(..) => signal!(e, NegateOnStruct), } } ast::ExprUnary(ast::UnNot, ref inner) => { @@ -351,6 +363,8 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, const_str(_) => signal!(e, NotOnString), const_float(_) => signal!(e, NotOnFloat), const_binary(_) => signal!(e, NotOnBinary), + const_val::Tuple(_) => signal!(e, NotOnTuple), + const_val::Struct(..) => signal!(e, NotOnStruct), } } ast::ExprBinary(op, ref a, ref b) => { @@ -540,33 +554,52 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, None => const_int(0) } } + ast::ExprTup(_) => { + const_val::Tuple(e.id) + } + ast::ExprStruct(..) => { + const_val::Struct(e.id) + } ast::ExprTupField(ref base, index) => { - // Get the base tuple if it is constant - if let Some(&ast::ExprTup(ref fields)) = lookup_const(tcx, &**base).map(|s| &s.node) { - // Check that the given index is within bounds and evaluate its value - if fields.len() > index.node { - return eval_const_expr_partial(tcx, &*fields[index.node], None); + if let Ok(c) = eval_const_expr_partial(tcx, base, None) { + if let const_val::Tuple(tup_id) = c { + if let ast::ExprTup(ref fields) = tcx.map.expect_expr(tup_id).node { + if index.node < fields.len() { + return eval_const_expr_partial(tcx, &fields[index.node], None) + } else { + signal!(e, TupleIndexOutOfBounds); + } + } else { + unreachable!() + } } else { - signal!(e, TupleIndexOutOfBounds); + signal!(base, ExpectedConstTuple); } + } else { + signal!(base, NonConstPath) } - - signal!(e, NonConstStruct); } ast::ExprField(ref base, field_name) => { // Get the base expression if it is a struct and it is constant - if let Some(&ast::ExprStruct(_, ref fields, _)) = lookup_const(tcx, &**base) - .map(|s| &s.node) { - // Check that the given field exists and evaluate it - if let Some(f) = fields.iter().find(|f| - f.ident.node.as_str() == field_name.node.as_str()) { - return eval_const_expr_partial(tcx, &*f.expr, None); + if let Ok(c) = eval_const_expr_partial(tcx, base, None) { + if let const_val::Struct(struct_id) = c { + if let ast::ExprStruct(_, ref fields, _) = tcx.map.expect_expr(struct_id).node { + // Check that the given field exists and evaluate it + if let Some(f) = fields.iter().find(|f| f.ident.node.as_str() + == field_name.node.as_str()) { + return eval_const_expr_partial(tcx, &*f.expr, None) + } else { + signal!(e, MissingStructField); + } + } else { + unreachable!() + } } else { - signal!(e, MissingStructField); + signal!(base, ExpectedConstStruct); } + } else { + signal!(base, NonConstPath); } - - signal!(e, NonConstStruct); } _ => signal!(e, MiscCatchAll) }; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 4cb4d343de758..a871602b86519 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -5853,16 +5853,13 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint { let found = match val { const_eval::const_uint(count) => return count as uint, const_eval::const_int(count) if count >= 0 => return count as uint, - const_eval::const_int(_) => - "negative integer", - const_eval::const_float(_) => - "float", - const_eval::const_str(_) => - "string", - const_eval::const_bool(_) => - "boolean", - const_eval::const_binary(_) => - "binary array" + const_eval::const_int(_) => "negative integer", + const_eval::const_float(_) => "float", + const_eval::const_str(_) => "string", + const_eval::const_bool(_) => "boolean", + const_eval::const_binary(_) => "binary array", + const_eval::Struct(..) => "struct", + const_eval::Tuple(_) => "tuple" }; span_err!(tcx.sess, count_expr.span, E0306, "expected positive integer for repeat count, found {}", From a83db812385f9bf281078c7c8ede44f6863f2966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Wed, 11 Mar 2015 10:57:12 +0100 Subject: [PATCH 13/18] Update tests --- src/test/compile-fail/repeat_count.rs | 2 +- src/test/run-pass/issue-19244.rs | 29 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index 9b3e2668042ea..121581412202c 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -19,7 +19,7 @@ fn main() { //~| found `()` //~| expected usize //~| found () -//~| ERROR expected constant integer for repeat count, found non-constant expression +//~| ERROR expected positive integer for repeat count, found tuple let c = [0; true]; //~^ ERROR mismatched types //~| expected `usize` diff --git a/src/test/run-pass/issue-19244.rs b/src/test/run-pass/issue-19244.rs index 9af4d30c4f640..35e053110dfc7 100644 --- a/src/test/run-pass/issue-19244.rs +++ b/src/test/run-pass/issue-19244.rs @@ -8,14 +8,35 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct MyStruct { field: uint } +struct MyStruct { field: usize } +struct Nested { nested: MyStruct } +struct Mix2 { nested: ((usize,),) } + const STRUCT: MyStruct = MyStruct { field: 42 }; -const TUP: (uint,) = (43,); +const TUP: (usize,) = (43,); +const NESTED_S: Nested = Nested { nested: MyStruct { field: 5 } }; +const NESTED_T: ((usize,),) = ((4,),); +const MIX_1: ((Nested,),) = ((Nested { nested: MyStruct { field: 3 } },),); +const MIX_2: Mix2 = Mix2 { nested: ((2,),) }; +const INSTANT_1: usize = (MyStruct { field: 1 }).field; +const INSTANT_2: usize = (0,).0; fn main() { let a = [0; STRUCT.field]; let b = [0; TUP.0]; + let c = [0; NESTED_S.nested.field]; + let d = [0; (NESTED_T.0).0]; + let e = [0; (MIX_1.0).0.nested.field]; + let f = [0; (MIX_2.nested.0).0]; + let g = [0; INSTANT_1]; + let h = [0; INSTANT_2]; - assert!(a.len() == 42); - assert!(b.len() == 43); + assert_eq!(a.len(), 42); + assert_eq!(b.len(), 43); + assert_eq!(c.len(), 5); + assert_eq!(d.len(), 4); + assert_eq!(e.len(), 3); + assert_eq!(f.len(), 2); + assert_eq!(g.len(), 1); + assert_eq!(h.len(), 0); } From 3ac89d372faf888e2482ac4a07c991e26f737259 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 10 Mar 2015 00:17:01 +0100 Subject: [PATCH 14/18] Rewrite the dynamic dispatch section to focus on usage rather than implementation. --- src/doc/trpl/static-and-dynamic-dispatch.md | 117 ++++++++++++-------- 1 file changed, 68 insertions(+), 49 deletions(-) diff --git a/src/doc/trpl/static-and-dynamic-dispatch.md b/src/doc/trpl/static-and-dynamic-dispatch.md index fc1ab9bf9e8dc..504ed63934c6a 100644 --- a/src/doc/trpl/static-and-dynamic-dispatch.md +++ b/src/doc/trpl/static-and-dynamic-dispatch.md @@ -102,49 +102,88 @@ reason. Rust provides dynamic dispatch through a feature called 'trait objects.' Trait objects, like `&Foo` or `Box`, are normal values that store a value of *any* type that implements the given trait, where the precise type can only be -known at runtime. The methods of the trait can be called on a trait object via -a special record of function pointers (created and managed by the compiler). +known at runtime. -A function that takes a trait object is not specialized to each of the types -that implements `Foo`: only one copy is generated, often (but not always) -resulting in less code bloat. However, this comes at the cost of requiring -slower virtual function calls, and effectively inhibiting any chance of -inlining and related optimisations from occurring. +A trait object can be obtained from a pointer to a concrete type that +implements the trait by *casting* it (e.g. `&x as &Foo`) or *coercing* it +(e.g. using `&x` as an argument to a function that takes `&Foo`). -Trait objects are both simple and complicated: their core representation and -layout is quite straight-forward, but there are some curly error messages and -surprising behaviors to discover. +These trait object coercions and casts also work for pointers like `&mut T` to +`&mut Foo` and `Box` to `Box`, but that's all at the moment. Coercions +and casts are identical. -### Obtaining a trait object +This operation can be seen as "erasing" the compiler's knowledge about the +specific type of the pointer, and hence trait objects are sometimes referred to +as "type erasure". -There's two similar ways to get a trait object value: casts and coercions. If -`T` is a type that implements a trait `Foo` (e.g. `u8` for the `Foo` above), -then the two ways to get a `Foo` trait object out of a pointer to `T` look -like: +Coming back to the example above, we can use the same trait to perform dynamic +dispatch with trait objects by casting: -```{rust,ignore} -let ref_to_t: &T = ...; +```rust +# trait Foo { fn method(&self) -> String; } +# impl Foo for u8 { fn method(&self) -> String { format!("u8: {}", *self) } } +# impl Foo for String { fn method(&self) -> String { format!("string: {}", *self) } } -// `as` keyword for casting -let cast = ref_to_t as &Foo; +fn do_something(x: &Foo) { + x.method(); +} -// using a `&T` in a place that has a known type of `&Foo` will implicitly coerce: -let coerce: &Foo = ref_to_t; +fn main() { + let x = 5u8; + do_something(&x as &Foo); +} +``` -fn also_coerce(_unused: &Foo) {} -also_coerce(ref_to_t); +or by coercing: + +```rust +# trait Foo { fn method(&self) -> String; } +# impl Foo for u8 { fn method(&self) -> String { format!("u8: {}", *self) } } +# impl Foo for String { fn method(&self) -> String { format!("string: {}", *self) } } + +fn do_something(x: &Foo) { + x.method(); +} + +fn main() { + let x = "Hello".to_string(); + do_something(&x); +} ``` -These trait object coercions and casts also work for pointers like `&mut T` to -`&mut Foo` and `Box` to `Box`, but that's all at the moment. Coercions -and casts are identical. +A function that takes a trait object is not specialized to each of the types +that implements `Foo`: only one copy is generated, often (but not always) +resulting in less code bloat. However, this comes at the cost of requiring +slower virtual function calls, and effectively inhibiting any chance of +inlining and related optimisations from occurring. -This operation can be seen as "erasing" the compiler's knowledge about the -specific type of the pointer, and hence trait objects are sometimes referred to -as "type erasure". +### Why pointers? + +Rust does not put things behind a pointer by default, unlike many managed +languages, so types can have different sizes. Knowing the size of the value at +compile time is important for things like passing it as an argument to a +function, moving it about on the stack and allocating (and deallocating) space +on the heap to store it. + +For `Foo`, we would need to have a value that could be at least either a +`String` (24 bytes) or a `u8` (1 byte), as well as any other type for which +dependent crates may implement `Foo` (any number of bytes at all). There's no +way to guarantee that this last point can work if the values are stored without +a pointer, because those other types can be arbitrarily large. + +Putting the value behind a pointer means the size of the value is not relevant +when we are tossing a trait object around, only the size of the pointer itself. ### Representation +The methods of the trait can be called on a trait object via a special record +of function pointers traditionally called a 'vtable' (created and managed by +the compiler). + +Trait objects are both simple and complicated: their core representation and +layout is quite straight-forward, but there are some curly error messages and +surprising behaviors to discover. + Let's start simple, with the runtime representation of a trait object. The `std::raw` module contains structs with layouts that are the same as the complicated built-in types, [including trait objects][stdraw]: @@ -265,23 +304,3 @@ let y = TraitObject { If `b` or `y` were owning trait objects (`Box`), there would be a `(b.vtable.destructor)(b.data)` (respectively `y`) call when they went out of scope. - -### Why pointers? - -The use of language like "fat pointer" implies that a trait object is -always a pointer of some form, but why? - -Rust does not put things behind a pointer by default, unlike many managed -languages, so types can have different sizes. Knowing the size of the value at -compile time is important for things like passing it as an argument to a -function, moving it about on the stack and allocating (and deallocating) space -on the heap to store it. - -For `Foo`, we would need to have a value that could be at least either a -`String` (24 bytes) or a `u8` (1 byte), as well as any other type for which -dependent crates may implement `Foo` (any number of bytes at all). There's no -way to guarantee that this last point can work if the values are stored without -a pointer, because those other types can be arbitrarily large. - -Putting the value behind a pointer means the size of the value is not relevant -when we are tossing a trait object around, only the size of the pointer itself. From de67c3a5bbfc8a9db2dc3d134700046dd6db05b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Thu, 12 Mar 2015 00:19:37 +0100 Subject: [PATCH 15/18] Fix LLVM assertion when out-of-bounds indexing in a constant Fixes #23291 --- src/librustc_trans/trans/consts.rs | 4 +++- src/test/compile-fail/const-array-oob.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/const-array-oob.rs diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 39b430b7ad51e..8dcabe0a94bb8 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -505,8 +505,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, // pass. Reporting here is a bit late. cx.sess().span_err(e.span, "const index-expr is out of bounds"); + C_undef(type_of::type_of(cx, bt).element_type()) + } else { + const_get_elt(cx, arr, &[iv as c_uint]) } - const_get_elt(cx, arr, &[iv as c_uint]) } ast::ExprCast(ref base, _) => { let llty = type_of::type_of(cx, ety); diff --git a/src/test/compile-fail/const-array-oob.rs b/src/test/compile-fail/const-array-oob.rs new file mode 100644 index 0000000000000..84d3529260824 --- /dev/null +++ b/src/test/compile-fail/const-array-oob.rs @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const FOO: [u32; 3] = [1, 2, 3]; +const BAR: u32 = FOO[5]; //~ ERROR const index-expr is out of bounds + +fn main() { + let _ = BAR; +} From ac6cd90af1fa784cc9f8ad976e27b6d0a844f211 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 11 Mar 2015 20:10:52 -0400 Subject: [PATCH 16/18] Explain why immediately dropping a JoinGuard is not what you want to do --- src/libstd/thread.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index 7d0df67959107..4c7dcc8b9eb61 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -635,7 +635,7 @@ impl Drop for JoinHandle { /// Due to platform restrictions, it is not possible to `Clone` this /// handle: the ability to join a child thread is a uniquely-owned /// permission. -#[must_use] +#[must_use = "thread will be immediately joined if `JoinGuard` is not used"] #[stable(feature = "rust1", since = "1.0.0")] pub struct JoinGuard<'a, T: 'a> { inner: JoinInner, From 64ab111b5387e9985df188a970350c9e6c7f1451 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 11 Mar 2015 21:11:40 -0400 Subject: [PATCH 17/18] Example -> Examples This brings comments in line with https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#using-markdown --- src/doc/trpl/comments.md | 2 +- src/liballoc/arc.rs | 2 +- src/liballoc/boxed.rs | 2 +- src/liballoc/rc.rs | 4 +- src/libcollections/borrow.rs | 2 +- src/libcollections/btree/map.rs | 2 +- src/libcollections/fmt.rs | 2 +- src/libcollections/macros.rs | 2 +- src/libcollections/slice.rs | 24 ++++----- src/libcollections/str.rs | 2 +- src/libcore/finally.rs | 4 +- src/libcore/fmt/num.rs | 2 +- src/libcore/iter.rs | 2 +- src/libcore/macros.rs | 10 ++-- src/libcore/marker.rs | 2 +- src/libcore/num/mod.rs | 34 ++++++------- src/libcore/ops.rs | 36 ++++++------- src/libcore/option.rs | 46 ++++++++--------- src/libcore/result.rs | 34 ++++++------- src/libcore/slice.rs | 4 +- src/libcore/str/mod.rs | 2 +- src/libcore/str/pattern.rs | 2 +- src/liblog/macros.rs | 12 ++--- src/librand/distributions/exponential.rs | 2 +- src/librand/distributions/gamma.rs | 8 +-- src/librand/distributions/mod.rs | 2 +- src/librand/distributions/normal.rs | 4 +- src/librand/distributions/range.rs | 2 +- src/librand/lib.rs | 24 ++++----- src/librand/reseeding.rs | 2 +- src/librbml/io.rs | 2 +- src/librustc/util/common.rs | 2 +- src/librustc_bitflags/lib.rs | 2 +- src/libserialize/hex.rs | 4 +- src/libstd/collections/hash/map.rs | 44 ++++++++-------- src/libstd/collections/hash/set.rs | 46 ++++++++--------- src/libstd/env.rs | 24 ++++----- src/libstd/ffi/c_str.rs | 4 +- src/libstd/fs/mod.rs | 18 +++---- src/libstd/macros.rs | 28 +++++------ src/libstd/net/mod.rs | 2 +- src/libstd/net/tcp.rs | 2 +- src/libstd/net/udp.rs | 2 +- src/libstd/old_io/buffered.rs | 6 +-- src/libstd/old_io/comm_adapters.rs | 4 +- src/libstd/old_io/fs.rs | 24 ++++----- src/libstd/old_io/mem.rs | 8 +-- src/libstd/old_io/mod.rs | 6 +-- src/libstd/old_io/net/pipe.rs | 4 +- src/libstd/old_io/net/tcp.rs | 8 +-- src/libstd/old_io/net/udp.rs | 2 +- src/libstd/old_io/pipe.rs | 2 +- src/libstd/old_io/process.rs | 8 +-- src/libstd/old_io/stdio.rs | 2 +- src/libstd/old_io/timer.rs | 4 +- src/libstd/old_path/mod.rs | 64 ++++++++++++------------ src/libstd/old_path/windows.rs | 4 +- src/libstd/os.rs | 24 ++++----- src/libstd/path.rs | 4 +- src/libstd/process.rs | 4 +- src/libstd/rand/mod.rs | 2 +- src/libstd/rand/reader.rs | 2 +- src/libstd/sync/condvar.rs | 4 +- src/libstd/sync/mpsc/mod.rs | 6 +-- src/libstd/sync/mpsc/select.rs | 2 +- src/libstd/sync/mutex.rs | 2 +- src/libstd/sync/once.rs | 2 +- src/libstd/sync/rwlock.rs | 2 +- src/libstd/sync/semaphore.rs | 2 +- src/libstd/sync/task_pool.rs | 2 +- src/libstd/sys/common/thread_local.rs | 6 +-- src/libstd/sys/windows/c.rs | 2 +- src/libstd/thread_local/mod.rs | 2 +- src/libstd/thread_local/scoped.rs | 6 +-- src/libsyntax/parse/parser.rs | 2 +- src/libunicode/u_str.rs | 2 +- 76 files changed, 341 insertions(+), 341 deletions(-) diff --git a/src/doc/trpl/comments.md b/src/doc/trpl/comments.md index 66670c7c631cd..441496e6a755b 100644 --- a/src/doc/trpl/comments.md +++ b/src/doc/trpl/comments.md @@ -28,7 +28,7 @@ The other kind of comment is a doc comment. Doc comments use `///` instead of /// /// * `name` - The name of the person you'd like to greet. /// -/// # Example +/// # Examples /// /// ```rust /// let name = "Steve"; diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index dc1938cac1ada..748eb9dcb2fd4 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -88,7 +88,7 @@ use heap::deallocate; /// An atomically reference counted wrapper for shared state. /// -/// # Example +/// # Examples /// /// In this example, a large vector of floats is shared between several tasks. /// With simple pipes, without `Arc`, a copy would have to be made for each diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 9351b11010030..6d865d2bffa8a 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -133,7 +133,7 @@ impl Box { /// automatically managed that may lead to memory or other resource /// leak. /// -/// # Example +/// # Examples /// ``` /// use std::boxed; /// diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 763dcc7f256e9..115acd4a0efec 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -264,7 +264,7 @@ pub fn is_unique(rc: &Rc) -> bool { /// /// If the `Rc` is not unique, an `Err` is returned with the same `Rc`. /// -/// # Example +/// # Examples /// /// ``` /// use std::rc::{self, Rc}; @@ -298,7 +298,7 @@ pub fn try_unwrap(rc: Rc) -> Result> { /// /// Returns `None` if the `Rc` is not unique. /// -/// # Example +/// # Examples /// /// ``` /// use std::rc::{self, Rc}; diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index f3c44a84ee50a..5b799d3e5c0ff 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -127,7 +127,7 @@ impl ToOwned for T where T: Clone { /// is desired, `to_mut` will obtain a mutable references to an owned /// value, cloning if necessary. /// -/// # Example +/// # Examples /// /// ```rust /// use std::borrow::Cow; diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 1fa592ac477a2..5de6cbe61e9e6 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -1177,7 +1177,7 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> { impl BTreeMap { /// Gets an iterator over the entries of the map. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::BTreeMap; diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 15a66bd80d02b..5d35c3902a31a 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -420,7 +420,7 @@ use string; /// /// * args - a structure of arguments generated via the `format_args!` macro. /// -/// # Example +/// # Examples /// /// ```rust /// use std::fmt; diff --git a/src/libcollections/macros.rs b/src/libcollections/macros.rs index e9764547628c0..0f6a85d75daa8 100644 --- a/src/libcollections/macros.rs +++ b/src/libcollections/macros.rs @@ -48,7 +48,7 @@ macro_rules! vec { /// Use the syntax described in `std::fmt` to create a value of type `String`. /// See `std::fmt` for more information. /// -/// # Example +/// # Examples /// /// ``` /// format!("test"); diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index cffa4bbfbf411..2503001b44dad 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -277,7 +277,7 @@ pub trait SliceExt { /// /// Panics if `size` is 0. /// - /// # Example + /// # Examples /// /// Print the adjacent pairs of a slice (i.e. `[1,2]`, `[2,3]`, /// `[3,4]`): @@ -300,7 +300,7 @@ pub trait SliceExt { /// /// Panics if `size` is 0. /// - /// # Example + /// # Examples /// /// Print the slice two elements at a time (i.e. `[1,2]`, /// `[3,4]`, `[5]`): @@ -390,7 +390,7 @@ pub trait SliceExt { /// `Err` is returned, containing the index where a matching /// element could be inserted while maintaining sorted order. /// - /// # Example + /// # Examples /// /// Looks up a series of four elements. The first is found, with a /// uniquely determined position; the second and third are not @@ -416,7 +416,7 @@ pub trait SliceExt { /// Return the number of elements in the slice /// - /// # Example + /// # Examples /// /// ``` /// let a = [1, 2, 3]; @@ -427,7 +427,7 @@ pub trait SliceExt { /// Returns true if the slice has a length of 0 /// - /// # Example + /// # Examples /// /// ``` /// let a = [1, 2, 3]; @@ -529,7 +529,7 @@ pub trait SliceExt { /// /// Panics if `a` or `b` are out of bounds. /// - /// # Example + /// # Examples /// /// ```rust /// let mut v = ["a", "b", "c", "d"]; @@ -549,7 +549,7 @@ pub trait SliceExt { /// /// Panics if `mid > len`. /// - /// # Example + /// # Examples /// /// ```rust /// let mut v = [1, 2, 3, 4, 5, 6]; @@ -578,7 +578,7 @@ pub trait SliceExt { /// Reverse the order of elements in a slice, in place. /// - /// # Example + /// # Examples /// /// ```rust /// let mut v = [1, 2, 3]; @@ -638,7 +638,7 @@ pub trait SliceExt { /// shorter of `self.len()` and `src.len()`). Returns the number /// of elements copied. /// - /// # Example + /// # Examples /// /// ```rust /// let mut dst = [0, 0, 0]; @@ -676,7 +676,7 @@ pub trait SliceExt { /// `Err` is returned, containing the index where a matching /// element could be inserted while maintaining sorted order. /// - /// # Example + /// # Examples /// /// Looks up a series of four elements. The first is found, with a /// uniquely determined position; the second and third are not @@ -707,7 +707,7 @@ pub trait SliceExt { /// Returns `true` if successful and `false` if the slice is at the /// last-ordered permutation. /// - /// # Example + /// # Examples /// /// ```rust /// let v: &mut [_] = &mut [0, 1, 2]; @@ -727,7 +727,7 @@ pub trait SliceExt { /// Returns `true` if successful and `false` if the slice is at the /// first-ordered permutation. /// - /// # Example + /// # Examples /// /// ```rust /// let v: &mut [_] = &mut [1, 0, 2]; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 28df6cf96d7e5..31d7677d19eaf 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1377,7 +1377,7 @@ pub trait StrExt: Index { /// /// Will return `Err` if it's not possible to parse `self` into the type. /// - /// # Example + /// # Examples /// /// ``` /// assert_eq!("4".parse::(), Ok(4)); diff --git a/src/libcore/finally.rs b/src/libcore/finally.rs index 562a597cccf1d..74806e52d261d 100644 --- a/src/libcore/finally.rs +++ b/src/libcore/finally.rs @@ -16,7 +16,7 @@ //! "finally" case. For advanced cases, the `try_finally` function can //! also be used. See that function for more details. //! -//! # Example +//! # Examples //! //! ``` //! # #![feature(unboxed_closures)] @@ -67,7 +67,7 @@ impl Finally for F where F: FnMut() -> T { /// function could have panicked at any point, so the values of the shared /// state may be inconsistent. /// -/// # Example +/// # Examples /// /// ``` /// use std::finally::try_finally; diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index b3f2302bb3e07..fe22ee60da688 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -143,7 +143,7 @@ pub struct RadixFmt(T, R); /// Constructs a radix formatter in the range of `2..36`. /// -/// # Example +/// # Examples /// /// ``` /// use std::fmt::radix; diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index d5e891a156e9b..74bc87ecbf3c5 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -2296,7 +2296,7 @@ impl RandomAccessIterator for Inspect /// An iterator that passes mutable state to a closure and yields the result. /// -/// # Example: The Fibonacci Sequence +/// # Examples /// /// An iterator that yields sequential Fibonacci numbers, and stops on overflow. /// diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index c2860d435114f..6575bac501fe0 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -33,7 +33,7 @@ macro_rules! panic { /// This will invoke the `panic!` macro if the provided expression cannot be /// evaluated to `true` at runtime. /// -/// # Example +/// # Examples /// /// ``` /// // the panic message for these assertions is the stringified value of the @@ -71,7 +71,7 @@ macro_rules! assert { /// /// On panic, this macro will print the values of the expressions. /// -/// # Example +/// # Examples /// /// ``` /// let a = 3; @@ -107,7 +107,7 @@ macro_rules! assert_eq { /// expensive to be present in a release build but may be helpful during /// development. /// -/// # Example +/// # Examples /// /// ``` /// // the panic message for these assertions is the stringified value of the @@ -142,7 +142,7 @@ macro_rules! debug_assert { /// expensive to be present in a release build but may be helpful during /// development. /// -/// # Example +/// # Examples /// /// ``` /// let a = 3; @@ -172,7 +172,7 @@ macro_rules! try { /// Use the `format!` syntax to write data into a buffer of type `&mut Writer`. /// See `std::fmt` for more information. /// -/// # Example +/// # Examples /// /// ``` /// # #![allow(unused_must_use)] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index fe53ea1f0af84..d596a06709c5a 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -288,7 +288,7 @@ impl MarkerTrait for T { } /// can extend `MarkerTrait`, which is equivalent to /// `PhantomFn`. /// -/// # Example +/// # Examples /// /// As an example, consider a trait with no methods like `Even`, meant /// to represent types that are "even": diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 752eca797bd13..6170092c8d107 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -82,7 +82,7 @@ pub trait Int /// Returns the number of ones in the binary representation of `self`. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -97,7 +97,7 @@ pub trait Int /// Returns the number of zeros in the binary representation of `self`. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -116,7 +116,7 @@ pub trait Int /// Returns the number of leading zeros in the binary representation /// of `self`. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -132,7 +132,7 @@ pub trait Int /// Returns the number of trailing zeros in the binary representation /// of `self`. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -148,7 +148,7 @@ pub trait Int /// Shifts the bits to the left by a specified amount amount, `n`, wrapping /// the truncated bits to the end of the resulting integer. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -165,7 +165,7 @@ pub trait Int /// Shifts the bits to the right by a specified amount amount, `n`, wrapping /// the truncated bits to the beginning of the resulting integer. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -181,7 +181,7 @@ pub trait Int /// Reverses the byte order of the integer. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -198,7 +198,7 @@ pub trait Int /// /// On big endian this is a no-op. On little endian the bytes are swapped. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -221,7 +221,7 @@ pub trait Int /// /// On little endian this is a no-op. On big endian the bytes are swapped. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -244,7 +244,7 @@ pub trait Int /// /// On big endian this is a no-op. On little endian the bytes are swapped. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -267,7 +267,7 @@ pub trait Int /// /// On little endian this is a no-op. On big endian the bytes are swapped. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -289,7 +289,7 @@ pub trait Int /// Checked integer addition. Computes `self + other`, returning `None` if /// overflow occurred. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -303,7 +303,7 @@ pub trait Int /// Checked integer subtraction. Computes `self - other`, returning `None` /// if underflow occurred. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -317,7 +317,7 @@ pub trait Int /// Checked integer multiplication. Computes `self * other`, returning /// `None` if underflow or overflow occurred. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -331,7 +331,7 @@ pub trait Int /// Checked integer division. Computes `self / other`, returning `None` if /// `other == 0` or the operation results in underflow or overflow. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -369,7 +369,7 @@ pub trait Int /// Raises self to the power of `exp`, using exponentiation by squaring. /// - /// # Example + /// # Examples /// /// ```rust /// use std::num::Int; @@ -1273,7 +1273,7 @@ impl_from_primitive! { f64, to_f64 } /// Cast from one machine scalar to another. /// -/// # Example +/// # Examples /// /// ``` /// use std::num; diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 4116d8be9fb5c..077b44f2dd2a7 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -27,7 +27,7 @@ //! idea to have both `T` and `&T` implement the traits `Add` and `Add<&T>` //! so that generic code can be written without unnecessary cloning. //! -//! # Example +//! # Examples //! //! This example creates a `Point` struct that implements `Add` and `Sub`, and then //! demonstrates adding and subtracting two `Point`s. @@ -73,7 +73,7 @@ use fmt; /// The `Drop` trait is used to run some code when a value goes out of scope. This /// is sometimes called a 'destructor'. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Drop`. The `drop` method is called when `_x` goes /// out of scope, and therefore `main` prints `Dropping!`. @@ -157,7 +157,7 @@ macro_rules! forward_ref_binop { /// The `Add` trait is used to specify the functionality of `+`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Add`. When `Foo + Foo` happens, it ends up /// calling `add`, and therefore, `main` prints `Adding!`. @@ -211,7 +211,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `Sub` trait is used to specify the functionality of `-`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Sub`. When `Foo - Foo` happens, it ends up /// calling `sub`, and therefore, `main` prints `Subtracting!`. @@ -265,7 +265,7 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `Mul` trait is used to specify the functionality of `*`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Mul`. When `Foo * Foo` happens, it ends up /// calling `mul`, and therefore, `main` prints `Multiplying!`. @@ -319,7 +319,7 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `Div` trait is used to specify the functionality of `/`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Div`. When `Foo / Foo` happens, it ends up /// calling `div`, and therefore, `main` prints `Dividing!`. @@ -373,7 +373,7 @@ div_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `Rem` trait is used to specify the functionality of `%`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up /// calling `rem`, and therefore, `main` prints `Remainder-ing!`. @@ -446,7 +446,7 @@ rem_float_impl! { f64, fmod } /// The `Neg` trait is used to specify the functionality of unary `-`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Neg`. When `-Foo` happens, it ends up calling /// `neg`, and therefore, `main` prints `Negating!`. @@ -523,7 +523,7 @@ neg_uint_impl! { u64, i64 } /// The `Not` trait is used to specify the functionality of unary `!`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Not`. When `!Foo` happens, it ends up calling /// `not`, and therefore, `main` prints `Not-ing!`. @@ -577,7 +577,7 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// The `BitAnd` trait is used to specify the functionality of `&`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `BitAnd`. When `Foo & Foo` happens, it ends up /// calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`. @@ -631,7 +631,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// The `BitOr` trait is used to specify the functionality of `|`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `BitOr`. When `Foo | Foo` happens, it ends up /// calling `bitor`, and therefore, `main` prints `Bitwise Or-ing!`. @@ -685,7 +685,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// The `BitXor` trait is used to specify the functionality of `^`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `BitXor`. When `Foo ^ Foo` happens, it ends up /// calling `bitxor`, and therefore, `main` prints `Bitwise Xor-ing!`. @@ -739,7 +739,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// The `Shl` trait is used to specify the functionality of `<<`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Shl`. When `Foo << Foo` happens, it ends up /// calling `shl`, and therefore, `main` prints `Shifting left!`. @@ -811,7 +811,7 @@ shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// The `Shr` trait is used to specify the functionality of `>>`. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Shr`. When `Foo >> Foo` happens, it ends up /// calling `shr`, and therefore, `main` prints `Shifting right!`. @@ -883,7 +883,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// The `Index` trait is used to specify the functionality of indexing operations /// like `arr[idx]` when used in an immutable context. /// -/// # Example +/// # Examples /// /// A trivial implementation of `Index`. When `Foo[Bar]` happens, it ends up /// calling `index`, and therefore, `main` prints `Indexing!`. @@ -924,7 +924,7 @@ pub trait Index { /// The `IndexMut` trait is used to specify the functionality of indexing /// operations like `arr[idx]`, when used in a mutable context. /// -/// # Example +/// # Examples /// /// A trivial implementation of `IndexMut`. When `Foo[Bar]` happens, it ends up /// calling `index_mut`, and therefore, `main` prints `Indexing!`. @@ -1033,7 +1033,7 @@ impl fmt::Debug for RangeTo { /// The `Deref` trait is used to specify the functionality of dereferencing /// operations like `*v`. /// -/// # Example +/// # Examples /// /// A struct with a single field which is accessible via dereferencing the /// struct. @@ -1087,7 +1087,7 @@ impl<'a, T: ?Sized> Deref for &'a mut T { /// The `DerefMut` trait is used to specify the functionality of dereferencing /// mutably like `*v = 1;` /// -/// # Example +/// # Examples /// /// A struct with a single field which is modifiable via dereferencing the /// struct. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 5343cdaaf088c..2dd8bf67220ab 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -185,7 +185,7 @@ impl Option { /// Returns `true` if the option is a `Some` value /// - /// # Example + /// # Examples /// /// ``` /// let x: Option = Some(2); @@ -205,7 +205,7 @@ impl Option { /// Returns `true` if the option is a `None` value /// - /// # Example + /// # Examples /// /// ``` /// let x: Option = Some(2); @@ -226,7 +226,7 @@ impl Option { /// Convert from `Option` to `Option<&T>` /// - /// # Example + /// # Examples /// /// Convert an `Option` into an `Option`, preserving the original. /// The `map` method takes the `self` argument by value, consuming the original, @@ -251,7 +251,7 @@ impl Option { /// Convert from `Option` to `Option<&mut T>` /// - /// # Example + /// # Examples /// /// ``` /// let mut x = Some(2); @@ -272,7 +272,7 @@ impl Option { /// Convert from `Option` to `&mut [T]` (without copying) /// - /// # Example + /// # Examples /// /// ``` /// let mut x = Some("Diamonds"); @@ -311,7 +311,7 @@ impl Option { /// Panics if the value is a `None` with a custom panic message provided by /// `msg`. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some("value"); @@ -343,7 +343,7 @@ impl Option { /// Instead, prefer to use pattern matching and handle the `None` /// case explicitly. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some("air"); @@ -365,7 +365,7 @@ impl Option { /// Returns the contained value or a default. /// - /// # Example + /// # Examples /// /// ``` /// assert_eq!(Some("car").unwrap_or("bike"), "car"); @@ -382,7 +382,7 @@ impl Option { /// Returns the contained value or computes it from a closure. /// - /// # Example + /// # Examples /// /// ``` /// let k = 10; @@ -404,7 +404,7 @@ impl Option { /// Maps an `Option` to `Option` by applying a function to a contained value /// - /// # Example + /// # Examples /// /// Convert an `Option` into an `Option`, consuming the original: /// @@ -424,7 +424,7 @@ impl Option { /// Applies a function to the contained value or returns a default. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some("foo"); @@ -444,7 +444,7 @@ impl Option { /// Applies a function to the contained value or computes a default. /// - /// # Example + /// # Examples /// /// ``` /// let k = 21; @@ -467,7 +467,7 @@ impl Option { /// Transforms the `Option` into a `Result`, mapping `Some(v)` to /// `Ok(v)` and `None` to `Err(err)`. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some("foo"); @@ -488,7 +488,7 @@ impl Option { /// Transforms the `Option` into a `Result`, mapping `Some(v)` to /// `Ok(v)` and `None` to `Err(err())`. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some("foo"); @@ -512,7 +512,7 @@ impl Option { /// Returns an iterator over the possibly contained value. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some(4); @@ -529,7 +529,7 @@ impl Option { /// Returns a mutable iterator over the possibly contained value. /// - /// # Example + /// # Examples /// /// ``` /// let mut x = Some(4); @@ -551,7 +551,7 @@ impl Option { /// Returns a consuming iterator over the possibly contained value. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some("string"); @@ -574,7 +574,7 @@ impl Option { /// Returns `None` if the option is `None`, otherwise returns `optb`. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some(2); @@ -607,7 +607,7 @@ impl Option { /// /// Some languages call this operation flatmap. /// - /// # Example + /// # Examples /// /// ``` /// fn sq(x: u32) -> Option { Some(x * x) } @@ -629,7 +629,7 @@ impl Option { /// Returns the option if it contains a value, otherwise returns `optb`. /// - /// # Example + /// # Examples /// /// ``` /// let x = Some(2); @@ -660,7 +660,7 @@ impl Option { /// Returns the option if it contains a value, otherwise calls `f` and /// returns the result. /// - /// # Example + /// # Examples /// /// ``` /// fn nobody() -> Option<&'static str> { None } @@ -685,7 +685,7 @@ impl Option { /// Takes the value out of the option, leaving a `None` in its place. /// - /// # Example + /// # Examples /// /// ``` /// let mut x = Some(2); @@ -720,7 +720,7 @@ impl Option { /// value, otherwise if `None`, returns the default value for that /// type. /// - /// # Example + /// # Examples /// /// Convert a string to an integer, turning poorly-formed strings /// into 0 (the default value for integers). `parse` converts diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 6c3afdf884953..9fba9a4d8ec76 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -265,7 +265,7 @@ impl Result { /// Returns true if the result is `Ok` /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(-3); @@ -285,7 +285,7 @@ impl Result { /// Returns true if the result is `Err` /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(-3); @@ -309,7 +309,7 @@ impl Result { /// Converts `self` into an `Option`, consuming `self`, /// and discarding the error, if any. /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(2); @@ -332,7 +332,7 @@ impl Result { /// Converts `self` into an `Option`, consuming `self`, /// and discarding the value, if any. /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(2); @@ -440,7 +440,7 @@ impl Result { /// /// This function can be used to compose the results of two functions. /// - /// # Example + /// # Examples /// /// Sum the lines of a buffer by mapping strings to numbers, /// ignoring I/O and parse errors: @@ -479,7 +479,7 @@ impl Result { /// This function can be used to pass through a successful result while handling /// an error. /// - /// # Example + /// # Examples /// /// ``` /// fn stringify(x: u32) -> String { format!("error code: {}", x) } @@ -505,7 +505,7 @@ impl Result { /// Returns an iterator over the possibly contained value. /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(7); @@ -522,7 +522,7 @@ impl Result { /// Returns a mutable iterator over the possibly contained value. /// - /// # Example + /// # Examples /// /// ``` /// let mut x: Result = Ok(7); @@ -543,7 +543,7 @@ impl Result { /// Returns a consuming iterator over the possibly contained value. /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(5); @@ -566,7 +566,7 @@ impl Result { /// Returns `res` if the result is `Ok`, otherwise returns the `Err` value of `self`. /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(2); @@ -598,7 +598,7 @@ impl Result { /// /// This function can be used for control flow based on result values. /// - /// # Example + /// # Examples /// /// ``` /// fn sq(x: u32) -> Result { Ok(x * x) } @@ -620,7 +620,7 @@ impl Result { /// Returns `res` if the result is `Err`, otherwise returns the `Ok` value of `self`. /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(2); @@ -652,7 +652,7 @@ impl Result { /// /// This function can be used for control flow based on result values. /// - /// # Example + /// # Examples /// /// ``` /// fn sq(x: u32) -> Result { Ok(x * x) } @@ -675,7 +675,7 @@ impl Result { /// Unwraps a result, yielding the content of an `Ok`. /// Else it returns `optb`. /// - /// # Example + /// # Examples /// /// ``` /// let optb = 2; @@ -697,7 +697,7 @@ impl Result { /// Unwraps a result, yielding the content of an `Ok`. /// If the value is an `Err` then it calls `op` with its value. /// - /// # Example + /// # Examples /// /// ``` /// fn count(x: &str) -> usize { x.len() } @@ -724,7 +724,7 @@ impl Result { /// Panics if the value is an `Err`, with a custom panic message provided /// by the `Err`'s value. /// - /// # Example + /// # Examples /// /// ``` /// let x: Result = Ok(2); @@ -755,7 +755,7 @@ impl Result { /// Panics if the value is an `Ok`, with a custom panic message provided /// by the `Ok`'s value. /// - /// # Example + /// # Examples /// /// ```{.should_fail} /// let x: Result = Ok(2); diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 1f58d7753549d..a8282e5701ee9 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1433,7 +1433,7 @@ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { /// function taking the lifetime of a host value for the slice, or by explicit /// annotation. /// -/// # Example +/// # Examples /// /// ```rust /// use std::slice; @@ -1476,7 +1476,7 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] { /// valid for `len` elements, nor whether the lifetime provided is a suitable /// lifetime for the returned slice. /// -/// # Example +/// # Examples /// /// ```rust /// use std::slice; diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index a5ade2ae2a579..6f72890d96fb5 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1183,7 +1183,7 @@ mod traits { /// Panics when `begin` and `end` do not point to valid characters /// or point beyond the last character of the string. /// - /// # Example + /// # Examples /// /// ```rust /// let s = "Löwe 老虎 Léopard"; diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 1f669c66eb117..9eeb9b869ce3b 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -215,7 +215,7 @@ pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { /// the two ends of a range of values, that is they /// can not "walk past each other". /// -/// # Example +/// # Examples /// /// `char::Searcher` is a `DoubleEndedSearcher` because searching for a /// `char` only requires looking at one at a time, which behaves the same diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs index f0f861a3831a1..1aee6e0be2ecc 100644 --- a/src/liblog/macros.rs +++ b/src/liblog/macros.rs @@ -16,7 +16,7 @@ /// format!-based argument list. See documentation in `std::fmt` for details on /// how to use the syntax. /// -/// # Example +/// # Examples /// /// ``` /// #[macro_use] extern crate log; @@ -64,7 +64,7 @@ macro_rules! log { /// A convenience macro for logging at the error log level. /// -/// # Example +/// # Examples /// /// ``` /// #[macro_use] extern crate log; @@ -89,7 +89,7 @@ macro_rules! error { /// A convenience macro for logging at the warning log level. /// -/// # Example +/// # Examples /// /// ``` /// #[macro_use] extern crate log; @@ -113,7 +113,7 @@ macro_rules! warn { /// A convenience macro for logging at the info log level. /// -/// # Example +/// # Examples /// /// ``` /// #[macro_use] extern crate log; @@ -139,7 +139,7 @@ macro_rules! info { /// be omitted at compile time by passing `--cfg ndebug` to the compiler. If /// this option is not passed, then debug statements will be compiled. /// -/// # Example +/// # Examples /// /// ``` /// #[macro_use] extern crate log; @@ -162,7 +162,7 @@ macro_rules! debug { /// A macro to test whether a log level is enabled for the current module. /// -/// # Example +/// # Examples /// /// ``` /// #[macro_use] extern crate log; diff --git a/src/librand/distributions/exponential.rs b/src/librand/distributions/exponential.rs index bf9d334e8a473..6820d9c5c48f2 100644 --- a/src/librand/distributions/exponential.rs +++ b/src/librand/distributions/exponential.rs @@ -57,7 +57,7 @@ impl Rand for Exp1 { /// This distribution has density function: `f(x) = lambda * /// exp(-lambda * x)` for `x > 0`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs index ae3724a2b431a..6659bf0f3eeb3 100644 --- a/src/librand/distributions/gamma.rs +++ b/src/librand/distributions/gamma.rs @@ -37,7 +37,7 @@ use super::{IndependentSample, Sample, Exp}; /// == 1`, and using the boosting technique described in [1] for /// `shape < 1`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; @@ -184,7 +184,7 @@ impl IndependentSample for GammaLargeShape { /// `k`, this uses the equivalent characterisation `χ²(k) = Gamma(k/2, /// 2)`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; @@ -241,7 +241,7 @@ impl IndependentSample for ChiSquared { /// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) / /// (χ²(n)/n)`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; @@ -285,7 +285,7 @@ impl IndependentSample for FisherF { /// The Student t distribution, `t(nu)`, where `nu` is the degrees of /// freedom. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index 9775507b3cd57..42e830ae4ca4b 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -93,7 +93,7 @@ pub struct Weighted { /// all `T`, as is `uint`, so one can store references or indices into /// another vector. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; diff --git a/src/librand/distributions/normal.rs b/src/librand/distributions/normal.rs index ab5d03ad82557..aeca477fb94ce 100644 --- a/src/librand/distributions/normal.rs +++ b/src/librand/distributions/normal.rs @@ -73,7 +73,7 @@ impl Rand for StandardNormal { /// This uses the ZIGNOR variant of the Ziggurat method, see /// `StandardNormal` for more details. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; @@ -121,7 +121,7 @@ impl IndependentSample for Normal { /// If `X` is log-normal distributed, then `ln(X)` is `N(mean, /// std_dev**2)` distributed. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand; diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index c5a260346e0ad..9a2576a87fcb5 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -33,7 +33,7 @@ use distributions::{Sample, IndependentSample}; /// primitive integer types satisfy this property, and the float types /// normally satisfy it, but rounding may mean `high` can occur. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand::distributions::{IndependentSample, Range}; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 6bc56ce9084b3..c5ff8ffe4576a 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -146,7 +146,7 @@ pub trait Rng : Sized { /// (e.g. reading past the end of a file that is being used as the /// source of randomness). /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{thread_rng, Rng}; @@ -181,7 +181,7 @@ pub trait Rng : Sized { /// Return a random value of a `Rand` type. /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{thread_rng, Rng}; @@ -199,7 +199,7 @@ pub trait Rng : Sized { /// Return an iterator that will yield an infinite number of randomly /// generated items. /// - /// # Example + /// # Examples /// /// ``` /// use std::rand::{thread_rng, Rng}; @@ -226,7 +226,7 @@ pub trait Rng : Sized { /// /// Panics if `low >= high`. /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{thread_rng, Rng}; @@ -244,7 +244,7 @@ pub trait Rng : Sized { /// Return a bool with a 1 in n chance of true /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{thread_rng, Rng}; @@ -258,7 +258,7 @@ pub trait Rng : Sized { /// Return an iterator of random characters from the set A-Z,a-z,0-9. /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{thread_rng, Rng}; @@ -274,7 +274,7 @@ pub trait Rng : Sized { /// /// Return `None` if `values` is empty. /// - /// # Example + /// # Examples /// /// ``` /// use std::rand::{thread_rng, Rng}; @@ -294,7 +294,7 @@ pub trait Rng : Sized { /// Shuffle a mutable slice in place. /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{thread_rng, Rng}; @@ -357,7 +357,7 @@ impl<'a, R: Rng> Iterator for AsciiGenerator<'a, R> { pub trait SeedableRng: Rng { /// Reseed an RNG with the given seed. /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{Rng, SeedableRng, StdRng}; @@ -372,7 +372,7 @@ pub trait SeedableRng: Rng { /// Create a new RNG with the given seed. /// - /// # Example + /// # Examples /// /// ```rust /// use std::rand::{Rng, SeedableRng, StdRng}; @@ -477,7 +477,7 @@ impl Rand for XorShiftRng { /// `Rand` implementation for `f32` and `f64` for the half-open /// `[0,1)`. /// -/// # Example +/// # Examples /// ```rust /// use std::rand::{random, Open01}; /// @@ -493,7 +493,7 @@ pub struct Open01(pub F); /// `Rand` implementation of `f32` and `f64` for the half-open /// `[0,1)`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand::{random, Closed01}; diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index 22b77a759319b..f39021d4a5f04 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -100,7 +100,7 @@ impl, Rsdr: Reseeder + Default> /// Something that can be used to reseed an RNG via `ReseedingRng`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand::{Rng, SeedableRng, StdRng}; diff --git a/src/librbml/io.rs b/src/librbml/io.rs index fc0a9d29ed6f2..bf4b5ee2c0e74 100644 --- a/src/librbml/io.rs +++ b/src/librbml/io.rs @@ -36,7 +36,7 @@ fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult /// Writes to an owned, growable byte vector that supports seeking. /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 0b32f7f69eb44..38502e3c10241 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -193,7 +193,7 @@ pub fn can_reach(edges_map: &HashMap, S>, source: T, /// ``` /// but currently it is not possible. /// -/// # Example +/// # Examples /// ``` /// struct Context { /// cache: RefCell> diff --git a/src/librustc_bitflags/lib.rs b/src/librustc_bitflags/lib.rs index 0367130c1320f..2992ddbc4f453 100644 --- a/src/librustc_bitflags/lib.rs +++ b/src/librustc_bitflags/lib.rs @@ -29,7 +29,7 @@ /// The flags should only be defined for integer types, otherwise unexpected /// type errors may occur at compile time. /// -/// # Example +/// # Examples /// /// ```{.rust} /// #[macro_use] extern crate rustc_bitflags; diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 6f3d90d45b087..26994a6d79d7f 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -29,7 +29,7 @@ const CHARS: &'static [u8] = b"0123456789abcdef"; impl ToHex for [u8] { /// Turn a vector of `u8` bytes into a hexadecimal string. /// - /// # Example + /// # Examples /// /// ```rust /// extern crate serialize; @@ -96,7 +96,7 @@ impl FromHex for str { /// You can use the `String::from_utf8` function to turn a /// `Vec` into a string with characters corresponding to those values. /// - /// # Example + /// # Examples /// /// This converts a string literal to hexadecimal and back. /// diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 9502302aa53ab..18f86901b8f44 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -225,7 +225,7 @@ fn test_resize_policy() { /// 3. Emmanuel Goossaert. ["Robin Hood hashing: backward shift /// deletion"](http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/) /// -/// # Example +/// # Examples /// /// ``` /// use std::collections::HashMap; @@ -497,7 +497,7 @@ impl HashMap impl HashMap { /// Create an empty HashMap. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -511,7 +511,7 @@ impl HashMap { /// Creates an empty hash map with the given initial capacity. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -531,7 +531,7 @@ impl HashMap /// /// The creates map has the default initial capacity. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -559,7 +559,7 @@ impl HashMap /// cause many collisions and very poor performance. Setting it /// manually using this function can expose a DoS attack vector. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -586,7 +586,7 @@ impl HashMap /// Returns the number of elements the map can hold without reallocating. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -607,7 +607,7 @@ impl HashMap /// /// Panics if the new allocation size overflows `usize`. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -714,7 +714,7 @@ impl HashMap /// down as much as possible while maintaining the internal rules /// and possibly leaving some space in accordance with the resize policy. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -806,7 +806,7 @@ impl HashMap /// An iterator visiting all keys in arbitrary order. /// Iterator element type is `&'a K`. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -831,7 +831,7 @@ impl HashMap /// An iterator visiting all values in arbitrary order. /// Iterator element type is `&'a V`. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -856,7 +856,7 @@ impl HashMap /// An iterator visiting all key-value pairs in arbitrary order. /// Iterator element type is `(&'a K, &'a V)`. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -879,7 +879,7 @@ impl HashMap /// with mutable references to the values. /// Iterator element type is `(&'a K, &'a mut V)`. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -907,7 +907,7 @@ impl HashMap /// pair out of the map in arbitrary order. The map cannot be used after /// calling this. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -942,7 +942,7 @@ impl HashMap /// Returns the number of elements in the map. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -957,7 +957,7 @@ impl HashMap /// Returns true if the map contains no elements. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -974,7 +974,7 @@ impl HashMap /// Clears the map, returning all key-value pairs as an iterator. Keeps the /// allocated memory for reuse. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -1005,7 +1005,7 @@ impl HashMap /// Clears the map, removing all key-value pairs. Keeps the allocated memory /// for reuse. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -1027,7 +1027,7 @@ impl HashMap /// `Hash` and `Eq` on the borrowed form *must* match those for /// the key type. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -1050,7 +1050,7 @@ impl HashMap /// `Hash` and `Eq` on the borrowed form *must* match those for /// the key type. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -1073,7 +1073,7 @@ impl HashMap /// `Hash` and `Eq` on the borrowed form *must* match those for /// the key type. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -1096,7 +1096,7 @@ impl HashMap /// Inserts a key-value pair from the map. If the key already had a value /// present in the map, that value is returned. Otherwise, `None` is returned. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; @@ -1128,7 +1128,7 @@ impl HashMap /// `Hash` and `Eq` on the borrowed form *must* match those for /// the key type. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashMap; diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index cdc0ebd76aada..35115ad77fefd 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -38,7 +38,7 @@ use super::state::HashState; /// HashMap where the value is (). As with the `HashMap` type, a `HashSet` /// requires that the elements implement the `Eq` and `Hash` traits. /// -/// # Example +/// # Examples /// /// ``` /// use std::collections::HashSet; @@ -100,7 +100,7 @@ pub struct HashSet { impl HashSet { /// Create an empty HashSet. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -115,7 +115,7 @@ impl HashSet { /// Create an empty HashSet with space for at least `n` elements in /// the hash table. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -136,7 +136,7 @@ impl HashSet /// /// The hash set is also created with the default initial capacity. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -160,7 +160,7 @@ impl HashSet /// cause many collisions and very poor performance. Setting it /// manually using this function can expose a DoS attack vector. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -181,7 +181,7 @@ impl HashSet /// Returns the number of elements the set can hold without reallocating. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -202,7 +202,7 @@ impl HashSet /// /// Panics if the new allocation size overflows `usize`. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -218,7 +218,7 @@ impl HashSet /// down as much as possible while maintaining the internal rules /// and possibly leaving some space in accordance with the resize policy. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -238,7 +238,7 @@ impl HashSet /// An iterator visiting all elements in arbitrary order. /// Iterator element type is &'a T. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -260,7 +260,7 @@ impl HashSet /// of the set in arbitrary order. The set cannot be used after calling /// this. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -286,7 +286,7 @@ impl HashSet /// Visit the values representing the difference. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -316,7 +316,7 @@ impl HashSet /// Visit the values representing the symmetric difference. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -342,7 +342,7 @@ impl HashSet /// Visit the values representing the intersection. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -367,7 +367,7 @@ impl HashSet /// Visit the values representing the union. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -389,7 +389,7 @@ impl HashSet /// Return the number of elements in the set /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -404,7 +404,7 @@ impl HashSet /// Returns true if the set contains no elements /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -430,7 +430,7 @@ impl HashSet /// Clears the set, removing all values. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -449,7 +449,7 @@ impl HashSet /// `Hash` and `Eq` on the borrowed form *must* match those for /// the value type. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -468,7 +468,7 @@ impl HashSet /// Returns `true` if the set has no elements in common with `other`. /// This is equivalent to checking for an empty intersection. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -489,7 +489,7 @@ impl HashSet /// Returns `true` if the set is a subset of another. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -510,7 +510,7 @@ impl HashSet /// Returns `true` if the set is a superset of another. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -536,7 +536,7 @@ impl HashSet /// Adds a value to the set. Returns `true` if the value was not already /// present in the set. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; @@ -557,7 +557,7 @@ impl HashSet /// `Hash` and `Eq` on the borrowed form *must* match those for /// the value type. /// - /// # Example + /// # Examples /// /// ``` /// use std::collections::HashSet; diff --git a/src/libstd/env.rs b/src/libstd/env.rs index b2ef04a5d632c..fb7de8c5f6655 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -38,7 +38,7 @@ use sys::os as os_imp; /// * There are insufficient permissions to access the current directory. /// * The internal buffer is not large enough to hold the path. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -55,7 +55,7 @@ pub fn current_dir() -> io::Result { /// Changes the current working directory to the specified path, returning /// whether the change was completed successfully or not. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -99,7 +99,7 @@ pub struct VarsOs { inner: os_imp::Env } /// environment is not valid unicode. If this is not desired, consider using the /// `env::vars_os` function. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -122,7 +122,7 @@ pub fn vars() -> Vars { /// variables at the time of this invocation, modifications to environment /// variables afterwards will not be reflected in the returned iterator. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -163,7 +163,7 @@ impl Iterator for VarsOs { /// valid unicode. If the environment variable is not present, or it is not /// valid unicode, then `Err` will be returned. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -185,7 +185,7 @@ pub fn var(key: &K) -> Result where K: AsOsStr { /// Fetches the environment variable `key` from the current process, returning /// None if the variable isn't set. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -243,7 +243,7 @@ impl Error for VarError { /// Sets the environment variable `k` to the value `v` for the currently running /// process. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -279,7 +279,7 @@ pub struct SplitPaths<'a> { inner: os_imp::SplitPaths<'a> } /// /// Returns an iterator over the paths contained in `unparsed`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -323,7 +323,7 @@ pub struct JoinPathsError { /// `Path`s contains an invalid character for constructing the `PATH` /// variable (a double quote on Windows or a colon on Unix). /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -371,7 +371,7 @@ impl Error for JoinPathsError { /// 'USERPROFILE' environment variable if it is set and not equal to the empty /// string. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -478,7 +478,7 @@ pub struct ArgsOs { inner: os_imp::Args } /// process is not valid unicode. If this is not desired it is recommended to /// use the `args_os` function instead. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; @@ -500,7 +500,7 @@ pub fn args() -> Args { /// set to arbitrary text, and it may not even exist, so this property should /// not be relied upon for security purposes. /// -/// # Example +/// # Examples /// /// ```rust /// use std::env; diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index ec9f90723be96..44564ebf53d58 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -41,7 +41,7 @@ use vec::Vec; /// a `CString` do *not* contain the trailing nul terminator unless otherwise /// specified. /// -/// # Example +/// # Examples /// /// ```no_run /// # extern crate libc; @@ -325,7 +325,7 @@ impl CStr { /// > currently implemented with an up-front calculation of the length of /// > the string. This is not guaranteed to always be the case. /// - /// # Example + /// # Examples /// /// ```no_run /// # extern crate libc; diff --git a/src/libstd/fs/mod.rs b/src/libstd/fs/mod.rs index 9f9163eb9e69f..0faae7015a6e7 100644 --- a/src/libstd/fs/mod.rs +++ b/src/libstd/fs/mod.rs @@ -36,7 +36,7 @@ mod tempdir; /// it was opened with. Files also implement `Seek` to alter the logical cursor /// that the file contains internally. /// -/// # Example +/// # Examples /// /// ```no_run /// use std::io::prelude::*; @@ -392,7 +392,7 @@ impl DirEntry { /// Remove a file from the underlying filesystem. /// -/// # Example +/// # Examples /// /// ```rust,no_run /// use std::fs; @@ -420,7 +420,7 @@ pub fn remove_file(path: &P) -> io::Result<()> { /// This function will traverse soft links to query information about the /// destination file. /// -/// # Example +/// # Examples /// /// ```rust,no_run /// # fn foo() -> std::io::Result<()> { @@ -444,7 +444,7 @@ pub fn metadata(path: &P) -> io::Result { /// Rename a file or directory to a new name. /// -/// # Example +/// # Examples /// /// ```rust,no_run /// use std::fs; @@ -472,7 +472,7 @@ pub fn rename(from: &P, to: &Q) /// Note that if `from` and `to` both point to the same file, then the file /// will likely get truncated by this operation. /// -/// # Example +/// # Examples /// /// ```rust /// use std::fs; @@ -541,7 +541,7 @@ pub fn read_link(path: &P) -> io::Result { /// Create a new, empty directory at the provided path /// -/// # Example +/// # Examples /// /// ```rust /// use std::fs; @@ -587,7 +587,7 @@ pub fn create_dir_all(path: &P) -> io::Result<()> { /// Remove an existing, empty directory /// -/// # Example +/// # Examples /// /// ```rust /// use std::fs; @@ -638,7 +638,7 @@ pub fn remove_dir_all(path: &P) -> io::Result<()> { /// The iterator will yield instances of `io::Result`. New errors may /// be encountered after an iterator is initially constructed. /// -/// # Example +/// # Examples /// /// ```rust /// use std::io; @@ -776,7 +776,7 @@ pub fn set_file_times(path: &P, accessed: u64, /// Changes the permissions found on a file or a directory. /// -/// # Example +/// # Examples /// /// ``` /// # fn foo() -> std::io::Result<()> { diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index abdcca59c58f3..a502294326725 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -26,7 +26,7 @@ /// The multi-argument form of this macro panics with a string and has the /// `format!` syntax for building a string. /// -/// # Example +/// # Examples /// /// ```should_fail /// # #![allow(unreachable_code)] @@ -74,7 +74,7 @@ macro_rules! print { /// The syntax of this macro is the same as that used for `format!`. For more /// information, see `std::fmt` and `std::old_io::stdio`. /// -/// # Example +/// # Examples /// /// ``` /// println!("hello there!"); @@ -177,7 +177,7 @@ pub mod builtin { /// /// For more information, see the documentation in `std::fmt`. /// - /// # Example + /// # Examples /// /// ```rust /// use std::fmt; @@ -200,7 +200,7 @@ pub mod builtin { /// will be emitted. To not emit a compile error, use the `option_env!` /// macro instead. /// - /// # Example + /// # Examples /// /// ```rust /// let path: &'static str = env!("PATH"); @@ -219,7 +219,7 @@ pub mod builtin { /// A compile time error is never emitted when using this macro regardless /// of whether the environment variable is present or not. /// - /// # Example + /// # Examples /// /// ```rust /// let key: Option<&'static str> = option_env!("SECRET_KEY"); @@ -263,7 +263,7 @@ pub mod builtin { /// Integer and floating point literals are stringified in order to be /// concatenated. /// - /// # Example + /// # Examples /// /// ``` /// let s = concat!("test", 10, 'b', true); @@ -278,7 +278,7 @@ pub mod builtin { /// the invocation of the `line!()` macro itself, but rather the first macro /// invocation leading up to the invocation of the `line!()` macro. /// - /// # Example + /// # Examples /// /// ``` /// let current_line = line!(); @@ -293,7 +293,7 @@ pub mod builtin { /// the invocation of the `column!()` macro itself, but rather the first macro /// invocation leading up to the invocation of the `column!()` macro. /// - /// # Example + /// # Examples /// /// ``` /// let current_col = column!(); @@ -309,7 +309,7 @@ pub mod builtin { /// first macro invocation leading up to the invocation of the `file!()` /// macro. /// - /// # Example + /// # Examples /// /// ``` /// let this_file = file!(); @@ -324,7 +324,7 @@ pub mod builtin { /// stringification of all the tokens passed to the macro. No restrictions /// are placed on the syntax of the macro invocation itself. /// - /// # Example + /// # Examples /// /// ``` /// let one_plus_one = stringify!(1 + 1); @@ -339,7 +339,7 @@ pub mod builtin { /// contents of the filename specified. The file is located relative to the /// current file (similarly to how modules are found), /// - /// # Example + /// # Examples /// /// ```rust,ignore /// let secret_key = include_str!("secret-key.ascii"); @@ -353,7 +353,7 @@ pub mod builtin { /// the contents of the filename specified. The file is located relative to /// the current file (similarly to how modules are found), /// - /// # Example + /// # Examples /// /// ```rust,ignore /// let secret_key = include_bytes!("secret-key.bin"); @@ -367,7 +367,7 @@ pub mod builtin { /// leading back up to the crate root. The first component of the path /// returned is the name of the crate currently being compiled. /// - /// # Example + /// # Examples /// /// ```rust /// mod test { @@ -390,7 +390,7 @@ pub mod builtin { /// The syntax given to this macro is the same syntax as the `cfg` /// attribute. /// - /// # Example + /// # Examples /// /// ```rust /// let my_directory = if cfg!(windows) { diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index d73c06a2549e1..b8cb8cb528929 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -82,7 +82,7 @@ impl Iterator for LookupHost { /// This method may perform a DNS query to resolve `host` and may also inspect /// system configuration to resolve the specified hostname. /// -/// # Example +/// # Examples /// /// ```no_run /// use std::net; diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index fd723ea13e962..76c0483547330 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -21,7 +21,7 @@ use sys_common::AsInner; /// /// The socket will be closed when the value is dropped. /// -/// # Example +/// # Examples /// /// ```no_run /// use std::io::prelude::*; diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 92f00599826dd..041e6551ff5ec 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -21,7 +21,7 @@ use sys_common::AsInner; /// IPv6 addresses, and there is no corresponding notion of a server because UDP /// is a datagram protocol. /// -/// # Example +/// # Examples /// /// ```no_run /// use std::net::UdpSocket; diff --git a/src/libstd/old_io/buffered.rs b/src/libstd/old_io/buffered.rs index cbb7bf0432745..3ee73f5ff6033 100644 --- a/src/libstd/old_io/buffered.rs +++ b/src/libstd/old_io/buffered.rs @@ -31,7 +31,7 @@ use vec::Vec; /// `BufferedReader` performs large, infrequent reads on the underlying /// `Reader` and maintains an in-memory buffer of the results. /// -/// # Example +/// # Examples /// /// ```rust /// use std::old_io::{BufferedReader, File}; @@ -134,7 +134,7 @@ impl Reader for BufferedReader { /// /// This writer will be flushed when it is dropped. /// -/// # Example +/// # Examples /// /// ```rust /// use std::old_io::{BufferedWriter, File}; @@ -320,7 +320,7 @@ impl Reader for InternalBufferedWriter { /// /// The output half will be flushed when this stream is dropped. /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] diff --git a/src/libstd/old_io/comm_adapters.rs b/src/libstd/old_io/comm_adapters.rs index dec1ae98ba0be..72ba653a9861a 100644 --- a/src/libstd/old_io/comm_adapters.rs +++ b/src/libstd/old_io/comm_adapters.rs @@ -20,7 +20,7 @@ use vec::Vec; /// Allows reading from a rx. /// -/// # Example +/// # Examples /// /// ``` /// use std::sync::mpsc::channel; @@ -111,7 +111,7 @@ impl Reader for ChanReader { /// Allows writing to a tx. /// -/// # Example +/// # Examples /// /// ``` /// # #![allow(unused_must_use)] diff --git a/src/libstd/old_io/fs.rs b/src/libstd/old_io/fs.rs index afffed2278b8d..b0116bd4efdc4 100644 --- a/src/libstd/old_io/fs.rs +++ b/src/libstd/old_io/fs.rs @@ -27,7 +27,7 @@ //! the metadata of a file. This includes getting the `stat` information, //! reading off particular bits of it, etc. //! -//! # Example +//! # Examples //! //! ```rust //! # #![allow(unused_must_use)] @@ -102,7 +102,7 @@ impl File { /// Open a file at `path` in the mode specified by the `mode` and `access` /// arguments /// - /// # Example + /// # Examples /// /// ```rust,should_fail /// use std::old_io::{File, Open, ReadWrite}; @@ -173,7 +173,7 @@ impl File { /// /// For more information, see the `File::open_mode` function. /// - /// # Example + /// # Examples /// /// ```rust /// use std::old_io::File; @@ -192,7 +192,7 @@ impl File { /// /// For more information, see the `File::open_mode` function. /// - /// # Example + /// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -283,7 +283,7 @@ impl File { /// Unlink a file from the underlying filesystem. /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -314,7 +314,7 @@ pub fn unlink(path: &Path) -> IoResult<()> { /// directory, etc. This function will traverse symlinks to query /// information about the destination file. /// -/// # Example +/// # Examples /// /// ```rust /// use std::old_io::fs; @@ -356,7 +356,7 @@ pub fn lstat(path: &Path) -> IoResult { /// Rename a file or directory to a new name. /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -384,7 +384,7 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> { /// Note that if `from` and `to` both point to the same file, then the file /// will likely get truncated by this operation. /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -434,7 +434,7 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> { /// Changes the permission mode bits found on a file or a directory. This /// function takes a mask from the `io` module /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -505,7 +505,7 @@ pub fn readlink(path: &Path) -> IoResult { /// Create a new, empty directory at the provided path /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -529,7 +529,7 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> { /// Remove an existing, empty directory /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -553,7 +553,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> { /// Retrieve a vector containing all entries within a provided directory /// -/// # Example +/// # Examples /// /// ```rust /// use std::old_io::fs::PathExtensions; diff --git a/src/libstd/old_io/mem.rs b/src/libstd/old_io/mem.rs index e6a8b90ea3334..2445da9ea3bab 100644 --- a/src/libstd/old_io/mem.rs +++ b/src/libstd/old_io/mem.rs @@ -51,7 +51,7 @@ impl Writer for Vec { /// Writes to an owned, growable byte vector /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -111,7 +111,7 @@ impl Writer for MemWriter { /// Reads from an owned byte vector /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -241,7 +241,7 @@ impl<'a> Buffer for &'a [u8] { /// If a write will not fit in the buffer, it returns an error and does not /// write any data. /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -313,7 +313,7 @@ impl<'a> Seek for BufWriter<'a> { /// Reads from a fixed-size byte slice /// -/// # Example +/// # Examples /// /// ```rust /// # #![allow(unused_must_use)] diff --git a/src/libstd/old_io/mod.rs b/src/libstd/old_io/mod.rs index f2042b384ceea..f71698fa72586 100644 --- a/src/libstd/old_io/mod.rs +++ b/src/libstd/old_io/mod.rs @@ -1276,7 +1276,7 @@ impl<'a> Writer for &'a mut (Writer+'a) { /// A `RefWriter` is a struct implementing `Writer` which contains a reference /// to another writer. This is often useful when composing streams. /// -/// # Example +/// # Examples /// /// ``` /// use std::old_io::util::TeeReader; @@ -1401,7 +1401,7 @@ pub trait Buffer: Reader { /// encoded Unicode codepoints. If a newline is encountered, then the /// newline is contained in the returned string. /// - /// # Example + /// # Examples /// /// ```rust /// use std::old_io::BufReader; @@ -1625,7 +1625,7 @@ impl<'a, T, A: ?Sized + Acceptor> Iterator for IncomingConnections<'a, A> { /// Creates a standard error for a commonly used flavor of error. The `detail` /// field of the returned error will always be `None`. /// -/// # Example +/// # Examples /// /// ``` /// use std::old_io as io; diff --git a/src/libstd/old_io/net/pipe.rs b/src/libstd/old_io/net/pipe.rs index 2ecaf515f081b..5935253290283 100644 --- a/src/libstd/old_io/net/pipe.rs +++ b/src/libstd/old_io/net/pipe.rs @@ -50,7 +50,7 @@ impl UnixStream { /// /// The returned stream will be closed when the object falls out of scope. /// - /// # Example + /// # Examples /// /// ```rust /// # #![allow(unused_must_use)] @@ -175,7 +175,7 @@ impl UnixListener { /// /// This listener will be closed when it falls out of scope. /// - /// # Example + /// # Examples /// /// ``` /// # fn foo() { diff --git a/src/libstd/old_io/net/tcp.rs b/src/libstd/old_io/net/tcp.rs index 73ef21fa3aa96..6fb8020a3d602 100644 --- a/src/libstd/old_io/net/tcp.rs +++ b/src/libstd/old_io/net/tcp.rs @@ -38,7 +38,7 @@ use sys_common; /// /// The socket will be closed when the value is dropped. /// -/// # Example +/// # Examples /// /// ```no_run /// use std::old_io::TcpStream; @@ -130,7 +130,7 @@ impl TcpStream { /// This method will close the reading portion of this connection, causing /// all pending and future reads to immediately return with an error. /// - /// # Example + /// # Examples /// /// ```no_run /// # #![allow(unused_must_use)] @@ -373,7 +373,7 @@ impl TcpAcceptor { /// regardless of whether the timeout has expired or not (the accept will /// not block in this case). /// - /// # Example + /// # Examples /// /// ```no_run /// use std::old_io::TcpListener; @@ -417,7 +417,7 @@ impl TcpAcceptor { /// This is useful for waking up a thread in an accept loop to indicate that /// it should exit. /// - /// # Example + /// # Examples /// /// ``` /// use std::old_io::{TcpListener, Listener, Acceptor, EndOfFile}; diff --git a/src/libstd/old_io/net/udp.rs b/src/libstd/old_io/net/udp.rs index 67b57b250860f..97ef3da2f369a 100644 --- a/src/libstd/old_io/net/udp.rs +++ b/src/libstd/old_io/net/udp.rs @@ -28,7 +28,7 @@ use sys_common; /// IPv6 addresses, and there is no corresponding notion of a server because UDP /// is a datagram protocol. /// -/// # Example +/// # Examples /// /// ```rust,no_run /// # #![allow(unused_must_use)] diff --git a/src/libstd/old_io/pipe.rs b/src/libstd/old_io/pipe.rs index b7b626db034e1..b78c8acb1900d 100644 --- a/src/libstd/old_io/pipe.rs +++ b/src/libstd/old_io/pipe.rs @@ -43,7 +43,7 @@ impl PipeStream { /// This operation consumes ownership of the file descriptor and it will be /// closed once the object is deallocated. /// - /// # Example + /// # Examples /// /// ```{rust,no_run} /// # #![allow(unused_must_use)] diff --git a/src/libstd/old_io/process.rs b/src/libstd/old_io/process.rs index a30dcd9d9f0ab..cabba8e358af0 100644 --- a/src/libstd/old_io/process.rs +++ b/src/libstd/old_io/process.rs @@ -57,7 +57,7 @@ use thread; /// process is created via the `Command` struct, which configures the spawning /// process and can itself be constructed using a builder-style interface. /// -/// # Example +/// # Examples /// /// ```should_fail /// use std::old_io::Command; @@ -361,7 +361,7 @@ impl Command { /// Executes the command as a child process, waiting for it to finish and /// collecting all of its output. /// - /// # Example + /// # Examples /// /// ``` /// use std::old_io::Command; @@ -382,7 +382,7 @@ impl Command { /// Executes a command as a child process, waiting for it to finish and /// collecting its exit status. /// - /// # Example + /// # Examples /// /// ``` /// use std::old_io::Command; @@ -656,7 +656,7 @@ impl Process { /// A value of `None` will clear any previous timeout, and a value of `Some` /// will override any previously set timeout. /// - /// # Example + /// # Examples /// /// ```no_run /// use std::old_io::{Command, IoResult}; diff --git a/src/libstd/old_io/stdio.rs b/src/libstd/old_io/stdio.rs index 85bf4908f8397..70e8a4ceff0a0 100644 --- a/src/libstd/old_io/stdio.rs +++ b/src/libstd/old_io/stdio.rs @@ -15,7 +15,7 @@ //! inspected for information about terminal dimensions or for related information //! about the stream or terminal to which it is attached. //! -//! # Example +//! # Examples //! //! ```rust //! # #![allow(unused_must_use)] diff --git a/src/libstd/old_io/timer.rs b/src/libstd/old_io/timer.rs index 375fe6ce483aa..de7883c715a2c 100644 --- a/src/libstd/old_io/timer.rs +++ b/src/libstd/old_io/timer.rs @@ -113,7 +113,7 @@ impl Timer { /// invalidated at the end of that statement, and all `recv` calls will /// fail. /// - /// # Example + /// # Examples /// /// ```rust /// use std::old_io::Timer; @@ -165,7 +165,7 @@ impl Timer { /// invalidated at the end of that statement, and all `recv` calls will /// fail. /// - /// # Example + /// # Examples /// /// ```rust /// use std::old_io::Timer; diff --git a/src/libstd/old_path/mod.rs b/src/libstd/old_path/mod.rs index 4f8976fb2ecda..7551e91178cba 100644 --- a/src/libstd/old_path/mod.rs +++ b/src/libstd/old_path/mod.rs @@ -46,7 +46,7 @@ //! suitable for passing to any API that actually operates on the path; it is only intended for //! display. //! -//! ## Example +//! ## Examples //! //! ```rust //! use std::old_io::fs::PathExtensions; @@ -140,7 +140,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Creates a new Path from a byte vector or string. /// The resulting Path will always be normalized. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -164,7 +164,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Creates a new Path from a byte vector or string, if possible. /// The resulting Path will always be normalized. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -186,7 +186,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the path as a string, if possible. /// If the path is not representable in utf-8, this returns None. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -203,7 +203,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the path as a byte vector /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -217,7 +217,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Converts the Path into an owned byte vector /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -232,7 +232,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns an object that implements `Display` for printing paths /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -250,7 +250,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// If there is no filename, nothing will be printed. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -267,7 +267,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the directory component of `self`, as a byte vector (with no trailing separator). /// If `self` has no directory component, returns ['.']. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -282,7 +282,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the directory component of `self`, as a string, if possible. /// See `dirname` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -301,7 +301,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// If `self` represents the root of the file hierarchy, returns None. /// If `self` is "." or "..", returns None. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -316,7 +316,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the file component of `self`, as a string, if possible. /// See `filename` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -335,7 +335,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// The stem is the portion of the filename just before the last '.'. /// If there is no '.', the entire filename is returned. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -362,7 +362,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the stem of the filename of `self`, as a string, if possible. /// See `filestem` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -382,7 +382,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// If there is no extension, None is returned. /// If the filename ends in '.', the empty vector is returned. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -409,7 +409,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the extension of the filename of `self`, as a string, if possible. /// See `extension` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -427,7 +427,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Replaces the filename portion of the path with the given byte vector or string. /// If the replacement name is [], this is equivalent to popping the path. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -453,7 +453,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// If the argument is [] or "", this removes the extension. /// If `self` has no filename, this is a no-op. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -503,7 +503,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// byte vector or string. /// See `set_filename` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -528,7 +528,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// byte vector or string. /// See `set_extension` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -552,7 +552,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns the directory component of `self`, as a Path. /// If `self` represents the root of the filesystem hierarchy, returns `self`. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -571,7 +571,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// If `self` is not absolute, or vol/cwd-relative in the case of Windows, this returns None. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -586,7 +586,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Pushes a path (as a byte vector or string) onto `self`. /// If the argument represents an absolute path, it replaces `self`. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -610,7 +610,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Pushes multiple paths (as byte vectors or strings) onto `self`. /// See `push` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -639,7 +639,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns `true` if the receiver was modified, or `false` if it already /// represented the root of the file hierarchy. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -656,7 +656,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// (as a byte vector or string). /// If the given path is absolute, the new Path will represent just that. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -681,7 +681,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// (as byte vectors or strings). /// See `join` for details. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -703,7 +703,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// An absolute path is defined as one that, when joined to another path, will /// yield back the same absolute path. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -720,7 +720,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// But for Windows paths, it also means the path is not volume-relative or /// relative to the current working directory. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -738,7 +738,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// If both paths are relative, they are compared as though they are relative /// to the same parent path. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -757,7 +757,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// If `self` is absolute and `base` is relative, or on Windows if both /// paths refer to separate drives, an absolute path is returned. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); @@ -773,7 +773,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Returns whether the relative path `child` is a suffix of `self`. /// - /// # Example + /// # Examples /// /// ``` /// # foo(); diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs index 5f2f1728be1a6..838710b1aec8e 100644 --- a/src/libstd/old_path/windows.rs +++ b/src/libstd/old_path/windows.rs @@ -603,7 +603,7 @@ impl Path { /// /// Panics if the vector contains a `NUL`, or if it contains invalid UTF-8. /// - /// # Example + /// # Examples /// /// ``` /// println!("{}", Path::new(r"C:\some\path").display()); @@ -617,7 +617,7 @@ impl Path { /// /// Returns `None` if the vector contains a `NUL`, or if it contains invalid UTF-8. /// - /// # Example + /// # Examples /// /// ``` /// let path = Path::new_opt(r"C:\some\path"); diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 9c42d1be77ee1..f81377e80841b 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -121,7 +121,7 @@ pub const TMPBUF_SZ : uint = 1000; /// * There are insufficient permissions to access the current directory. /// * The internal buffer is not large enough to hold the path. /// -/// # Example +/// # Examples /// /// ```rust /// use std::os; @@ -141,7 +141,7 @@ pub fn getcwd() -> IoResult { /// Invalid UTF-8 bytes are replaced with \uFFFD. See `String::from_utf8_lossy()` /// for details. /// -/// # Example +/// # Examples /// /// ```rust /// use std::os; @@ -177,7 +177,7 @@ pub fn env_as_bytes() -> Vec<(Vec, Vec)> { /// /// Panics if `n` has any interior NULs. /// -/// # Example +/// # Examples /// /// ```rust /// use std::os; @@ -219,7 +219,7 @@ fn byteify(s: OsString) -> Vec { /// Sets the environment variable `n` to the value `v` for the currently running /// process. /// -/// # Example +/// # Examples /// /// ```rust /// use std::os; @@ -260,7 +260,7 @@ pub fn unsetenv(n: &str) { /// Parses input according to platform conventions for the `PATH` /// environment variable. /// -/// # Example +/// # Examples /// ```rust /// use std::os; /// @@ -291,7 +291,7 @@ pub fn split_paths(unparsed: T) -> Vec { /// `Path`s contains an invalid character for constructing the `PATH` /// variable (a double quote on Windows or a colon on Unix). /// -/// # Example +/// # Examples /// /// ```rust /// use std::os; @@ -372,7 +372,7 @@ pub fn self_exe_name() -> Option { /// /// Like self_exe_name() but without the binary's name. /// -/// # Example +/// # Examples /// /// ```rust /// use std::os; @@ -401,7 +401,7 @@ pub fn self_exe_path() -> Option { /// 'USERPROFILE' environment variable if it is set and not equal to the empty /// string. /// -/// # Example +/// # Examples /// /// ```rust /// use std::os; @@ -491,7 +491,7 @@ pub fn tmpdir() -> Path { /// directory. If the given path is already an absolute path, return it /// as is. /// -/// # Example +/// # Examples /// ```rust /// use std::os; /// use std::old_path::Path; @@ -522,7 +522,7 @@ pub fn make_absolute(p: &Path) -> IoResult { /// Changes the current working directory to the specified path, returning /// whether the change was completed successfully or not. /// -/// # Example +/// # Examples /// ```rust /// use std::os; /// use std::old_path::Path; @@ -543,7 +543,7 @@ pub fn errno() -> i32 { /// Return the string corresponding to an `errno()` value of `errnum`. /// -/// # Example +/// # Examples /// ```rust /// use std::os; /// @@ -739,7 +739,7 @@ extern "system" { /// /// The arguments are interpreted as utf-8, with invalid bytes replaced with \uFFFD. /// See `String::from_utf8_lossy` for details. -/// # Example +/// # Examples /// /// ```rust /// use std::os; diff --git a/src/libstd/path.rs b/src/libstd/path.rs index ad8e17fed24c2..bf71acc522ca4 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -809,7 +809,7 @@ impl<'a> cmp::Ord for Components<'a> { /// More details about the overall approach can be found in /// the module documentation. /// -/// # Example +/// # Examples /// /// ```rust /// use std::path::PathBuf; @@ -1041,7 +1041,7 @@ impl AsOsStr for PathBuf { /// This is an *unsized* type, meaning that it must always be used with behind a /// pointer like `&` or `Box`. /// -/// # Example +/// # Examples /// /// ```rust /// use std::path::Path; diff --git a/src/libstd/process.rs b/src/libstd/process.rs index ec4fcec555622..ebd0820669c53 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -35,7 +35,7 @@ use thread; /// process is created via the `Command` struct, which configures the spawning /// process and can itself be constructed using a builder-style interface. /// -/// # Example +/// # Examples /// /// ```should_fail /// # #![feature(process)] @@ -288,7 +288,7 @@ impl Command { /// /// By default, stdin, stdout and stderr are inherited by the parent. /// - /// # Example + /// # Examples /// /// ``` /// # #![feature(process)] diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 7382cc6e2eb33..e8407ab1115db 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -424,7 +424,7 @@ pub fn random() -> T { /// Randomly sample up to `amount` elements from an iterator. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand::{thread_rng, sample}; diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index c56dc387b7fe6..08c43198aa1f1 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -22,7 +22,7 @@ use slice::SliceExt; /// /// It will panic if it there is insufficient data to fulfill a request. /// -/// # Example +/// # Examples /// /// ```rust /// use std::rand::{reader, Rng}; diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 3499675f5422d..4430cc3b0af82 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -34,7 +34,7 @@ use sync::{mutex, MutexGuard, PoisonError}; /// in a runtime panic. If this is not desired, then the unsafe primitives in /// `sys` do not have this restriction but may result in undefined behavior. /// -/// # Example +/// # Examples /// /// ``` /// use std::sync::{Arc, Mutex, Condvar}; @@ -66,7 +66,7 @@ pub struct Condvar { inner: Box } /// This structure is identical to `Condvar` except that it is suitable for use /// in static initializers for other structures. /// -/// # Example +/// # Examples /// /// ``` /// use std::sync::{StaticCondvar, CONDVAR_INIT}; diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 2ae1d4a9d50bc..01eeed4fb54d0 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -464,7 +464,7 @@ impl UnsafeFlavor for Receiver { /// All data sent on the sender will become available on the receiver, and no /// send will block the calling task (this channel has an "infinite buffer"). /// -/// # Example +/// # Examples /// /// ``` /// use std::sync::mpsc::channel; @@ -506,7 +506,7 @@ pub fn channel() -> (Sender, Receiver) { /// As with asynchronous channels, all senders will panic in `send` if the /// `Receiver` has been destroyed. /// -/// # Example +/// # Examples /// /// ``` /// use std::sync::mpsc::sync_channel; @@ -555,7 +555,7 @@ impl Sender { /// /// This method will never block the current thread. /// - /// # Example + /// # Examples /// /// ``` /// use std::sync::mpsc::channel; diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 2c14c9fe3f199..b5739c36aa912 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -24,7 +24,7 @@ //! received values of receivers in a much more natural syntax then usage of the //! `Select` structure directly. //! -//! # Example +//! # Examples //! //! ```rust //! use std::sync::mpsc::channel; diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 6f0febd61e803..41378a6b3127b 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -133,7 +133,7 @@ unsafe impl Sync for Mutex { } /// to a `Mutex`, a `destroy` method. This method is unsafe to call, and /// documentation can be found directly on the method. /// -/// # Example +/// # Examples /// /// ```rust /// use std::sync::{StaticMutex, MUTEX_INIT}; diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index d2054a1e819ab..5cad2916624d2 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -24,7 +24,7 @@ use sync::{StaticMutex, MUTEX_INIT}; /// functionality. This type can only be constructed with the `ONCE_INIT` /// value. /// -/// # Example +/// # Examples /// /// ```rust /// use std::sync::{Once, ONCE_INIT}; diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index e9ff6c0bf9df0..368e88e4e8b41 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -74,7 +74,7 @@ unsafe impl Sync for RwLock {} /// automatic global access as well as lazy initialization. The internal /// resources of this RwLock, however, must be manually deallocated. /// -/// # Example +/// # Examples /// /// ``` /// use std::sync::{StaticRwLock, RW_LOCK_INIT}; diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index 410e1c11bb9a9..2f9873950b62e 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -22,7 +22,7 @@ use sync::{Mutex, Condvar}; /// until the counter is positive, and each release will increment the counter /// and unblock any threads if necessary. /// -/// # Example +/// # Examples /// /// ``` /// use std::sync::Semaphore; diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index e41bc6d8683ab..3d31790550b96 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -58,7 +58,7 @@ impl<'a> Drop for Sentinel<'a> { /// Spawns `n` worker threads and replenishes the pool if any worker threads /// panic. /// -/// # Example +/// # Examples /// /// ```rust /// use std::sync::TaskPool; diff --git a/src/libstd/sys/common/thread_local.rs b/src/libstd/sys/common/thread_local.rs index 91de2662883f8..279362416392b 100644 --- a/src/libstd/sys/common/thread_local.rs +++ b/src/libstd/sys/common/thread_local.rs @@ -28,7 +28,7 @@ //! more useful in practice than this OS-based version which likely requires //! unsafe code to interoperate with. //! -//! # Example +//! # Examples //! //! Using a dynamically allocated TLS key. Note that this key can be shared //! among many threads via an `Arc`. @@ -73,7 +73,7 @@ use sys::thread_local as imp; /// time. The key is also deallocated when the Rust runtime exits or `destroy` /// is called, whichever comes first. /// -/// # Example +/// # Examples /// /// ```ignore /// use tls::os::{StaticKey, INIT}; @@ -110,7 +110,7 @@ pub struct StaticKeyInner { /// Implementations will likely, however, contain unsafe code as this type only /// operates on `*mut u8`, an unsafe pointer. /// -/// # Example +/// # Examples /// /// ```rust,ignore /// use tls::os::Key; diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 8ed7302b6653f..b9be4eb6bf52b 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -300,7 +300,7 @@ pub mod compat { /// Macro for creating a compatibility fallback for a Windows function /// - /// # Example + /// # Examples /// ``` /// compat_fn!(adll32::SomeFunctionW(_arg: LPCWSTR) { /// // Fallback implementation diff --git a/src/libstd/thread_local/mod.rs b/src/libstd/thread_local/mod.rs index 6bba73420d851..08780292c88b1 100644 --- a/src/libstd/thread_local/mod.rs +++ b/src/libstd/thread_local/mod.rs @@ -68,7 +68,7 @@ pub mod __impl { /// within a thread, and values support destructors which will be run when a /// thread exits. /// -/// # Example +/// # Examples /// /// ``` /// use std::cell::RefCell; diff --git a/src/libstd/thread_local/scoped.rs b/src/libstd/thread_local/scoped.rs index a5339568e9ef6..86e6c059a70db 100644 --- a/src/libstd/thread_local/scoped.rs +++ b/src/libstd/thread_local/scoped.rs @@ -21,7 +21,7 @@ //! period of time and it is not required to relinquish ownership of the //! contents. //! -//! # Example +//! # Examples //! //! ``` //! scoped_thread_local!(static FOO: u32); @@ -139,7 +139,7 @@ impl Key { /// Upon return, this function will restore the previous value, if any /// was available. /// - /// # Example + /// # Examples /// /// ``` /// scoped_thread_local!(static FOO: u32); @@ -191,7 +191,7 @@ impl Key { /// /// This function will panic if `set` has not previously been called. /// - /// # Example + /// # Examples /// /// ```no_run /// scoped_thread_local!(static FOO: u32); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 28d757e9be963..9ba0c265462d1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5428,7 +5428,7 @@ impl<'a> Parser<'a> { /// Parse extern crate links /// - /// # Example + /// # Examples /// /// extern crate url; /// extern crate foo = "bar"; //deprecated diff --git a/src/libunicode/u_str.rs b/src/libunicode/u_str.rs index 9b3f4b0521da3..050d2adf0504b 100644 --- a/src/libunicode/u_str.rs +++ b/src/libunicode/u_str.rs @@ -479,7 +479,7 @@ impl<'a> Iterator for Utf16Items<'a> { /// Create an iterator over the UTF-16 encoded codepoints in `v`, /// returning invalid surrogates as `LoneSurrogate`s. /// -/// # Example +/// # Examples /// /// ```rust /// use unicode::str::Utf16Item::{ScalarValue, LoneSurrogate}; From 419c0ff321c9995a0b3bfc709f61397e5d2c53d4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 11 Mar 2015 14:43:37 +0530 Subject: [PATCH 18/18] Rm unused feature --- src/libflate/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index a5cfe908aa86e..100a9e36e8677 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -25,7 +25,6 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(core)] #![feature(int_uint)] #![feature(libc)] #![feature(staged_api)]