diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index db2c6dfeb9f74..5f1830081adbf 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -324,7 +324,7 @@ impl<'a> Builder<'a> { StepDescription::run(&Builder::get_step_descriptions(Kind::Doc), self, paths); } - /// Obtain a compiler at a given stage and for a given host. Explictly does + /// Obtain a compiler at a given stage and for a given host. Explicitly does /// not take `Compiler` since all `Compiler` instances are meant to be /// obtained through this function, since it ensures that they are valid /// (i.e., built and assembled). @@ -489,7 +489,7 @@ impl<'a> Builder<'a> { // crates). Let's say, for example that rustc itself depends on the // bitflags crate. If an external crate then depends on the // bitflags crate as well, we need to make sure they don't - // conflict, even if they pick the same verison of bitflags. We'll + // conflict, even if they pick the same version of bitflags. We'll // want to make sure that e.g. a plugin and rustc each get their // own copy of bitflags. diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index f0e0874abed60..81a3845ecf76a 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -306,7 +306,7 @@ impl Step for Standalone { /// /// This will list all of `src/doc` looking for markdown files and appropriately /// perform transformations like substituting `VERSION`, `SHORT_HASH`, and - /// `STAMP` alongw ith providing the various header/footer HTML we've cutomized. + /// `STAMP` along with providing the various header/footer HTML we've customized. /// /// In the end, this is just a glorified wrapper around rustdoc! fn run(self, builder: &Builder) { diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 3ea7d349c9cd7..7b6700bfd4928 100644 --- a/src/liballoc/allocator.rs +++ b/src/liballoc/allocator.rs @@ -240,7 +240,7 @@ impl Layout { /// /// Returns `Some((k, offset))`, where `k` is layout of the concatenated /// record and `offset` is the relative location, in bytes, of the - /// start of the `next` embedded witnin the concatenated record + /// start of the `next` embedded within the concatenated record /// (assuming that the record itself starts at offset 0). /// /// On arithmetic overflow, returns `None`. @@ -297,7 +297,7 @@ impl Layout { /// /// Returns `(k, offset)`, where `k` is layout of the concatenated /// record and `offset` is the relative location, in bytes, of the - /// start of the `next` embedded witnin the concatenated record + /// start of the `next` embedded within the concatenated record /// (assuming that the record itself starts at offset 0). /// /// (The `offset` is always the same as `self.size()`; we use this @@ -544,7 +544,7 @@ pub unsafe trait Alloc { /// practice this means implementors should eschew allocating, /// especially from `self` (directly or indirectly). /// - /// Implementions of the allocation and reallocation methods + /// Implementations of the allocation and reallocation methods /// (e.g. `alloc`, `alloc_one`, `realloc`) are discouraged from /// panicking (or aborting) in the event of memory exhaustion; /// instead they should return an appropriate error from the diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 4847b21c0b3b5..480fb4b9eaa2b 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -10,16 +10,16 @@ //! Utilities for formatting and printing `String`s //! -//! This module contains the runtime support for the `format!` syntax extension. +//! This module contains the runtime support for the [`format!`] syntax extension. //! This macro is implemented in the compiler to emit calls to this module in //! order to format arguments at runtime into strings. //! //! # Usage //! -//! The `format!` macro is intended to be familiar to those coming from C's -//! printf/fprintf functions or Python's `str.format` function. +//! The [`format!`] macro is intended to be familiar to those coming from C's +//! `printf`/`fprintf` functions or Python's `str.format` function. //! -//! Some examples of the `format!` extension are: +//! Some examples of the [`format!`] extension are: //! //! ``` //! format!("Hello"); // => "Hello" @@ -67,7 +67,7 @@ //! ## Named parameters //! //! Rust itself does not have a Python-like equivalent of named parameters to a -//! function, but the `format!` macro is a syntax extension which allows it to +//! function, but the [`format!`] macro is a syntax extension which allows it to //! leverage named parameters. Named parameters are listed at the end of the //! argument list and have the syntax: //! @@ -75,7 +75,7 @@ //! identifier '=' expression //! ``` //! -//! For example, the following `format!` expressions all use named argument: +//! For example, the following [`format!`] expressions all use named argument: //! //! ``` //! format!("{argument}", argument = "test"); // => "test" @@ -102,30 +102,30 @@ //! //! If this syntax is used, then the number of characters to print precedes the //! actual object being formatted, and the number of characters must have the -//! type `usize`. +//! type [`usize`]. //! //! ## Formatting traits //! //! When requesting that an argument be formatted with a particular type, you //! are actually requesting that an argument ascribes to a particular trait. -//! This allows multiple actual types to be formatted via `{:x}` (like `i8` as -//! well as `isize`). The current mapping of types to traits is: +//! This allows multiple actual types to be formatted via `{:x}` (like [`i8`] as +//! well as [`isize`]). The current mapping of types to traits is: //! -//! * *nothing* ⇒ [`Display`](trait.Display.html) -//! * `?` ⇒ [`Debug`](trait.Debug.html) +//! * *nothing* ⇒ [`Display`] +//! * `?` ⇒ [`Debug`] //! * `o` ⇒ [`Octal`](trait.Octal.html) //! * `x` ⇒ [`LowerHex`](trait.LowerHex.html) //! * `X` ⇒ [`UpperHex`](trait.UpperHex.html) //! * `p` ⇒ [`Pointer`](trait.Pointer.html) -//! * `b` ⇒ [`Binary`](trait.Binary.html) +//! * `b` ⇒ [`Binary`] //! * `e` ⇒ [`LowerExp`](trait.LowerExp.html) //! * `E` ⇒ [`UpperExp`](trait.UpperExp.html) //! //! What this means is that any type of argument which implements the -//! `fmt::Binary` trait can then be formatted with `{:b}`. Implementations +//! [`fmt::Binary`][`Binary`] trait can then be formatted with `{:b}`. Implementations //! are provided for these traits for a number of primitive types by the //! standard library as well. If no format is specified (as in `{}` or `{:6}`), -//! then the format trait used is the `Display` trait. +//! then the format trait used is the [`Display`] trait. //! //! When implementing a format trait for your own type, you will have to //! implement a method of the signature: @@ -144,15 +144,15 @@ //! should emit output into the `f.buf` stream. It is up to each format trait //! implementation to correctly adhere to the requested formatting parameters. //! The values of these parameters will be listed in the fields of the -//! `Formatter` struct. In order to help with this, the `Formatter` struct also +//! [`Formatter`] struct. In order to help with this, the [`Formatter`] struct also //! provides some helper methods. //! -//! Additionally, the return value of this function is `fmt::Result` which is a -//! type alias of `Result<(), std::fmt::Error>`. Formatting implementations -//! should ensure that they propagate errors from the `Formatter` (e.g., when -//! calling `write!`) however, they should never return errors spuriously. That +//! Additionally, the return value of this function is [`fmt::Result`] which is a +//! type alias of [`Result`]`<(), `[`std::fmt::Error`]`>`. Formatting implementations +//! should ensure that they propagate errors from the [`Formatter`][`Formatter`] (e.g., when +//! calling [`write!`]) however, they should never return errors spuriously. That //! is, a formatting implementation must and may only return an error if the -//! passed-in `Formatter` returns an error. This is because, contrary to what +//! passed-in [`Formatter`] returns an error. This is because, contrary to what //! the function signature might suggest, string formatting is an infallible //! operation. This function only returns a result because writing to the //! underlying stream might fail and it must provide a way to propagate the fact @@ -209,12 +209,12 @@ //! //! These two formatting traits have distinct purposes: //! -//! - `fmt::Display` implementations assert that the type can be faithfully +//! - [`fmt::Display`][`Display`] implementations assert that the type can be faithfully //! represented as a UTF-8 string at all times. It is **not** expected that //! all types implement the `Display` trait. -//! - `fmt::Debug` implementations should be implemented for **all** public types. +//! - [`fmt::Debug`][`Debug`] implementations should be implemented for **all** public types. //! Output will typically represent the internal state as faithfully as possible. -//! The purpose of the `Debug` trait is to facilitate debugging Rust code. In +//! The purpose of the [`Debug`] trait is to facilitate debugging Rust code. In //! most cases, using `#[derive(Debug)]` is sufficient and recommended. //! //! Some examples of the output from both traits: @@ -227,7 +227,7 @@ //! //! ## Related macros //! -//! There are a number of related macros in the `format!` family. The ones that +//! There are a number of related macros in the [`format!`] family. The ones that //! are currently implemented are: //! //! ```ignore (only-for-syntax-highlight) @@ -241,11 +241,11 @@ //! //! ### `write!` //! -//! This and `writeln` are two macros which are used to emit the format string +//! This and [`writeln!`] are two macros which are used to emit the format string //! to a specified stream. This is used to prevent intermediate allocations of //! format strings and instead directly write the output. Under the hood, this -//! function is actually invoking the `write_fmt` function defined on the -//! `std::io::Write` trait. Example usage is: +//! function is actually invoking the [`write_fmt`] function defined on the +//! [`std::io::Write`] trait. Example usage is: //! //! ``` //! # #![allow(unused_must_use)] @@ -256,7 +256,7 @@ //! //! ### `print!` //! -//! This and `println` emit their output to stdout. Similarly to the `write!` +//! This and [`println!`] emit their output to stdout. Similarly to the [`write!`] //! macro, the goal of these macros is to avoid intermediate allocations when //! printing output. Example usage is: //! @@ -288,8 +288,8 @@ //! my_fmt_fn(format_args!(", or a {} too", "function")); //! ``` //! -//! The result of the `format_args!` macro is a value of type `fmt::Arguments`. -//! This structure can then be passed to the `write` and `format` functions +//! The result of the [`format_args!`] macro is a value of type [`fmt::Arguments`]. +//! This structure can then be passed to the [`write`] and [`format`] functions //! inside this module in order to process the format string. //! The goal of this macro is to even further prevent intermediate allocations //! when dealing formatting strings. @@ -357,7 +357,7 @@ //! * `-` - Currently not used //! * `#` - This flag is indicates that the "alternate" form of printing should //! be used. The alternate forms are: -//! * `#?` - pretty-print the `Debug` formatting +//! * `#?` - pretty-print the [`Debug`] formatting //! * `#x` - precedes the argument with a `0x` //! * `#X` - precedes the argument with a `0x` //! * `#b` - precedes the argument with a `0b` @@ -384,9 +384,9 @@ //! the `0` flag is specified for numerics, then the implicit fill character is //! `0`. //! -//! The value for the width can also be provided as a `usize` in the list of +//! The value for the width can also be provided as a [`usize`] in the list of //! parameters by using the dollar syntax indicating that the second argument is -//! a `usize` specifying the width, for example: +//! a [`usize`] specifying the width, for example: //! //! ``` //! // All of these print "Hello x !" @@ -474,6 +474,29 @@ //! The literal characters `{` and `}` may be included in a string by preceding //! them with the same character. For example, the `{` character is escaped with //! `{{` and the `}` character is escaped with `}}`. +//! +//! [`format!`]: ../../macro.format.html +//! [`usize`]: ../../std/primitive.usize.html +//! [`isize`]: ../../std/primitive.isize.html +//! [`i8`]: ../../std/primitive.i8.html +//! [`Display`]: trait.Display.html +//! [`Binary`]: trait.Binary.html +//! [`fmt::Result`]: type.Result.html +//! [`Result`]: ../../std/result/enum.Result.html +//! [`std::fmt::Error`]: struct.Error.html +//! [`Formatter`]: struct.Formatter.html +//! [`write!`]: ../../std/macro.write.html +//! [`Debug`]: trait.Debug.html +//! [`format!`]: ../../std/macro.format.html +//! [`writeln!`]: ../../std/macro.writeln.html +//! [`write_fmt`]: ../../std/io/trait.Write.html#method.write_fmt +//! [`std::io::Write`]: ../../std/io/trait.Write.html +//! [`println!`]: ../../std/macro.println.html +//! [`write!`]: ../../std/macro.write.html +//! [`format_args!`]: ../../std/macro.format_args.html +//! [`fmt::Arguments`]: struct.Arguments.html +//! [`write`]: fn.write.html +//! [`format`]: fn.format.html #![stable(feature = "rust1", since = "1.0.0")] @@ -498,10 +521,10 @@ pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; use string; -/// The `format` function takes an `Arguments` struct and returns the resulting +/// The `format` function takes an [`Arguments`] struct and returns the resulting /// formatted string. /// -/// The `Arguments` instance can be created with the `format_args!` macro. +/// The [`Arguments`] instance can be created with the [`format_args!`] macro. /// /// # Examples /// @@ -514,7 +537,7 @@ use string; /// assert_eq!(s, "Hello, world!"); /// ``` /// -/// Please note that using [`format!`][format!] might be preferrable. +/// Please note that using [`format!`] might be preferrable. /// Example: /// /// ``` @@ -522,7 +545,9 @@ use string; /// assert_eq!(s, "Hello, world!"); /// ``` /// -/// [format!]: ../macro.format.html +/// [`Arguments`]: struct.Arguments.html +/// [`format_args!`]: ../../std/macro.format_args.html +/// [`format!`]: ../../std/macro.format.html #[stable(feature = "rust1", since = "1.0.0")] pub fn format(args: Arguments) -> string::String { let capacity = args.estimated_capacity(); diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 322b137e99f0e..3ed5d2df1aba5 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -653,7 +653,7 @@ impl String { /// * `capacity` needs to be the correct value. /// /// Violating these may cause problems like corrupting the allocator's - /// internal datastructures. + /// internal data structures. /// /// The ownership of `ptr` is effectively transferred to the /// `String` which may then deallocate, reallocate or change the diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 160c0ba2ab0e3..5f68e59289d76 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -374,7 +374,7 @@ impl Vec { /// * `capacity` needs to be the capacity that the pointer was allocated with. /// /// Violating these may cause problems like corrupting the allocator's - /// internal datastructures. For example it is **not** safe + /// internal data structures. For example it is **not** safe /// to build a `Vec` from a pointer to a C `char` array and a `size_t`. /// /// The ownership of `ptr` is effectively transferred to the diff --git a/src/libcore/ops/place.rs b/src/libcore/ops/place.rs index 19da887cbbfbe..9fb171e7b924e 100644 --- a/src/libcore/ops/place.rs +++ b/src/libcore/ops/place.rs @@ -66,7 +66,7 @@ pub trait Place { /// or `Copy`, since the `make_place` method takes `self` by value. #[unstable(feature = "placement_new_protocol", issue = "27779")] pub trait Placer { - /// `Place` is the intermedate agent guarding the + /// `Place` is the intermediate agent guarding the /// uninitialized state for `Data`. type Place: InPlace; diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 7412a01e11e1e..c01938f5e1174 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -548,7 +548,7 @@ impl<'a> LabelText<'a> { } /// Renders text as string suitable for a label in a .dot file. - /// This includes quotes or suitable delimeters. + /// This includes quotes or suitable delimiters. pub fn to_dot_string(&self) -> String { match self { &LabelStr(ref s) => format!("\"{}\"", s.escape_default()), diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 57198d8ca0b77..2a0c76d99bfbd 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -87,7 +87,7 @@ pub enum NestedVisitorMap<'this, 'tcx: 'this> { /// Do not visit nested item-like things, but visit nested things /// that are inside of an item-like. /// - /// **This is the most common choice.** A very commmon pattern is + /// **This is the most common choice.** A very common pattern is /// to use `visit_all_item_likes()` as an outer loop, /// and to have the visitor that visits the contents of each item /// using this setting. diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 45b1d6c184101..919b205fdf95f 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -248,7 +248,7 @@ pub struct Map<'hir> { pub forest: &'hir Forest, /// Same as the dep_graph in forest, just available with one fewer - /// deref. This is a gratuitious micro-optimization. + /// deref. This is a gratuitous micro-optimization. pub dep_graph: DepGraph, /// NodeIds are sequential integers from 0, so we can be diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index efe0504aa18c4..7f408900dece2 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -496,7 +496,7 @@ impl Crate { &self.impl_items[&id] } - /// Visits all items in the crate in some determinstic (but + /// Visits all items in the crate in some deterministic (but /// unspecified) order. If you just need to process every item, /// but don't care about nesting, this method is the best choice. /// diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 756e0b5f9fb6a..3fd7ee276729f 100644 --- a/src/librustc/infer/at.rs +++ b/src/librustc/infer/at.rs @@ -169,7 +169,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> { } /// Sets the "trace" values that will be used for - /// error-repporting, but doesn't actually perform any operation + /// error-reporting, but doesn't actually perform any operation /// yet (this is useful when you want to set the trace using /// distinct values from those you wish to operate upon). pub fn trace(self, diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index 9ecc8b0e66b9b..0d02420457e6b 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -589,7 +589,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { (result, map) } - /// Searches the region constriants created since `snapshot` was started + /// Searches the region constraints created since `snapshot` was started /// and checks to determine whether any of the skolemized regions created /// in `skol_map` would "escape" -- meaning that they are related to /// other regions in some way. If so, the higher-ranked subtyping doesn't diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index d4d090f0153d0..d5c1163cfc1b1 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -46,7 +46,7 @@ pub trait LatticeDir<'f, 'gcx: 'f+'tcx, 'tcx: 'f> : TypeRelation<'f, 'gcx, 'tcx> // the LUB/GLB of `a` and `b` as appropriate. // // Subtle hack: ordering *may* be significant here. This method - // relates `v` to `a` first, which may help us to avoid unecessary + // relates `v` to `a` first, which may help us to avoid unnecessary // type variable obligations. See caller for details. fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>; } diff --git a/src/librustc/infer/region_inference/mod.rs b/src/librustc/infer/region_inference/mod.rs index 57f2f748b246e..5588b6d9add16 100644 --- a/src/librustc/infer/region_inference/mod.rs +++ b/src/librustc/infer/region_inference/mod.rs @@ -128,7 +128,7 @@ pub enum UndoLogEntry<'tcx> { /// We added the given `given` AddGiven(Region<'tcx>, ty::RegionVid), - /// We added a GLB/LUB "combinaton variable" + /// We added a GLB/LUB "combination variable" AddCombination(CombineMapType, TwoRegions<'tcx>), /// During skolemization, we sometimes purge entries from the undo diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 6ee06dc0a8163..17b5f6ad95439 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -69,7 +69,7 @@ pub struct LintStore { /// is true if the lint group was added by a plugin. lint_groups: FxHashMap<&'static str, (Vec, bool)>, - /// Extra info for future incompatibility lints, descibing the + /// Extra info for future incompatibility lints, describing the /// issue or RFC that caused the incompatibility. future_incompatible: FxHashMap, } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 1e8dda0addf4c..74ce68b351df9 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -695,7 +695,7 @@ impl<'tcx> Debug for TerminatorKind<'tcx> { impl<'tcx> TerminatorKind<'tcx> { /// Write the "head" part of the terminator; that is, its name and the data it uses to pick the - /// successor basic block, if any. The only information not inlcuded is the list of possible + /// successor basic block, if any. The only information not included is the list of possible /// successors, which may be rendered differently between the text and the graphviz format. pub fn fmt_head(&self, fmt: &mut W) -> fmt::Result { use self::TerminatorKind::*; diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index be39f95b98899..3aea0722d0e2f 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -112,7 +112,7 @@ pub struct Session { /// Map from imported macro spans (which consist of /// the localized span for the macro body) to the - /// macro name and defintion span in the source crate. + /// macro name and definition span in the source crate. pub imported_macro_spans: RefCell>, incr_comp_session: RefCell, @@ -828,7 +828,7 @@ pub fn compile_result_from_err_count(err_count: usize) -> CompileResult { #[inline(never)] pub fn bug_fmt(file: &'static str, line: u32, args: fmt::Arguments) -> ! { // this wrapper mostly exists so I don't have to write a fully - // qualified path of None:: inside the bug!() macro defintion + // qualified path of None:: inside the bug!() macro definition opt_span_bug_fmt(file, line, None::, args); } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f0fc6998c9e51..f23071de64744 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -111,8 +111,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } - // returns if `cond` not occuring implies that `error` does not occur - i.e. that - // `error` occuring implies that `cond` occurs. + // returns if `cond` not occurring implies that `error` does not occur - i.e. that + // `error` occurring implies that `cond` occurs. fn error_implies(&self, cond: &ty::Predicate<'tcx>, error: &ty::Predicate<'tcx>) diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 7cce9c398bb44..e70258007e463 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -1364,7 +1364,7 @@ impl<'tcx> ProjectionCache<'tcx> { } /// Try to start normalize `key`; returns an error if - /// normalization already occured (this error corresponds to a + /// normalization already occurred (this error corresponds to a /// cache hit, so it's actually a good thing). fn try_start(&mut self, key: ty::ProjectionTy<'tcx>) -> Result<(), ProjectionCacheEntry<'tcx>> { diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index 611137562a906..8b31cb599e45d 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -95,7 +95,7 @@ impl<'a, 'gcx, 'tcx> Children { } /// Attempt to insert an impl into this set of children, while comparing for - /// specialiation relationships. + /// specialization relationships. fn insert(&mut self, tcx: TyCtxt<'a, 'gcx, 'tcx>, impl_def_id: DefId, @@ -206,7 +206,7 @@ impl<'a, 'gcx, 'tcx> Graph { // if the reference itself contains an earlier error (e.g., due to a // resolution failure), then we just insert the impl at the top level of - // the graph and claim that there's no overlap (in order to supress + // the graph and claim that there's no overlap (in order to suppress // bogus errors). if trait_ref.references_error() { debug!("insert: inserting dummy node for erroneous TraitRef {:?}, \ diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 231600f95ac60..896682e2370e2 100644 --- a/src/librustc/ty/inhabitedness/def_id_forest.rs +++ b/src/librustc/ty/inhabitedness/def_id_forest.rs @@ -24,7 +24,7 @@ use ty::{DefId, DefIdTree}; #[derive(Clone)] pub struct DefIdForest { /// The minimal set of DefIds required to represent the whole set. - /// If A and B are DefIds in the DefIdForest, and A is a desecendant + /// If A and B are DefIds in the DefIdForest, and A is a descendant /// of B, then only B will be in root_ids. /// We use a SmallVec here because (for its use for cacheing inhabitedness) /// its rare that this will contain even two ids. @@ -61,7 +61,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest { self.root_ids.is_empty() } - /// Test whether the forest conains a given DefId. + /// Test whether the forest contains a given DefId. pub fn contains(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, id: DefId) -> bool diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 73b577e2e876b..76a20ed8f3023 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -125,7 +125,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// If possible, this pushes a global path resolving to `external_def_id` that is visible /// from at least one local module and returns true. If the crate defining `external_def_id` is - /// declared with an `extern crate`, the path is guarenteed to use the `extern crate`. + /// declared with an `extern crate`, the path is guaranteed to use the `extern crate`. pub fn try_push_visible_item_path(self, buffer: &mut T, external_def_id: DefId) -> bool where T: ItemPathBuffer { diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index b871b36c94850..a640da31eec25 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -587,7 +587,7 @@ macro_rules! define_maps { } // FIXME(eddyb) Get more valid Span's on queries. - // def_span guard is necesary to prevent a recursive loop, + // def_span guard is necessary to prevent a recursive loop, // default_span calls def_span query internally. if span == DUMMY_SP && stringify!($name) != "def_span" { span = key.default_span(tcx) diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 244b7f3596889..885be8464eb30 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -224,7 +224,7 @@ pub trait MemoizationMap { type Key: Clone; type Value: Clone; - /// If `key` is present in the map, return the valuee, + /// If `key` is present in the map, return the value, /// otherwise invoke `op` and store the value in the map. /// /// NB: if the receiver is a `DepTrackingMap`, special care is diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index e70b7f89a6767..c34bf4c3d284d 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -472,7 +472,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { if new_loan.span == old_loan.span { // Both borrows are happening in the same place - // Meaning the borrow is occuring in a loop + // Meaning the borrow is occurring in a loop err.span_label( new_loan.span, format!("mutable borrow starts here in previous \ diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index eb45fd9c0e0a4..a1581b1604123 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -106,7 +106,7 @@ impl<'a, 'tcx> ConstContext<'a, 'tcx> { } /// Evaluate a constant expression in a context where the expression isn't - /// guaranteed to be evaluatable. + /// guaranteed to be evaluable. pub fn eval(&self, e: &Expr) -> EvalResult<'tcx> { if self.tables.tainted_by_errors { signal!(e, TypeckError); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index c6d2d75e9377f..83bed33b1118c 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -974,7 +974,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, passes.push_pass(MIR_CONST, mir::transform::type_check::TypeckMir); passes.push_pass(MIR_CONST, mir::transform::rustc_peek::SanityCheck); - // We compute "constant qualifications" betwen MIR_CONST and MIR_VALIDATED. + // We compute "constant qualifications" between MIR_CONST and MIR_VALIDATED. // What we need to run borrowck etc. passes.push_pass(MIR_VALIDATED, mir::transform::qualify_consts::QualifyAndPromoteConstants); diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index a4a89a7f8185a..ce64f88d18e1f 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -113,7 +113,7 @@ pub struct Scope<'tcx> { /// for unwinding, for several reasons: /// * clang doesn't emit llvm.lifetime.end for C++ unwinding /// * LLVM's memory dependency analysis can't handle it atm - /// * pollutting the cleanup MIR with StorageDead creates + /// * polluting the cleanup MIR with StorageDead creates /// landing pads even though there's no actual destructors /// * freeing up stack space has no effect during unwinding needs_cleanup: bool, diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index d7ad9f9c09aef..7c0137b18c02e 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -333,11 +333,11 @@ pub trait BitDenotation { /// basic block) according to the effects of evaluating statement. /// /// This is used, in particular, for building up the - /// "transfer-function" represnting the overall-effect of the + /// "transfer-function" representing the overall-effect of the /// block, represented via GEN and KILL sets. /// /// The statement is identified as `bb_data[idx_stmt]`, where - /// `bb_data` is the sequence of statements identifed by `bb` in + /// `bb_data` is the sequence of statements identified by `bb` in /// the MIR. fn statement_effect(&self, sets: &mut BlockSets, @@ -349,7 +349,7 @@ pub trait BitDenotation { /// the terminator. /// /// This is used, in particular, for building up the - /// "transfer-function" represnting the overall-effect of the + /// "transfer-function" representing the overall-effect of the /// block, represented via GEN and KILL sets. /// /// The effects applied here cannot depend on which branch the diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index baf0522896c9c..89de847231c85 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! This pass erases all early-bound regions from the types occuring in the MIR. +//! This pass erases all early-bound regions from the types occurring in the MIR. //! We want to do this once just before trans, so trans does not have to take //! care erasing regions all over the place. //! NOTE: We do NOT erase regions of statements that are relevant for diff --git a/src/librustc_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs index 29fac5463e557..c6bc045f0de3b 100644 --- a/src/librustc_passes/hir_stats.rs +++ b/src/librustc_passes/hir_stats.rs @@ -125,6 +125,11 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> { self.visit_impl_item(nested_impl_item) } + fn visit_nested_body(&mut self, body_id: hir::BodyId) { + let nested_body = self.krate.unwrap().body(body_id); + self.visit_body(nested_body) + } + fn visit_item(&mut self, i: &'v hir::Item) { self.record("Item", Id::Node(i.id), i); hir_visit::walk_item(self, i) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index b4f9ba4e8f78f..da170e7fe22ca 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1621,7 +1621,7 @@ impl<'a> Resolver<'a> { return Some(module.parent.unwrap()); } - let mut module_expansion = module.expansion.modern(); // for backward compatability + let mut module_expansion = module.expansion.modern(); // for backward compatibility while let Some(parent) = module.parent { let parent_expansion = parent.expansion.modern(); if module_expansion.is_descendant_of(parent_expansion) && diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 30a698e635143..8dd191f4375ed 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -109,7 +109,7 @@ impl<'b, O: DumpOutput + 'b> JsonDumper { } if data.kind == DefKind::Mod && data.span.file_name.to_str().unwrap() != data.value { // If the module is an out-of-line defintion, then we'll make the - // defintion the first character in the module's file and turn the + // definition the first character in the module's file and turn the // the declaration into a reference to it. let rf = Ref { kind: RefKind::Mod, diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 3557b4752e7e4..6ef499694aa4f 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -387,7 +387,7 @@ impl Sig for ast::Item { sig.text.push('('); for i in &decl.inputs { - // FIXME shoudl descend into patterns to add defs. + // FIXME should descend into patterns to add defs. sig.text.push_str(&pprust::pat_to_string(&i.pat)); sig.text.push_str(": "); let nested = i.ty.make(offset + sig.text.len(), Some(i.id), scx)?; @@ -922,7 +922,7 @@ fn make_method_signature(id: NodeId, sig.text.push('('); for i in &m.decl.inputs { - // FIXME shoudl descend into patterns to add defs. + // FIXME should descend into patterns to add defs. sig.text.push_str(&pprust::pat_to_string(&i.pat)); sig.text.push_str(": "); let nested = i.ty.make(sig.text.len(), Some(i.id), scx)?; diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 63df33913ca73..b4a2891f94c2a 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -488,7 +488,7 @@ impl Lifetime { // on), and `ptr` is nonzero-sized, then extracts the size of `ptr` // and the intrinsic for `lt` and passes them to `emit`, which is in // charge of generating code to call the passed intrinsic on whatever - // block of generated code is targetted for the intrinsic. + // block of generated code is targeted for the intrinsic. // // If LLVM lifetime intrinsic support is disabled (i.e. optimizations // off) or `ptr` is zero-sized, then no-op (does not call `emit`). diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index 6e36073107b56..8cb2c2809f4f3 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -36,7 +36,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, qualified: bool, output: &mut String) { - // When targeting MSVC, emit C++ style type names for compatability with + // When targeting MSVC, emit C++ style type names for compatibility with // .natvis visualizers (and perhaps other existing native debuggers?) let cpp_like_names = cx.sess().target.target.options.is_like_msvc; diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index a7f12babb10f9..d0f7f27d5a81c 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { (scope, source_info.span) } else { // Walk up the macro expansion chain until we reach a non-expanded span. - // We also stop at the function body level because no line stepping can occurr + // We also stop at the function body level because no line stepping can occur // at the level above that. let mut span = source_info.span; while span.ctxt != NO_EXPANSION && span.ctxt != self.mir.span.ctxt { diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 7bb8a251354e2..fc241c023cdaf 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -67,7 +67,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Ok(InferOk { obligations, value: () }) => { self.register_predicates(obligations); None - }, + } Err(e) => { Some(self.report_mismatched_types(cause, expected, actual, e)) } @@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Checks that the type of `expr` can be coerced to `expected`. // - // NB: This code relies on `self.diverges` to be accurate. In + // NB: This code relies on `self.diverges` to be accurate. In // particular, assignments to `!` will be permitted if the // diverges flag is currently "always". pub fn demand_coerce_diag(&self, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 1ccb1e64a98e0..a1c987f22e053 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -219,7 +219,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// `lookup_method_in_trait` is used for overloaded operators. /// It does a very narrow slice of what the normal probe/confirm path does. /// In particular, it doesn't really do any probing: it simply constructs - /// an obligation for aparticular trait with the given self-type and checks + /// an obligation for a particular trait with the given self-type and checks /// whether that trait is implemented. /// /// FIXME(#18741) -- It seems likely that we can consolidate some of this diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 697d9de931a86..17611af5ac410 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -529,7 +529,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { /// `foo(return)`; we warn on the `foo()` expression. (We then /// update the flag to `WarnedAlways` to suppress duplicate /// reports.) Similarly, if we traverse to a fresh statement (or - /// tail expression) from a `Always` setting, we will isssue a + /// tail expression) from a `Always` setting, we will issue a /// warning. This corresponds to something like `{return; /// foo();}` or `{return; 22}`, where we would warn on the /// `foo()` or `22`. @@ -538,7 +538,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { /// (including the "return slot") of type `!`. This is allowed /// if **either** the type of value being assigned is `!`, which /// means the current code is dead, **or** the expression's - /// divering flag is true, which means that a divering value was + /// diverging flag is true, which means that a diverging value was /// wrapped (e.g., `let x: ! = foo(return)`). /// /// To repeat the last point: an expression represents dead-code @@ -1895,7 +1895,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { value.fold_with(&mut BottomUpFolder { tcx: self.tcx, fldop: |ty| { if let ty::TyAnon(def_id, substs) = ty.sty { // Use the same type variable if the exact same TyAnon appears more - // than once in the return type (e.g. if it's pased to a type alias). + // than once in the return type (e.g. if it's passed to a type alias). let id = self.tcx.hir.as_local_node_id(def_id).unwrap(); if let Some(ty_var) = self.anon_types.borrow().get(&id) { return ty_var; @@ -4244,7 +4244,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } /// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether a - /// suggetion can be made, `None` otherwise. + /// suggestion can be made, `None` otherwise. pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> { // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or // `while` before reaching it, as block tail returns are not available in them. @@ -4312,7 +4312,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// ``` /// /// This routine checks if the return expression in a block would make sense on its own as a - /// statement and the return type has been left as defaultor has been specified as `()`. If so, + /// statement and the return type has been left as default or has been specified as `()`. If so, /// it suggests adding a semicolon. fn suggest_missing_semicolon(&self, err: &mut DiagnosticBuilder<'tcx>, diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index cf5882bb9bdbd..31e14a6b630d2 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -255,7 +255,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { // We want to ensure: // // 1) that there are no items contained within - // the trait defintion + // the trait definition // // 2) that the definition doesn't violate the no-super trait rule // for auto traits. diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 735c9d8af7a8a..82c252ae4d726 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -190,8 +190,8 @@ impl<'a, I: Iterator>> Iterator for CodeBlocks<'a, I> { .map(|l| map_line(l).for_code()) .collect::>().join("\n"); let krate = krate.as_ref().map(|s| &**s); - let test = test::maketest(&test, krate, false, - &Default::default()); + let test = test::make_test(&test, krate, false, + &Default::default()); let channel = if test.contains("#![feature(") { "&version=nightly" } else { @@ -584,8 +584,8 @@ pub fn render(w: &mut fmt::Formatter, .map(|l| map_line(l).for_code()) .collect::>().join("\n"); let krate = krate.as_ref().map(|s| &**s); - let test = test::maketest(&test, krate, false, - &Default::default()); + let test = test::make_test(&test, krate, false, + &Default::default()); let channel = if test.contains("#![feature(") { "&version=nightly" } else { diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index fff047c99c034..b1fb343b8bb9c 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -174,16 +174,16 @@ fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions { opts } -fn runtest(test: &str, cratename: &str, cfgs: Vec, libs: SearchPaths, - externs: Externs, - should_panic: bool, no_run: bool, as_test_harness: bool, - compile_fail: bool, mut error_codes: Vec, opts: &TestOptions, - maybe_sysroot: Option) { +fn run_test(test: &str, cratename: &str, filename: &str, cfgs: Vec, libs: SearchPaths, + externs: Externs, + should_panic: bool, no_run: bool, as_test_harness: bool, + compile_fail: bool, mut error_codes: Vec, opts: &TestOptions, + maybe_sysroot: Option) { // the test harness wants its own `main` & top level functions, so // never wrap the test in `fn main() { ... }` - let test = maketest(test, Some(cratename), as_test_harness, opts); + let test = make_test(test, Some(cratename), as_test_harness, opts); let input = config::Input::Str { - name: driver::anon_src(), + name: filename.to_owned(), input: test.to_owned(), }; let outputs = OutputTypes::new(&[(OutputType::Exe, None)]); @@ -320,8 +320,11 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec, libs: SearchPaths, } } -pub fn maketest(s: &str, cratename: Option<&str>, dont_insert_main: bool, - opts: &TestOptions) -> String { +pub fn make_test(s: &str, + cratename: Option<&str>, + dont_insert_main: bool, + opts: &TestOptions) + -> String { let (crate_attrs, everything_else) = partition_source(s); let mut prog = String::new(); @@ -505,18 +508,19 @@ impl Collector { rustc_driver::in_rustc_thread(move || { io::set_panic(panic); io::set_print(print); - runtest(&test, - &cratename, - cfgs, - libs, - externs, - should_panic, - no_run, - as_test_harness, - compile_fail, - error_codes, - &opts, - maybe_sysroot) + run_test(&test, + &cratename, + &filename, + cfgs, + libs, + externs, + should_panic, + no_run, + as_test_harness, + compile_fail, + error_codes, + &opts, + maybe_sysroot) }) } { Ok(()) => (), diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 062186ef70866..1e692abaff2f9 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -657,7 +657,7 @@ impl OpenOptions { /// This function will return an error under a number of different /// circumstances. Some of these error conditions are listed here, together /// with their [`ErrorKind`]. The mapping to [`ErrorKind`]s is not part of - /// the compatiblity contract of the function, especially the `Other` kind + /// the compatibility contract of the function, especially the `Other` kind /// might change to more specific kinds in the future. /// /// * [`NotFound`]: The specified file does not exist and neither `create` diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 5e88a46ecc343..c426bf8086eef 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -461,9 +461,26 @@ pub mod builtin { /// /// # Examples /// + /// Assume there are two files in the same directory with the following + /// contents: + /// + /// File 'spanish.in': + /// + /// ```text + /// adiós + /// ``` + /// + /// File 'main.rs': + /// /// ```ignore (cannot-doctest-external-file-dependency) - /// let secret_key = include_str!("secret-key.ascii"); + /// fn main() { + /// let my_str = include_str!("spanish.in"); + /// assert_eq!(my_str, "adiós\n"); + /// print!("{}", my_str); + /// } /// ``` + /// + /// Compiling 'main.rs' and running the resulting binary will print "adiós". #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) } @@ -478,9 +495,26 @@ pub mod builtin { /// /// # Examples /// + /// Assume there are two files in the same directory with the following + /// contents: + /// + /// File 'spanish.in': + /// + /// ```text + /// adiós + /// ``` + /// + /// File 'main.rs': + /// /// ```ignore (cannot-doctest-external-file-dependency) - /// let secret_key = include_bytes!("secret-key.bin"); + /// fn main() { + /// let bytes = include_bytes!("spanish.in"); + /// assert_eq!(bytes, b"adi\xc3\xb3s\n"); + /// print!("{}", String::from_utf8_lossy(bytes)); + /// } /// ``` + /// + /// Compiling 'main.rs' and running the resulting binary will print "adiós". #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) } @@ -545,23 +579,28 @@ pub mod builtin { /// Assume there are two files in the same directory with the following /// contents: /// - /// File 'my_str.in': + /// File 'monkeys.in': /// /// ```ignore (only-for-syntax-highlight) - /// "Hello World!" + /// ['🙈', '🙊', '🙉'] + /// .iter() + /// .cycle() + /// .take(6) + /// .collect::() /// ``` /// /// File 'main.rs': /// /// ```ignore (cannot-doctest-external-file-dependency) /// fn main() { - /// let my_str = include!("my_str.in"); - /// println!("{}", my_str); + /// let my_string = include!("monkeys.in"); + /// assert_eq!("🙈🙊🙉🙈🙊🙉", my_string); + /// println!("{}", my_string); /// } /// ``` /// - /// Compiling 'main.rs' and running the resulting binary will print "Hello - /// World!". + /// Compiling 'main.rs' and running the resulting binary will print + /// "🙈🙊🙉🙈🙊🙉". #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) } diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index fdeca8bc5cac3..2eabb46441b32 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -147,7 +147,7 @@ impl TcpStream { /// connection request. /// /// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html - #[unstable(feature = "tcpstream_connect_timeout", issue = "43709")] + #[unstable(feature = "tcpstream_connect_timeout", issue = "43079")] pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result { net_imp::TcpStream::connect_timeout(addr, timeout).map(TcpStream) } @@ -351,7 +351,7 @@ impl TcpStream { self.0.write_timeout() } - /// Receives data on the socket from the remote adress to which it is + /// Receives data on the socket from the remote address to which it is /// connected, without removing that data from the queue. On success, /// returns the number of bytes peeked. /// diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 80151dc2b4455..9aff989788536 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -622,7 +622,7 @@ impl UdpSocket { self.0.recv(buf) } - /// Receives data on the socket from the remote adress to which it is + /// Receives data on the socket from the remote address to which it is /// connected, without removing that data from the queue. On success, /// returns the number of bytes peeked. /// diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 10b3209257efe..97b09b7e2ad99 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -37,7 +37,7 @@ pub use panicking::{take_hook, set_hook, PanicInfo, Location}; /// In Rust a function can "return" early if it either panics or calls a /// function which transitively panics. This sort of control flow is not always /// anticipated, and has the possibility of causing subtle bugs through a -/// combination of two criticial components: +/// combination of two critical components: /// /// 1. A data structure is in a temporarily invalid state when the thread /// panics. diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 04e1a579decd4..99567bd08bbf4 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -171,7 +171,7 @@ pub fn take_hook() -> Box { /// use std::panic; /// /// panic::set_hook(Box::new(|panic_info| { -/// println!("panic occured: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); +/// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); /// })); /// /// panic!("Normal panic"); @@ -196,7 +196,7 @@ impl<'a> PanicInfo<'a> { /// use std::panic; /// /// panic::set_hook(Box::new(|panic_info| { - /// println!("panic occured: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); + /// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); /// })); /// /// panic!("Normal panic"); @@ -221,9 +221,10 @@ impl<'a> PanicInfo<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured in file '{}' at line {}", location.file(), location.line()); + /// println!("panic occurred in file '{}' at line {}", location.file(), + /// location.line()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -249,9 +250,9 @@ impl<'a> PanicInfo<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { -/// println!("panic occured in file '{}' at line {}", location.file(), location.line()); +/// println!("panic occurred in file '{}' at line {}", location.file(), location.line()); /// } else { -/// println!("panic occured but can't get location information..."); +/// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -275,9 +276,9 @@ impl<'a> Location<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured in file '{}'", location.file()); + /// println!("panic occurred in file '{}'", location.file()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -297,9 +298,9 @@ impl<'a> Location<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured at line {}", location.line()); + /// println!("panic occurred at line {}", location.line()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -320,9 +321,9 @@ impl<'a> Location<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured at column {}", location.column()); + /// println!("panic occurred at column {}", location.column()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 7be319d1954ec..c52899db43733 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -906,7 +906,7 @@ mod prim_ref { } /// These markers can be combined, so `unsafe extern "stdcall" fn()` is a valid type. /// /// Like references in rust, function pointers are assumed to not be null, so if you want to pass a -/// function pointer over FFI and be able to accomodate null pointers, make your type +/// function pointer over FFI and be able to accommodate null pointers, make your type /// `Option` with your required signature. /// /// Function pointers implement the following traits: diff --git a/src/libstd/sys/redox/ext/fs.rs b/src/libstd/sys/redox/ext/fs.rs index 9a0d1e06da327..5d4edc2cf92c2 100644 --- a/src/libstd/sys/redox/ext/fs.rs +++ b/src/libstd/sys/redox/ext/fs.rs @@ -121,7 +121,7 @@ pub trait OpenOptionsExt { #[stable(feature = "fs_ext", since = "1.1.0")] fn mode(&mut self, mode: u32) -> &mut Self; - /// Pass custom flags to the `flags` agument of `open`. + /// Pass custom flags to the `flags` argument of `open`. /// /// The bits that define the access mode are masked out with `O_ACCMODE`, to /// ensure they do not interfere with the access mode set by Rusts options. diff --git a/src/libstd/sys/redox/ext/process.rs b/src/libstd/sys/redox/ext/process.rs index c59524974bf2f..e68e180acf1c4 100644 --- a/src/libstd/sys/redox/ext/process.rs +++ b/src/libstd/sys/redox/ext/process.rs @@ -47,7 +47,7 @@ pub trait CommandExt { /// # Notes /// /// This closure will be run in the context of the child process after a - /// `fork`. This primarily means that any modificatons made to memory on + /// `fork`. This primarily means that any modifications made to memory on /// behalf of this closure will **not** be visible to the parent process. /// This is often a very constrained environment where normal operations /// like `malloc` or acquiring a mutex are not guaranteed to work (due to diff --git a/src/libstd/sys/redox/net/dns/mod.rs b/src/libstd/sys/redox/net/dns/mod.rs index 43c4fe7ac9d96..49cde89dc0544 100644 --- a/src/libstd/sys/redox/net/dns/mod.rs +++ b/src/libstd/sys/redox/net/dns/mod.rs @@ -102,6 +102,7 @@ impl Dns { } pub fn parse(data: &[u8]) -> Result { + let name_ind = 0b11000000; let mut i = 0; macro_rules! pop_u8 { @@ -147,9 +148,15 @@ impl Dns { () => { { let mut name = String::new(); + let old_i = i; loop { let name_len = pop_u8!(); + if name_len & name_ind == name_ind { + i -= 1; + i = (pop_n16!() - ((name_ind as u16) << 8)) as usize; + continue; + } if name_len == 0 { break; } @@ -161,6 +168,10 @@ impl Dns { } } + if i <= old_i { + i = old_i + 2; + } + name } }; @@ -184,21 +195,8 @@ impl Dns { let mut answers = Vec::new(); for _answer_i in 0..answers_len { - let name_ind = 0b11000000; - let name_test = pop_u8!(); - i -= 1; - answers.push(DnsAnswer { - name: if name_test & name_ind == name_ind { - let name_off = pop_n16!() - ((name_ind as u16) << 8); - let old_i = i; - i = name_off as usize; - let name = pop_name!(); - i = old_i; - name - } else { - pop_name!() - }, + name: pop_name!(), a_type: pop_n16!(), a_class: pop_n16!(), ttl_a: pop_n16!(), diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index 26710bf61d510..a94585723a1ee 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -46,7 +46,7 @@ pub trait FileExt { /// /// The current file cursor is not affected by this function. /// - /// When writing beyond the end of the file, the file is appropiately + /// When writing beyond the end of the file, the file is appropriately /// extended and the intermediate bytes are initialized with the value 0. /// /// Note that similar to `File::write`, it is not an error to return a @@ -168,7 +168,7 @@ pub trait OpenOptionsExt { #[stable(feature = "fs_ext", since = "1.1.0")] fn mode(&mut self, mode: u32) -> &mut Self; - /// Pass custom flags to the `flags` agument of `open`. + /// Pass custom flags to the `flags` argument of `open`. /// /// The bits that define the access mode are masked out with `O_ACCMODE`, to /// ensure they do not interfere with the access mode set by Rusts options. diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 698944ea0ba4b..278534271281f 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -338,7 +338,7 @@ impl UnixStream { /// /// The returned `UnixStream` is a reference to the same stream that this /// object references. Both handles will read and write the same stream of - /// data, and options set on one stream will be propogated to the other + /// data, and options set on one stream will be propagated to the other /// stream. /// /// # Examples diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index 2961c4ec58245..cde21b089a20d 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -47,7 +47,7 @@ pub trait CommandExt { /// # Notes /// /// This closure will be run in the context of the child process after a - /// `fork`. This primarily means that any modificatons made to memory on + /// `fork`. This primarily means that any modifications made to memory on /// behalf of this closure will **not** be visible to the parent process. /// This is often a very constrained environment where normal operations /// like `malloc` or acquiring a mutex are not guaranteed to work (due to diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index a1c63e3358840..d58a3505154dd 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -66,7 +66,7 @@ pub trait FileExt { /// from the current cursor. The current cursor **is** affected by this /// function, it is set to the end of the write. /// - /// When writing beyond the end of the file, the file is appropiately + /// When writing beyond the end of the file, the file is appropriately /// extended and the intermediate bytes are left uninitialized. /// /// Note that similar to `File::write`, it is not an error to return a diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 857d9a753cc4e..38ef79822c7b5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -563,8 +563,8 @@ pub enum PatKind { TupleStruct(Path, Vec>, Option), /// A possibly qualified path pattern. - /// Unquailfied path patterns `A::B::C` can legally refer to variants, structs, constants - /// or associated constants. Quailfied path patterns `::B::C`/`::B::C` can + /// Unqualified path patterns `A::B::C` can legally refer to variants, structs, constants + /// or associated constants. Qualified path patterns `::B::C`/`::B::C` can /// only legally refer to associated constants. Path(Option, Path), @@ -1838,7 +1838,7 @@ pub struct Item { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum ItemKind { - /// An`extern crate` item, with optional original crate name. + /// An `extern crate` item, with optional original crate name. /// /// E.g. `extern crate foo` or `extern crate foo_bar as foo` ExternCrate(Option), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index bfdcae7641dd5..6c48b4cadd84f 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -761,7 +761,7 @@ mod tests { } /// Given a string like " ~~~~~~~~~~~~ ", produces a span - /// coverting that range. The idea is that the string has the same + /// converting that range. The idea is that the string has the same /// length as the input, and we uncover the byte positions. Note /// that this can span lines and so on. fn span_from_selection(input: &str, selection: &str) -> Span { @@ -771,7 +771,7 @@ mod tests { Span { lo: BytePos(left_index), hi: BytePos(right_index + 1), ctxt: NO_EXPANSION } } - /// Test span_to_snippet and span_to_lines for a span coverting 3 + /// Test span_to_snippet and span_to_lines for a span converting 3 /// lines in the middle of a file. #[test] fn span_to_snippet_and_lines_spanning_multiple_lines() { diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index b293aa8de38b2..95fe41be12254 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -193,13 +193,14 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Toke // resolve a file-system path to an absolute file-system path (if it // isn't already) fn res_rel_file(cx: &mut ExtCtxt, sp: syntax_pos::Span, arg: &Path) -> PathBuf { - // NB: relative paths are resolved relative to the compilation unit + // Relative paths are resolved relative to the file in which they are found + // after macro expansion (that is, they are unhygienic). if !arg.is_absolute() { let callsite = sp.source_callsite(); - let mut cu = PathBuf::from(&cx.codemap().span_to_filename(callsite)); - cu.pop(); - cu.push(arg); - cu + let mut path = PathBuf::from(&cx.codemap().span_to_filename(callsite)); + path.pop(); + path.push(arg); + path } else { arg.to_path_buf() } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7bf4c6799b3cb..15f05df58b507 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3587,7 +3587,7 @@ impl<'a> Parser<'a> { /// Parse a local variable declaration fn parse_local(&mut self, attrs: ThinVec) -> PResult<'a, P> { - let lo = self.span; + let lo = self.prev_span; let pat = self.parse_pat()?; let ty = if self.eat(&token::Colon) { diff --git a/src/test/rustdoc/issue-43153.rs b/src/test/rustdoc/issue-43153.rs new file mode 100644 index 0000000000000..6ac341d8b0224 --- /dev/null +++ b/src/test/rustdoc/issue-43153.rs @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Test that `include!` in a doc test searches relative to the directory in +// which the test is declared. + +// compile-flags:--test + +/// ```rust +/// include!("auxiliary/empty.rs"); +/// fn main() {} +/// ``` +pub struct Foo;