diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-08-17 13:23:20 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-08-17 13:23:20 -0700 |
| commit | 4b5f330c706e115ce75667a650e7c15c429d3a20 (patch) | |
| tree | 80bedaa7a3cfc5a41827c96717ef73d25bb297f6 /src | |
| parent | 63477fdeceead5683dfa197c5450ffe1bee3ab04 (diff) | |
| parent | 59ccba995de202fb9d9a8d795d2770fb2d199db0 (diff) | |
| download | rust-4b5f330c706e115ce75667a650e7c15c429d3a20.tar.gz rust-4b5f330c706e115ce75667a650e7c15c429d3a20.zip | |
Merge remote-tracking branch 'origin/master' into gen
Diffstat (limited to 'src')
89 files changed, 284 insertions, 168 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index cf6ebb48b2c..e325fc65f05 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -257,7 +257,7 @@ impl<'a> Builder<'a> { Kind::Bench => describe!(check::Crate, check::CrateLibrustc), Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon, - doc::Reference, doc::Rustdoc), + doc::Reference, doc::Rustdoc, doc::CargoBook), Kind::Dist => describe!(dist::Docs, dist::Mingw, dist::Rustc, dist::DebuggerScripts, dist::Std, dist::Analysis, dist::Src, dist::PlainSourceTarball, dist::Cargo, dist::Rls, dist::Extended, dist::HashSign), diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 5ade2c279e2..86f5346bea1 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -240,6 +240,51 @@ impl Step for TheBook { } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct CargoBook { + target: Interned<String>, +} + +impl Step for CargoBook { + type Output = (); + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + let builder = run.builder; + run.path("src/doc/cargo").default_condition(builder.build.config.docs) + } + + fn make_run(run: RunConfig) { + run.builder.ensure(CargoBook { + target: run.target, + }); + } + + /// Create a placeholder for the cargo documentation so that doc.rust-lang.org/cargo will + /// redirect to doc.crates.io. We want to publish doc.rust-lang.org/cargo in the paper + /// version of the book, but we don't want to rush the process of switching cargo's docs + /// over to mdbook and deploying them. When the cargo book is ready, this implementation + /// should build the mdbook instead of this redirect page. + fn run(self, builder: &Builder) { + let build = builder.build; + let out = build.doc_out(self.target); + + let cargo_dir = out.join("cargo"); + t!(fs::create_dir_all(&cargo_dir)); + + let index = cargo_dir.join("index.html"); + let redirect_html = r#" + <html> + <head> + <meta http-equiv="refresh" content="0; URL='http://doc.crates.io'" /> + </head> + </html>"#; + + println!("Creating cargo book redirect page"); + t!(t!(File::create(&index)).write_all(redirect_html.as_bytes())); + } +} + fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned<String>, markdown: &str) { let build = builder.build; let out = build.doc_out(target); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 17f8bcdf03d..b6e00981576 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -444,7 +444,7 @@ impl Build { } /// Returns the root output directory for all Cargo output in a given stage, - /// running a particular compiler, wehther or not we're building the + /// running a particular compiler, whether or not we're building the /// standard library, and targeting the specified architecture. fn cargo_out(&self, compiler: Compiler, diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 59efbd5c4d2..0a307e72bf6 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -11,7 +11,7 @@ //! Compilation of native dependencies like LLVM. //! //! Native projects like LLVM unfortunately aren't suited just yet for -//! compilation in build scripts that Cargo has. This is because thie +//! compilation in build scripts that Cargo has. This is because the //! compilation takes a *very* long time but also because we don't want to //! compile LLVM 3 times as part of a normal bootstrap (we want it cached). //! diff --git a/src/doc/book b/src/doc/book -Subproject 6f1a03dae6bcea44976918186f2d554186b3499 +Subproject d09c9e8144ed32170b7596abb145ade8b097aca diff --git a/src/doc/nomicon b/src/doc/nomicon -Subproject f570bcb681771d691aa4fdb8dfcfad1939844bf +Subproject a4322ccb289a43cc238d4536982f184a3eec9ba diff --git a/src/doc/reference b/src/doc/reference -Subproject 1abfbaa70313fdf527cf799ffd9b9a096a62105 +Subproject 266d429a48468371d2d90669f6a30dd659bb4bd diff --git a/src/doc/unstable-book/src/language-features/rvalue-static-promotion.md b/src/doc/unstable-book/src/language-features/rvalue-static-promotion.md deleted file mode 100644 index 2583d350ebe..00000000000 --- a/src/doc/unstable-book/src/language-features/rvalue-static-promotion.md +++ /dev/null @@ -1,23 +0,0 @@ -# `rvalue_static_promotion` - -The tracking issue for this feature is: [#38865] - -[#38865]: https://github.com/rust-lang/rust/issues/38865 - ------------------------- - -The `rvalue_static_promotion` feature allows directly creating `'static` references to -constant `rvalue`s, which in particular allowing for more concise code in the common case -in which a `'static` reference is all that's needed. - - -## Examples - -```rust -#![feature(rvalue_static_promotion)] - -fn main() { - let DEFAULT_VALUE: &'static u32 = &42; - assert_eq!(*DEFAULT_VALUE, 42); -} -``` diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 2b3df15f716..fc6585a9f95 100644 --- a/src/liballoc/allocator.rs +++ b/src/liballoc/allocator.rs @@ -293,7 +293,7 @@ impl Layout { /// Creates a layout describing the record for `self` followed by /// `next` with no additional padding between the two. Since no /// padding is inserted, the alignment of `next` is irrelevant, - /// and is not incoporated *at all* into the resulting layout. + /// and is not incorporated *at all* into the resulting layout. /// /// Returns `(k, offset)`, where `k` is layout of the concatenated /// record and `offset` is the relative location, in bytes, of the @@ -528,7 +528,7 @@ pub unsafe trait Alloc { /// to allocate that block of memory. unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout); - /// Allocator-specific method for signalling an out-of-memory + /// Allocator-specific method for signaling an out-of-memory /// condition. /// /// `oom` aborts the thread or process, optionally performing @@ -539,7 +539,7 @@ pub unsafe trait Alloc { /// unsatisfied allocation request (signaled by an error such as /// `AllocErr::Exhausted`), and wish to abandon computation rather /// than attempt to recover locally. Such clients should pass the - /// signalling error value back into `oom`, where the allocator + /// signaling error value back into `oom`, where the allocator /// may incorporate that error value into its diagnostic report /// before aborting. /// diff --git a/src/liballoc/btree/node.rs b/src/liballoc/btree/node.rs index b057c18fca8..c1618043ce6 100644 --- a/src/liballoc/btree/node.rs +++ b/src/liballoc/btree/node.rs @@ -763,7 +763,7 @@ impl<Node: Copy, Type> Clone for Handle<Node, Type> { } impl<Node, Type> Handle<Node, Type> { - /// Retrieves the node that contains the edge of key/value pair this handle pointes to. + /// Retrieves the node that contains the edge of key/value pair this handle points to. pub fn into_node(self) -> Node { self.node } diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 9a8614895f3..841f9dc6414 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -544,12 +544,12 @@ impl<T, A: Alloc> RawVec<T, A> { /// Attempts to ensure that the buffer contains at least enough space to hold /// `used_cap + needed_extra_cap` elements. If it doesn't already have /// enough capacity, will reallocate in place enough space plus comfortable slack - /// space to get amortized `O(1)` behaviour. Will limit this behaviour + /// space to get amortized `O(1)` behavior. Will limit this behaviour /// if it would needlessly cause itself to panic. /// /// If `used_cap` exceeds `self.cap()`, this may fail to actually allocate /// the requested space. This is not really unsafe, but the unsafe - /// code *you* write that relies on the behaviour of this function may break. + /// code *you* write that relies on the behavior of this function may break. /// /// Returns true if the reallocation attempt has succeeded, or false otherwise. /// diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 6068f1a7961..dc0905e2972 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -809,7 +809,7 @@ impl<T: ?Sized> RefCell<T> { /// [`borrow_mut`] method instead if `self` isn't mutable. /// /// Also, please be aware that this method is only for special circumstances and is usually - /// not you want. In case of doubt, use [`borrow_mut`] instead. + /// not what you want. In case of doubt, use [`borrow_mut`] instead. /// /// [`borrow_mut`]: #method.borrow_mut /// diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 2000ba91460..a8b84203d6a 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -240,7 +240,12 @@ pub trait Hash { /// [`write_u8`]: #method.write_u8 #[stable(feature = "rust1", since = "1.0.0")] pub trait Hasher { - /// Completes a round of hashing, producing the output hash generated. + /// Returns the hash value for the values written so far. + /// + /// Despite its name, the method does not reset the hasher’s internal + /// state. Additional [`write`]s will continue from the current value. + /// If you need to start a fresh hash value, you will have to create + /// a new hasher. /// /// # Examples /// @@ -253,6 +258,8 @@ pub trait Hasher { /// /// println!("Hash is {:x}!", hasher.finish()); /// ``` + /// + /// ['write']: #tymethod.write #[stable(feature = "rust1", since = "1.0.0")] fn finish(&self) -> u64; diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs index 2a60292d023..12960fed045 100644 --- a/src/libcore/num/dec2flt/rawfp.rs +++ b/src/libcore/num/dec2flt/rawfp.rs @@ -102,10 +102,10 @@ pub trait RawFloat : Float + Copy + Debug + LowerExp /// The number of bits in the exponent. const EXP_BITS: u8; - /// The number of bits in the singificand, *including* the hidden bit. + /// The number of bits in the significand, *including* the hidden bit. const SIG_BITS: u8; - /// The number of bits in the singificand, *excluding* the hidden bit. + /// The number of bits in the significand, *excluding* the hidden bit. const EXPLICIT_SIG_BITS: u8; /// The maximum legal exponent in fractional representation. @@ -123,7 +123,7 @@ pub trait RawFloat : Float + Copy + Debug + LowerExp /// `MIN_EXP` for integral representation, i.e., with the shift applied. const MIN_EXP_INT: i16; - /// The maximum normalized singificand in integral representation. + /// The maximum normalized significand in integral representation. const MAX_SIG: u64; /// The minimal normalized significand in integral representation. diff --git a/src/libcore/ops/try.rs b/src/libcore/ops/try.rs index 4971e825a6f..78326c3e639 100644 --- a/src/libcore/ops/try.rs +++ b/src/libcore/ops/try.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/// A trait for customizing the behaviour of the `?` operator. +/// A trait for customizing the behavior of the `?` operator. /// /// A type implementing `Try` is one that has a canonical way to view it /// in terms of a success/failure dichotomy. This trait allows both diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index d647a94a1ef..510e01db0e9 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -1632,7 +1632,7 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T { /// /// pub fn lock(&self) { /// while !self.flag.compare_and_swap(false, true, Ordering::Relaxed) {} -/// // This fence syncronizes-with store in `unlock`. +/// // This fence synchronizes-with store in `unlock`. /// fence(Ordering::Acquire); /// } /// diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index d66fba18f47..4ee0c3d92bd 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -11,7 +11,7 @@ //! Generate files suitable for use with [Graphviz](http://www.graphviz.org/) //! //! The `render` function generates output (e.g. an `output.dot` file) for -//! use with [Graphviz](http://www.graphviz.org/) by walking a labelled +//! use with [Graphviz](http://www.graphviz.org/) by walking a labeled //! graph. (Graphviz can then automatically lay out the nodes and edges //! of the graph, and also optionally render the graph as an image or //! other [output formats]( @@ -150,7 +150,7 @@ //! //! The output from this example renders four nodes that make up the //! Hasse-diagram for the subsets of the set `{x, y}`. Each edge is -//! labelled with the ⊆ character (specified using the HTML character +//! labeled with the ⊆ character (specified using the HTML character //! entity `&sube`). //! //! ```rust @@ -789,7 +789,7 @@ mod tests { } struct LabelledGraph { - /// The name for this graph. Used for labelling generated `digraph`. + /// The name for this graph. Used for labeling generated `digraph`. name: &'static str, /// Each node is an index into `node_labels`; these labels are diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs index 188e71f3fa9..e796197ab5b 100644 --- a/src/librand/distributions/gamma.rs +++ b/src/librand/distributions/gamma.rs @@ -254,7 +254,7 @@ impl IndependentSample<f64> for ChiSquared { /// The Fisher F distribution `F(m, n)`. /// -/// This distribution is equivalent to the ratio of two normalised +/// This distribution is equivalent to the ratio of two normalized /// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) / /// (χ²(n)/n)`. pub struct FisherF { diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 2baa07e370e..96ce0905e38 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -76,7 +76,7 @@ impl IsaacRng { rng } - /// Initialises `self`. If `use_rsl` is true, then use the current value + /// Initializes `self`. If `use_rsl` is true, then use the current value /// of `rsl` as a seed, otherwise construct one algorithmically (not /// randomly). fn init(&mut self, use_rsl: bool) { @@ -367,7 +367,7 @@ impl Isaac64Rng { rng } - /// Initialises `self`. If `use_rsl` is true, then use the current value + /// Initializes `self`. If `use_rsl` is true, then use the current value /// of `rsl` as a seed, otherwise construct one algorithmically (not /// randomly). fn init(&mut self, use_rsl: bool) { diff --git a/src/librand/lib.rs b/src/librand/lib.rs index a1b6ddcb331..a3c4f6a4b1d 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -180,7 +180,7 @@ pub trait Rng: Sized { /// This method does *not* have a requirement to bear any fixed /// relationship to the other methods, for example, it does *not* /// have to result in the same output as progressively filling - /// `dest` with `self.gen::<u8>()`, and any such behaviour should + /// `dest` with `self.gen::<u8>()`, and any such behavior should /// not be relied upon. /// /// This method should guarantee that `dest` is entirely filled diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index 804fe9dc63c..2821b7a8232 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -24,7 +24,7 @@ pub struct ReseedingRng<R, Rsdr> { rng: R, generation_threshold: usize, bytes_generated: usize, - /// Controls the behaviour when reseeding the RNG. + /// Controls the behavior when reseeding the RNG. pub reseeder: Rsdr, } diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 480e6ee1bc5..deeeb802e1f 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -362,6 +362,10 @@ Here are some simple examples of where you'll run into this error: struct Foo { x: &bool } // error struct Foo<'a> { x: &'a bool } // correct +struct Bar { x: Foo } + ^^^ expected lifetime parameter +struct Bar<'a> { x: Foo<'a> } // correct + enum Bar { A(u8), B(&bool), } // error enum Bar<'a> { A(u8), B(&'a bool), } // correct diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 072da14cdeb..e50ba5b1389 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -733,7 +733,7 @@ impl<'hir> Map<'hir> { /// Returns the nearest enclosing scope. A scope is an item or block. /// FIXME it is not clear to me that all items qualify as scopes - statics - /// and associated types probably shouldn't, for example. Behaviour in this + /// and associated types probably shouldn't, for example. Behavior in this /// regard should be expected to be highly unstable. pub fn get_enclosing_scope(&self, id: NodeId) -> Option<NodeId> { match self.walk_parent_nodes(id, |node| match *node { diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index b5390da7e85..d608d09d054 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -24,7 +24,7 @@ //! a span, but also more information so that we can generate a meaningful //! error message. //! -//! Having a catalogue of all the different reasons an error can arise is +//! Having a catalog of all the different reasons an error can arise is //! also useful for other reasons, like cross-referencing FAQs etc, though //! we are not really taking advantage of this yet. //! diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index 6a1f8f1d069..639a330dc6e 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -46,7 +46,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeResolver<'a, 'g } /// The opportunistic type and region resolver is similar to the -/// opportunistic type resolver, but also opportunistly resolves +/// opportunistic type resolver, but also opportunistically resolves /// regions. It is useful for canonicalization. pub struct OpportunisticTypeAndRegionResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 40d78d0138b..92b159a55f4 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -101,7 +101,7 @@ pub struct FutureIncompatibleInfo { pub reference: &'static str // e.g., a URL for an issue/PR/RFC or error code } -/// The targed of the `by_name` map, which accounts for renaming/deprecation. +/// The target of the `by_name` map, which accounts for renaming/deprecation. enum TargetLint { /// A direct lint target Id(LintId), diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 00ad0678e0d..4400bfc2550 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -879,10 +879,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { let promotable = self.tcx.rvalue_promotable_to_static.borrow().get(&id).cloned() .unwrap_or(false); - // When the corresponding feature isn't toggled, only promote `[T; 0]`. + // Always promote `[T; 0]` (even when e.g. borrowed mutably). let promotable = match expr_ty.sty { ty::TyArray(_, 0) => true, - _ => promotable && self.tcx.sess.features.borrow().rvalue_static_promotion, + _ => promotable, }; // Compute maximum lifetime of this rvalue. This is 'static if diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 9d28e2f496d..6374eb3ff90 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -74,7 +74,7 @@ use mir::transform::MirSource; /// (M1.): Misc extent of the whole `let a = ...;` statement. /// (M2.): Misc extent of the `f()` expression. /// (M3.): Misc extent of the `f().g(..)` expression. -/// (M4.): Misc extent of the block labelled `'b:`. +/// (M4.): Misc extent of the block labeled `'b:`. /// (M5.): Misc extent of the `let x = d();` statement /// (D6.): DestructionScope for temporaries created during M5. /// (R7.): Remainder extent for block `'b:`, stmt 0 (let x = ...). diff --git a/src/librustc/mir/traversal.rs b/src/librustc/mir/traversal.rs index 5aab46b3cef..74c3408c4c2 100644 --- a/src/librustc/mir/traversal.rs +++ b/src/librustc/mir/traversal.rs @@ -216,7 +216,7 @@ impl<'a, 'tcx> Iterator for Postorder<'a, 'tcx> { /// /// Reverse postorder is the reverse order of a postorder traversal. /// This is different to a preorder traversal and represents a natural -/// linearisation of control-flow. +/// linearization of control-flow. /// /// ```text /// diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 4f1eb616920..78e47693caa 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -37,7 +37,7 @@ impl<'tcx> ForestObligation for PendingPredicateObligation<'tcx> { /// consists of a list of obligations that must be (eventually) /// satisfied. The job is to track which are satisfied, which yielded /// errors, and which are still pending. At any point, users can call -/// `select_where_possible`, and the fulfilment context will try to do +/// `select_where_possible`, and the fulfillment context will try to do /// selection, retaining only those obligations that remain /// ambiguous. This may be helpful in pushing type inference /// along. Once all type inference constraints have been generated, the diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 77872690cc3..50e0a03abc9 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -897,7 +897,7 @@ pub struct GlobalCtxt<'tcx> { /// A vector of every trait accessible in the whole crate /// (i.e. including those from subcrates). This is used only for - /// error reporting, and so is lazily initialised and generally + /// error reporting, and so is lazily initialized and generally /// shouldn't taint the common path (hence the RefCell). pub all_traits: RefCell<Option<Vec<DefId>>>, } diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 896682e2370..3629709e6a4 100644 --- a/src/librustc/ty/inhabitedness/def_id_forest.rs +++ b/src/librustc/ty/inhabitedness/def_id_forest.rs @@ -26,7 +26,7 @@ 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 descendant /// of B, then only B will be in root_ids. - /// We use a SmallVec here because (for its use for cacheing inhabitedness) + /// We use a SmallVec here because (for its use for caching inhabitedness) /// its rare that this will contain even two ids. root_ids: SmallVec<[DefId; 1]>, } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index d22915181c7..4a3b5a02ae7 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -804,7 +804,7 @@ pub type Region<'tcx> = &'tcx RegionKind; /// /// The process of doing that is called "skolemization". The bound regions /// are replaced by skolemized markers, which don't satisfy any relation -/// not explicity provided. +/// not explicitly provided. /// /// There are 2 kinds of skolemized regions in rustc: `ReFree` and /// `ReSkolemized`. When checking an item's body, `ReFree` is supposed diff --git a/src/librustc_data_structures/accumulate_vec.rs b/src/librustc_data_structures/accumulate_vec.rs index c03c2890ba3..52306de74cb 100644 --- a/src/librustc_data_structures/accumulate_vec.rs +++ b/src/librustc_data_structures/accumulate_vec.rs @@ -13,7 +13,7 @@ //! Space for up to N elements is provided on the stack. If more elements are collected, Vec is //! used to store the values on the heap. //! -//! The N above is determined by Array's implementor, by way of an associatated constant. +//! The N above is determined by Array's implementor, by way of an associated constant. use std::ops::{Deref, DerefMut}; use std::iter::{self, IntoIterator, FromIterator}; diff --git a/src/librustc_data_structures/ivar.rs b/src/librustc_data_structures/ivar.rs index f842f4a41a1..de44509ef2f 100644 --- a/src/librustc_data_structures/ivar.rs +++ b/src/librustc_data_structures/ivar.rs @@ -14,7 +14,7 @@ use std::cell::Cell; /// A write-once variable. When constructed, it is empty, and /// can only be set once. /// -/// Ivars ensure that data that can only be initialised once. A full +/// Ivars ensure that data that can only be initialized once. A full /// implementation is used for concurrency and blocks on a read of an /// unfulfilled value. This implementation is more minimal and panics /// if you attempt to read the value before it has been set. It is also diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs index 4e2b3786021..74738e61b44 100644 --- a/src/librustc_data_structures/small_vec.rs +++ b/src/librustc_data_structures/small_vec.rs @@ -14,7 +14,7 @@ //! used to store the values on the heap. SmallVec is similar to AccumulateVec, but adds //! the ability to push elements. //! -//! The N above is determined by Array's implementor, by way of an associatated constant. +//! The N above is determined by Array's implementor, by way of an associated constant. use std::ops::{Deref, DerefMut}; use std::iter::{IntoIterator, FromIterator}; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 19d237b7761..3b86c684877 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -306,7 +306,7 @@ pub fn source_name(input: &Input) -> String { } } -/// CompileController is used to customise compilation, it allows compilation to +/// CompileController is used to customize compilation, it allows compilation to /// be stopped and/or to call arbitrary code at various points in compilation. /// It also allows for various flags to be set to influence what information gets /// collected during compilation. diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 8a61a309250..20f2a146b0b 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -620,6 +620,15 @@ impl UserIdentifiedItem { } // Note: Also used by librustdoc, see PR #43348. Consider moving this struct elsewhere. +// +// FIXME: Currently the `everybody_loops` transformation is not applied to: +// * `const fn`, due to issue #43636 that `loop` is not supported for const evaluation. We are +// waiting for miri to fix that. +// * `impl Trait`, due to issue #43869 that functions returning impl Trait cannot be diverging. +// Solving this may require `!` to implement every trait, which relies on the an even more +// ambitious form of the closed RFC #1637. See also [#34511]. +// +// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401 pub struct ReplaceBodyWithLoop { within_static_or_const: bool, } @@ -635,14 +644,34 @@ impl ReplaceBodyWithLoop { self.within_static_or_const = old_const; ret } + + fn should_ignore_fn(ret_ty: &ast::FnDecl) -> bool { + if let ast::FunctionRetTy::Ty(ref ty) = ret_ty.output { + fn involves_impl_trait(ty: &ast::Ty) -> bool { + match ty.node { + ast::TyKind::ImplTrait(_) => true, + ast::TyKind::Slice(ref subty) | + ast::TyKind::Array(ref subty, _) | + ast::TyKind::Ptr(ast::MutTy { ty: ref subty, .. }) | + ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. }) | + ast::TyKind::Paren(ref subty) => involves_impl_trait(subty), + ast::TyKind::Tup(ref tys) => tys.iter().any(|subty| involves_impl_trait(subty)), + _ => false, + } + } + involves_impl_trait(ty) + } else { + false + } + } } impl fold::Folder for ReplaceBodyWithLoop { fn fold_item_kind(&mut self, i: ast::ItemKind) -> ast::ItemKind { let is_const = match i { ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => true, - ast::ItemKind::Fn(_, _, ref constness, _, _, _) => - constness.node == ast::Constness::Const, + ast::ItemKind::Fn(ref decl, _, ref constness, _, _, _) => + constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), _ => false, }; self.run(is_const, |s| fold::noop_fold_item_kind(i, s)) @@ -651,8 +680,8 @@ impl fold::Folder for ReplaceBodyWithLoop { fn fold_trait_item(&mut self, i: ast::TraitItem) -> SmallVector<ast::TraitItem> { let is_const = match i.node { ast::TraitItemKind::Const(..) => true, - ast::TraitItemKind::Method(ast::MethodSig { ref constness, .. }, _) => - constness.node == ast::Constness::Const, + ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref constness, .. }, _) => + constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), _ => false, }; self.run(is_const, |s| fold::noop_fold_trait_item(i, s)) @@ -661,8 +690,8 @@ impl fold::Folder for ReplaceBodyWithLoop { fn fold_impl_item(&mut self, i: ast::ImplItem) -> SmallVector<ast::ImplItem> { let is_const = match i.node { ast::ImplItemKind::Const(..) => true, - ast::ImplItemKind::Method(ast::MethodSig { ref constness, .. }, _) => - constness.node == ast::Constness::Const, + ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref constness, .. }, _) => + constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), _ => false, }; self.run(is_const, |s| fold::noop_fold_impl_item(i, s)) diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 6c52eabd66d..5a7016e7239 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -93,9 +93,9 @@ impl Diagnostic { } /// Cancel the diagnostic (a structured diagnostic must either be emitted or - /// cancelled or it will panic when dropped). + /// canceled or it will panic when dropped). /// BEWARE: if this DiagnosticBuilder is an error, then creating it will - /// bump the error count on the Handler and cancelling it won't undo that. + /// bump the error count on the Handler and canceling it won't undo that. /// If you want to decrement the error count you should use `Handler::cancel`. pub fn cancel(&mut self) { self.level = Level::Cancelled; diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index ee0bd949898..73e09fd8fa9 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -198,7 +198,7 @@ impl<'a> Debug for DiagnosticBuilder<'a> { } } -/// Destructor bomb - a `DiagnosticBuilder` must be either emitted or cancelled +/// Destructor bomb - a `DiagnosticBuilder` must be either emitted or canceled /// or we emit a bug. impl<'a> Drop for DiagnosticBuilder<'a> { fn drop(&mut self) { diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 22b6a888f25..3b1414ef83a 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -822,7 +822,7 @@ impl EmitterWriter { .map(|_| " ") .collect::<String>(); - /// Return wether `style`, or the override if present and the style is `NoStyle`. + /// Return whether `style`, or the override if present and the style is `NoStyle`. fn style_or_override(style: Style, override_style: Option<Style>) -> Style { if let Some(o) = override_style { if style == Style::NoStyle { diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 3c5a6c031e1..52e3fcc1b47 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -141,7 +141,7 @@ pub struct Annotation { } impl Annotation { - /// Wether this annotation is a vertical line placeholder. + /// Whether this annotation is a vertical line placeholder. pub fn is_line(&self) -> bool { if let AnnotationType::MultilineLine(_) = self.annotation_type { true diff --git a/src/librustc_incremental/persist/preds/compress/construct.rs b/src/librustc_incremental/persist/preds/compress/construct.rs index 394be74f783..0ad8d178916 100644 --- a/src/librustc_incremental/persist/preds/compress/construct.rs +++ b/src/librustc_incremental/persist/preds/compress/construct.rs @@ -14,7 +14,7 @@ //! representation of the DAG): //! //! - SCCs, in the form of a union-find repr that can convert each node to -//! its *cycle head* (an arbitrarly chosen representative from the cycle) +//! its *cycle head* (an arbitrarily chosen representative from the cycle) //! - a vector of *leaf nodes*, just a convenience //! - a vector of *parents* for each node (in some cases, nodes have no parents, //! or their parent is another member of same cycle; in that case, the vector diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 32ceefdcd63..c32e7b24763 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -89,7 +89,7 @@ should go to. use build::{BlockAnd, BlockAndExtension, Builder, CFG}; use rustc::middle::region::CodeExtent; -use rustc::ty::{Ty, TyCtxt}; +use rustc::ty::Ty; use rustc::mir::*; use rustc::mir::transform::MirSource; use syntax_pos::{Span}; @@ -665,7 +665,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } assert!(!self.scopes.is_empty()); // or `any` above would be false - let Builder { ref mut hir, ref mut cfg, ref mut scopes, + let Builder { ref mut cfg, ref mut scopes, ref mut cached_resume_block, .. } = *self; // Build up the drops in **reverse** order. The end result will @@ -692,8 +692,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }; for scope in scopes.iter_mut() { - target = build_diverge_scope( - hir.tcx(), cfg, scope.extent_span, scope, target, generator_drop); + target = build_diverge_scope(cfg, scope.extent_span, scope, target, generator_drop); } Some(target) } @@ -829,8 +828,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>, block.unit() } -fn build_diverge_scope<'a, 'gcx, 'tcx>(_tcx: TyCtxt<'a, 'gcx, 'tcx>, - cfg: &mut CFG<'tcx>, +fn build_diverge_scope<'a, 'gcx, 'tcx>(cfg: &mut CFG<'tcx>, span: Span, scope: &mut Scope<'tcx>, mut target: BasicBlock, diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index d8564f858e5..cfbcd247057 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -150,6 +150,14 @@ fn run_suite<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pass.run_pass(tcx, source, mir); + for (index, promoted_mir) in mir.promoted.iter_enumerated_mut() { + let promoted_source = MirSource::Promoted(source.item_id(), index); + pass.run_pass(tcx, promoted_source, promoted_mir); + + // Let's make sure we don't miss any nested instances + assert!(promoted_mir.promoted.is_empty()); + } + for hook in tcx.mir_passes.hooks() { hook.on_mir_pass(tcx, suite, pass_num, &pass.name(), source, &mir, true); } diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs index cbad43066e4..8863d4ea5ea 100644 --- a/src/librustc_trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -47,7 +47,7 @@ pub fn unwind(val: ValueRef, can_unwind: bool) { Attribute::NoUnwind.toggle_llfn(Function, val, !can_unwind); } -/// Tell LLVM whether it should optimise function for size. +/// Tell LLVM whether it should optimize function for size. #[inline] #[allow(dead_code)] // possibly useful function pub fn set_optimize_for_size(val: ValueRef, optimize: bool) { diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 354a85b4d29..e4b090471d7 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -664,7 +664,7 @@ fn check_for_rustc_errors_attr(tcx: TyCtxt) { } } -/// Create the `main` function which will initialise the rust runtime and call +/// Create the `main` function which will initialize the rust runtime and call /// users main function. fn maybe_create_entry_wrapper(ccx: &CrateContext) { let (main_def_id, span) = match *ccx.sess().entry_fn.borrow() { diff --git a/src/librustc_trans/debuginfo/doc.rs b/src/librustc_trans/debuginfo/doc.rs index 7a739071506..93dca03e1ff 100644 --- a/src/librustc_trans/debuginfo/doc.rs +++ b/src/librustc_trans/debuginfo/doc.rs @@ -92,7 +92,7 @@ //! encounters a recursive reference, it will hit the cache and does not try to //! describe the type anew. //! -//! This behaviour is encapsulated in the 'RecursiveTypeDescription' enum, +//! This behavior is encapsulated in the 'RecursiveTypeDescription' enum, //! which represents a kind of continuation, storing all state needed to //! continue traversal at the type members after the type has been registered //! with the cache. (This implementation approach might be a tad over- @@ -156,13 +156,13 @@ //! (2) Structs, enums and traits have a multipart identifier //! //! (1) The first part is the SVH (strict version hash) of the crate they -//! wereoriginally defined in +//! were originally defined in //! //! (2) The second part is the ast::NodeId of the definition in their -//! originalcrate +//! original crate //! //! (3) The final part is a concatenation of the type IDs of their concrete -//! typearguments if they are generic types. +//! type arguments if they are generic types. //! //! (3) Tuple-, pointer and function types are structurally identified, which //! means that they are equivalent if their component types are equivalent diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 2337e989be4..c8b828f3a43 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -260,6 +260,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if !static_sources.is_empty() { err.note("found the following associated functions; to be used as methods, \ functions must have a `self` parameter"); + err.help(&format!("try with `{}::{}`", self.ty_to_string(actual), item_name)); report_candidates(&mut err, static_sources); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 504e1bfebc9..bc0c6e01fd5 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3017,8 +3017,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { type_error_struct!(self.tcx().sess, field.span, expr_t, E0615, "attempted to take value of method `{}` on type `{}`", field.node, expr_t) - .help("maybe a `()` to call it is missing? \ - If not, try an anonymous function") + .help("maybe a `()` to call it is missing?") .emit(); self.tcx().types.err } else { diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index dfbf435d74a..eb27fa3abfa 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -106,7 +106,7 @@ pub enum Class { } /// Trait that controls writing the output of syntax highlighting. Users should -/// implement this trait to customise writing output. +/// implement this trait to customize writing output. /// /// The classifier will call into the `Writer` implementation as it finds spans /// of text to highlight. Exactly how that text should be highlighted is up to diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index fc5977f533c..8ec9cd8660a 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -596,9 +596,9 @@ } return { - raw, - query, - type, + raw: raw, + query: query, + type: type, id: query + type }; } @@ -837,7 +837,7 @@ searchWords.push(crate); searchIndex.push({ - crate, + crate: crate, ty: 1, // == ExternCrate name: crate, path: "", diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs index 67f371313d0..f3379b33155 100644 --- a/src/librustdoc/html/toc.rs +++ b/src/librustdoc/html/toc.rs @@ -95,7 +95,7 @@ impl TocBuilder { /// self.top_level, D is in C.children, and C, E, F, G are in /// self.chain. /// - /// When we attempt to push H, we realise that first G is not the + /// When we attempt to push H, we realize that first G is not the /// parent (level is too high) so it is popped from chain and put /// into F.children, then F isn't the parent (level is equal, aka /// sibling), so it's also popped and put into E.children. diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 9264015ed9e..1c3f296bed9 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -400,7 +400,7 @@ pub fn main_args(args: &[String]) -> isize { }) } -/// Prints an uniformised error message on the standard error output +/// Prints an uniformized error message on the standard error output fn print_error<T>(error_message: T) where T: Display { writeln!( &mut io::stderr(), diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index db64d41011c..7392a153e3b 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -830,7 +830,7 @@ impl CStr { /// /// It is your responsibility to make sure that the underlying memory is not /// freed too early. For example, the following code will cause undefined - /// behaviour when `ptr` is used inside the `unsafe` block: + /// behavior when `ptr` is used inside the `unsafe` block: /// /// ```no_run /// use std::ffi::{CString}; diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index d62e3e905e3..a40a9329ed9 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -123,7 +123,7 @@ impl OsString { /// Creates a new `OsString` with the given capacity. /// - /// The string will be able to hold exactly `capacity` lenth units of other + /// The string will be able to hold exactly `capacity` length units of other /// OS strings without reallocating. If `capacity` is 0, the string will not /// allocate. /// diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index d986021a18b..32a92145aaf 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -69,7 +69,7 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; /// // now let's write a test /// #[test] /// fn test_writes_bytes() { -/// // setting up a real File is much more slow than an in-memory buffer, +/// // setting up a real File is much slower than an in-memory buffer, /// // let's use a cursor instead /// use std::io::Cursor; /// let mut buff = Cursor::new(vec![0; 15]); diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index bb18fe95a9d..403685a4b8e 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -387,7 +387,7 @@ impl Drop for Finish { impl OnceState { /// Returns whether the associated [`Once`] has been poisoned. /// - /// Once an initalization routine for a [`Once`] has panicked it will forever + /// Once an initialization routine for a [`Once`] has panicked it will forever /// indicate to future forced initialization routines that it is poisoned. /// /// [`Once`]: struct.Once.html diff --git a/src/libstd/sys/redox/args.rs b/src/libstd/sys/redox/args.rs index 6e44ad705fe..59ae2a74a6d 100644 --- a/src/libstd/sys/redox/args.rs +++ b/src/libstd/sys/redox/args.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Global initialization and retreival of command line arguments. +//! Global initialization and retrieval of command line arguments. //! //! On some platforms these are stored during runtime startup, //! and on some they are retrieved from the system on demand. diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index bbdcb5d3616..810d2d40c05 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Global initialization and retreival of command line arguments. +//! Global initialization and retrieval of command line arguments. //! //! On some platforms these are stored during runtime startup, //! and on some they are retrieved from the system on demand. diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 3cd9cf7727c..83feb595bce 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -560,7 +560,7 @@ pub fn current() -> Thread { /// implementing low-level shared resources or synchronization primitives. /// /// However programmers will usually prefer to use, [`channel`]s, [`Condvar`]s, -/// [`Mutex`]es or [`join`] for their synchronisation routines, as they avoid +/// [`Mutex`]es or [`join`] for their synchronization routines, as they avoid /// thinking about thread scheduling. /// /// Note that [`channel`]s for example are implemented using this primitive. diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index e8eb4abaa40..5b893505b34 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -112,7 +112,7 @@ pub struct Instant(time::Instant); /// println!("{}", elapsed.as_secs()); /// } /// Err(e) => { -/// // an error occured! +/// // an error occurred! /// println!("Error: {:?}", e); /// } /// } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 09762417c1c..71c1f791470 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -345,9 +345,6 @@ declare_features! ( // Allows `repr(align(u16))` struct attribute (RFC 1358) (active, repr_align, "1.17.0", Some(33626)), - // See rust-lang/rfcs#1414. Allows code like `let x: &'static u32 = &42` to work. - (active, rvalue_static_promotion, "1.15.1", Some(38865)), - // Used to preserve symbols (see llvm.used) (active, used, "1.18.0", Some(40289)), @@ -461,6 +458,8 @@ declare_features! ( (accepted, associated_consts, "1.20.0", Some(29646)), // Usage of the `compile_error!` macro (accepted, compile_error, "1.20.0", Some(40872)), + // See rust-lang/rfcs#1414. Allows code like `let x: &'static u32 = &42` to work. + (accepted, rvalue_static_promotion, "1.21.0", Some(38865)), ); // If you change this, please modify src/doc/unstable-book as well. You must diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 19238c30670..37a59411c16 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -11,7 +11,7 @@ //! A JSON emitter for errors. //! //! This works by converting errors to a simplified structural format (see the -//! structs at the start of the file) and then serialising them. These should +//! structs at the start of the file) and then serializing them. These should //! contain as much information about the error as possible. //! //! The format of the JSON output should be considered *unstable*. For now the diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 674facd05fd..a0dd2975ca0 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -23,7 +23,7 @@ //! and lifetimes for methods.) //! - Additional bounds on the type parameters (`TraitDef.additional_bounds`) //! -//! The most important thing for implementers is the `Substructure` and +//! The most important thing for implementors is the `Substructure` and //! `SubstructureFields` objects. The latter groups 5 possibilities of the //! arguments: //! diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs b/src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs index fbb3824cd40..f7514df800d 100644 --- a/src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs +++ b/src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs @@ -11,10 +11,12 @@ // Test lifetimes are linked properly when we take reference // to interior. +fn id<T>(x: T) -> T { x } + struct Foo(isize); fn foo<'a>() -> &'a isize { - let &Foo(ref x) = &Foo(3); //~ ERROR borrowed value does not live long enough + let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough x } diff --git a/src/test/compile-fail/issue-11493.rs b/src/test/compile-fail/issue-11493.rs index 333ff7118d4..3045c06ca4c 100644 --- a/src/test/compile-fail/issue-11493.rs +++ b/src/test/compile-fail/issue-11493.rs @@ -10,7 +10,9 @@ // This file must never have a trailing newline +fn id<T>(x: T) -> T { x } + fn main() { let x = Some(3); - let y = x.as_ref().unwrap_or(&5); //~ ERROR: borrowed value does not live long enough + let y = x.as_ref().unwrap_or(&id(5)); //~ ERROR: borrowed value does not live long enough } diff --git a/src/test/compile-fail/issue-17545.rs b/src/test/compile-fail/issue-17545.rs index 45bc5ee07a5..9264305e6ea 100644 --- a/src/test/compile-fail/issue-17545.rs +++ b/src/test/compile-fail/issue-17545.rs @@ -10,9 +10,11 @@ #![feature(fn_traits)] +fn id<T>(x: T) -> T { x } + pub fn foo<'a, F: Fn(&'a ())>(bar: F) { bar.call(( - &(), //~ ERROR borrowed value does not live long enough + &id(()), //~ ERROR borrowed value does not live long enough )); } fn main() {} diff --git a/src/test/compile-fail/issue-17718-constants-not-static.rs b/src/test/compile-fail/issue-17718-constants-not-static.rs index db56d2c6cf3..9b7ed463499 100644 --- a/src/test/compile-fail/issue-17718-constants-not-static.rs +++ b/src/test/compile-fail/issue-17718-constants-not-static.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn id<T>(x: T) -> T { x } + const FOO: usize = 3; -fn foo() -> &'static usize { &FOO } +fn foo() -> &'static usize { &id(FOO) } //~^ ERROR: borrowed value does not live long enough fn main() { diff --git a/src/test/compile-fail/issue-27592.rs b/src/test/compile-fail/issue-27592.rs index ccf5eabc111..731d4fb2bf6 100644 --- a/src/test/compile-fail/issue-27592.rs +++ b/src/test/compile-fail/issue-27592.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Regression test for issue #27591. +// Regression test for issue #27592. fn write<'a, F: ::std::ops::FnOnce()->::std::fmt::Arguments<'a> + 'a>(fcn: F) { use std::fmt::Write; @@ -23,7 +23,7 @@ impl ::std::fmt::Write for Stream { } fn main() { - write(|| format_args!("{}", "Hello world")); + write(|| format_args!("{}", String::from("Hello world"))); //~^ ERROR borrowed value does not live long enough //~| ERROR borrowed value does not live long enough } diff --git a/src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs b/src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs index 9c985839c4d..46c486c63a3 100644 --- a/src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs +++ b/src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs @@ -12,6 +12,8 @@ // are treated as rvalues and their lifetime is not bounded to // the static scope. +fn id<T>(x: T) -> T { x } + struct Test; enum MyEnum { @@ -19,12 +21,14 @@ enum MyEnum { } fn structLifetime<'a>() -> &'a Test { - let testValue = &Test; //~ ERROR borrowed value does not live long enough + let testValue = &id(Test); + //~^ ERROR borrowed value does not live long enough testValue } fn variantLifetime<'a>() -> &'a MyEnum { - let testValue = &MyEnum::Variant1; //~ ERROR borrowed value does not live long enough + let testValue = &id(MyEnum::Variant1); + //~^ ERROR borrowed value does not live long enough testValue } diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs index 61c98d69d80..c7cd3ced98d 100644 --- a/src/test/compile-fail/regions-ret.rs +++ b/src/test/compile-fail/regions-ret.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn id<T>(x: T) -> T { x } + fn f(_x: &isize) -> &isize { - return &3; //~ ERROR borrowed value does not live long enough + return &id(3); //~ ERROR borrowed value does not live long enough } fn main() { diff --git a/src/test/compile-fail/regions-var-type-out-of-scope.rs b/src/test/compile-fail/regions-var-type-out-of-scope.rs index 8955a26de0b..031091c4523 100644 --- a/src/test/compile-fail/regions-var-type-out-of-scope.rs +++ b/src/test/compile-fail/regions-var-type-out-of-scope.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn id<T>(x: T) -> T { x } + fn foo(cond: bool) { // Here we will infer a type that uses the // region of the if stmt then block: let mut x; if cond { - x = &3; //~ ERROR borrowed value does not live long enough + x = &id(3); //~ ERROR borrowed value does not live long enough assert_eq!(*x, 3); } } diff --git a/src/test/compile-fail/static-reference-to-fn-2.rs b/src/test/compile-fail/static-reference-to-fn-2.rs index 460154f25d7..8d9f442b81d 100644 --- a/src/test/compile-fail/static-reference-to-fn-2.rs +++ b/src/test/compile-fail/static-reference-to-fn-2.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn id<T>(x: T) -> T { x } + struct StateMachineIter<'a> { statefn: &'a StateMachineFunc<'a> } @@ -23,19 +25,19 @@ impl<'a> Iterator for StateMachineIter<'a> { } fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { - self_.statefn = &(state2 as StateMachineFunc); + self_.statefn = &id(state2 as StateMachineFunc); //~^ ERROR borrowed value does not live long enough return Some("state1"); } fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { - self_.statefn = &(state3 as StateMachineFunc); + self_.statefn = &id(state3 as StateMachineFunc); //~^ ERROR borrowed value does not live long enough return Some("state2"); } fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { - self_.statefn = &(finished as StateMachineFunc); + self_.statefn = &id(finished as StateMachineFunc); //~^ ERROR borrowed value does not live long enough return Some("state3"); } @@ -46,7 +48,8 @@ fn finished(_: &mut StateMachineIter) -> Option<(&'static str)> { fn state_iter() -> StateMachineIter<'static> { StateMachineIter { - statefn: &(state1 as StateMachineFunc) //~ ERROR borrowed value does not live long enough + statefn: &id(state1 as StateMachineFunc) + //~^ ERROR borrowed value does not live long enough } } diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index eca22bfdda0..90ed401659c 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -10,11 +10,13 @@ #![feature(box_syntax)] +fn id<T>(x: T) -> T { x } + fn f<T:'static>(_: T) {} fn main() { let x: Box<_> = box 3; f(x); - let x = &3; //~ ERROR borrowed value does not live long enough + let x = &id(3); //~ ERROR borrowed value does not live long enough f(x); } diff --git a/src/test/run-pass/rvalue-static-promotion.rs b/src/test/run-pass/rvalue-static-promotion.rs index 30643cfc3eb..e57491930a4 100644 --- a/src/test/run-pass/rvalue-static-promotion.rs +++ b/src/test/run-pass/rvalue-static-promotion.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(rvalue_static_promotion)] - #[allow(unused_variables)] fn main() { let x: &'static u32 = &42; diff --git a/src/test/compile-fail/feature-gate-rvalue_static_promotion.rs b/src/test/rustdoc/issue-43869.rs index f33d0a71481..2d18e4be532 100644 --- a/src/test/compile-fail/feature-gate-rvalue_static_promotion.rs +++ b/src/test/rustdoc/issue-43869.rs @@ -8,8 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[allow(unused_variables)] -fn main() { - let x: &'static u32 = &42; //~ error: does not live long enough - let y: &'static Option<u32> = &None; //~ error: does not live long enough +#![feature(conservative_impl_trait)] + +pub fn g() -> impl Iterator<Item=u8> { + Some(1u8).into_iter() +} + +pub fn h() -> (impl Iterator<Item=u8>) { + Some(1u8).into_iter() +} + +pub fn i() -> impl Iterator<Item=u8> + 'static { + Some(1u8).into_iter() +} + +pub fn j() -> impl Iterator<Item=u8> + Clone { + Some(1u8).into_iter() } + +// @has issue_43869/fn.g.html +// @has issue_43869/fn.h.html +// @has issue_43869/fn.i.html +// @has issue_43869/fn.j.html diff --git a/src/test/ui/issue-41652/issue_41652.stderr b/src/test/ui/issue-41652/issue_41652.stderr index 8a55c9989e1..5d143697908 100644 --- a/src/test/ui/issue-41652/issue_41652.stderr +++ b/src/test/ui/issue-41652/issue_41652.stderr @@ -5,6 +5,7 @@ error[E0599]: no method named `f` found for type `{integer}` in the current scop | ^ | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter + = help: try with `{integer}::f` note: candidate #1 is defined in the trait `issue_41652_b::Tr` --> $DIR/auxiliary/issue_41652_b.rs:14:5 | diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.rs b/src/test/ui/lifetimes/borrowck-let-suggestion.rs index eeafaab44c6..1c904648f9e 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.rs +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.rs @@ -9,7 +9,7 @@ // except according to those terms. fn f() { - let x = [1].iter(); + let x = vec![1].iter(); } fn main() { diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr index d1ba9246588..6316c066660 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr @@ -1,14 +1,15 @@ error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-let-suggestion.rs:12:23 + --> $DIR/borrowck-let-suggestion.rs:12:27 | -12 | let x = [1].iter(); - | --- ^ temporary value dropped here while still borrowed +12 | let x = vec![1].iter(); + | ------- ^ temporary value dropped here while still borrowed | | | temporary value created here 13 | } | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime + = note: this error originates in a macro outside of the current crate error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs index 1206d716672..9e316b989a4 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn id<T>(x: T) -> T { x } + fn f() { let old = ['o']; // statement 0 let mut v1 = Vec::new(); // statement 1 @@ -21,7 +23,7 @@ fn f() { let mut v3 = Vec::new(); // statement 5 - v3.push(&'x'); // statement 6 + v3.push(&id('x')); // statement 6 //~^ ERROR borrowed value does not live long enough //~| NOTE temporary value created here //~| NOTE temporary value only lives until here @@ -31,7 +33,7 @@ fn f() { let mut v4 = Vec::new(); // (sub) statement 0 - v4.push(&'y'); + v4.push(&id('y')); //~^ ERROR borrowed value does not live long enough //~| NOTE temporary value created here //~| NOTE temporary value only lives until here @@ -42,7 +44,7 @@ fn f() { let mut v5 = Vec::new(); // statement 8 - v5.push(&'z'); + v5.push(&id('z')); //~^ ERROR borrowed value does not live long enough //~| NOTE temporary value created here //~| NOTE temporary value only lives until here diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr index 6ed1b7c2622..86c6f28ef1c 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr @@ -1,49 +1,49 @@ error[E0597]: `young[..]` does not live long enough - --> $DIR/borrowck-let-suggestion-suffixes.rs:52:1 + --> $DIR/borrowck-let-suggestion-suffixes.rs:54:1 | -19 | v2.push(&young[0]); // statement 4 +21 | v2.push(&young[0]); // statement 4 | -------- borrow occurs here ... -52 | } +54 | } | ^ `young[..]` dropped here while still borrowed | = note: values in a scope are dropped in the opposite order they are created error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-let-suggestion-suffixes.rs:24:18 + --> $DIR/borrowck-let-suggestion-suffixes.rs:26:22 | -24 | v3.push(&'x'); // statement 6 - | --- ^ temporary value dropped here while still borrowed +26 | v3.push(&id('x')); // statement 6 + | ------- ^ temporary value dropped here while still borrowed | | | temporary value created here ... -52 | } +54 | } | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-let-suggestion-suffixes.rs:34:22 + --> $DIR/borrowck-let-suggestion-suffixes.rs:36:26 | -34 | v4.push(&'y'); - | --- ^ temporary value dropped here while still borrowed +36 | v4.push(&id('y')); + | ------- ^ temporary value dropped here while still borrowed | | | temporary value created here ... -40 | } // (statement 7) +42 | } // (statement 7) | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-let-suggestion-suffixes.rs:45:18 + --> $DIR/borrowck-let-suggestion-suffixes.rs:47:22 | -45 | v5.push(&'z'); - | --- ^ temporary value dropped here while still borrowed +47 | v5.push(&id('z')); + | ------- ^ temporary value dropped here while still borrowed | | | temporary value created here ... -52 | } +54 | } | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime diff --git a/src/test/ui/span/issue-15480.rs b/src/test/ui/span/issue-15480.rs index ea5f4d3fe60..871e0af50bf 100644 --- a/src/test/ui/span/issue-15480.rs +++ b/src/test/ui/span/issue-15480.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn id<T>(x: T) -> T { x } + fn main() { let v = vec![ - &3 + &id(3) ]; for &&x in &v { diff --git a/src/test/ui/span/issue-15480.stderr b/src/test/ui/span/issue-15480.stderr index ce1c6e81b96..7f4ca19241c 100644 --- a/src/test/ui/span/issue-15480.stderr +++ b/src/test/ui/span/issue-15480.stderr @@ -1,12 +1,12 @@ error[E0597]: borrowed value does not live long enough - --> $DIR/issue-15480.rs:14:6 + --> $DIR/issue-15480.rs:16:6 | -13 | &3 - | - temporary value created here -14 | ]; +15 | &id(3) + | ----- temporary value created here +16 | ]; | ^ temporary value dropped here while still borrowed ... -19 | } +21 | } | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime diff --git a/src/test/ui/span/issue-7575.stderr b/src/test/ui/span/issue-7575.stderr index ff62adbfbd5..08ec2a87fcd 100644 --- a/src/test/ui/span/issue-7575.stderr +++ b/src/test/ui/span/issue-7575.stderr @@ -5,6 +5,7 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope | ^^ | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter + = help: try with `usize::f9` note: candidate #1 is defined in the trait `CtxtFn` --> $DIR/issue-7575.rs:16:5 | @@ -36,6 +37,7 @@ error[E0599]: no method named `fff` found for type `Myisize` in the current scop | ^^^ | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter + = help: try with `Myisize::fff` note: candidate #1 is defined in an impl for the type `Myisize` --> $DIR/issue-7575.rs:51:5 | @@ -51,6 +53,7 @@ error[E0599]: no method named `is_str` found for type `T` in the current scope | ^^^^^^ | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter + = help: try with `T::is_str` note: candidate #1 is defined in the trait `ManyImplTrait` --> $DIR/issue-7575.rs:57:5 | diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs index a524562f2d9..99b0d6ed296 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs @@ -10,6 +10,8 @@ #![feature(box_syntax)] +fn id<T>(x: T) -> T { x } + trait Foo { } impl<'a> Foo for &'a isize { } @@ -17,7 +19,7 @@ impl<'a> Foo for &'a isize { } fn main() { let blah; { - let ss: &isize = &1; + let ss: &isize = &id(1); blah = box ss as Box<Foo>; } } diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr index e671f1daf61..6a3625441b4 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr @@ -1,12 +1,12 @@ error[E0597]: borrowed value does not live long enough - --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:22:5 + --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:24:5 | -20 | let ss: &isize = &1; - | - temporary value created here -21 | blah = box ss as Box<Foo>; -22 | } +22 | let ss: &isize = &id(1); + | ----- temporary value created here +23 | blah = box ss as Box<Foo>; +24 | } | ^ temporary value dropped here while still borrowed -23 | } +25 | } | - temporary value needs to live until here error: aborting due to previous error diff --git a/src/test/ui/span/slice-borrow.rs b/src/test/ui/span/slice-borrow.rs index 4ca0ccaa731..1b022f23246 100644 --- a/src/test/ui/span/slice-borrow.rs +++ b/src/test/ui/span/slice-borrow.rs @@ -13,7 +13,7 @@ fn main() { let y; { - let x: &[isize] = &[1, 2, 3, 4, 5]; + let x: &[isize] = &vec![1, 2, 3, 4, 5]; y = &x[1..]; } } diff --git a/src/test/ui/span/slice-borrow.stderr b/src/test/ui/span/slice-borrow.stderr index b60ccd0fbf3..5e8edf80df6 100644 --- a/src/test/ui/span/slice-borrow.stderr +++ b/src/test/ui/span/slice-borrow.stderr @@ -1,13 +1,15 @@ error[E0597]: borrowed value does not live long enough --> $DIR/slice-borrow.rs:18:5 | -16 | let x: &[isize] = &[1, 2, 3, 4, 5]; - | --------------- temporary value created here +16 | let x: &[isize] = &vec![1, 2, 3, 4, 5]; + | ------------------- temporary value created here 17 | y = &x[1..]; 18 | } | ^ temporary value dropped here while still borrowed 19 | } | - temporary value needs to live until here + | + = note: this error originates in a macro outside of the current crate error: aborting due to previous error |
