]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #43915 - adrian5:patch-1, r=sfackler
authorCorey Farwell <coreyf@rwell.org>
Thu, 17 Aug 2017 14:44:11 +0000 (10:44 -0400)
committerGitHub <noreply@github.com>
Thu, 17 Aug 2017 14:44:11 +0000 (10:44 -0400)
Fix typo in doc

84 files changed:
src/bootstrap/lib.rs
src/bootstrap/native.rs
src/doc/book
src/doc/nomicon
src/doc/reference
src/doc/unstable-book/src/language-features/rvalue-static-promotion.md [deleted file]
src/liballoc/allocator.rs
src/liballoc/btree/node.rs
src/liballoc/raw_vec.rs
src/libcore/hash/mod.rs
src/libcore/num/dec2flt/rawfp.rs
src/libcore/ops/try.rs
src/libcore/sync/atomic.rs
src/libgraphviz/lib.rs
src/librand/distributions/gamma.rs
src/librand/isaac.rs
src/librand/lib.rs
src/librand/reseeding.rs
src/librustc/diagnostics.rs
src/librustc/hir/map/mod.rs
src/librustc/infer/error_reporting/mod.rs
src/librustc/infer/resolve.rs
src/librustc/lint/context.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/region.rs
src/librustc/mir/traversal.rs
src/librustc/traits/fulfill.rs
src/librustc/ty/context.rs
src/librustc/ty/inhabitedness/def_id_forest.rs
src/librustc/ty/sty.rs
src/librustc_data_structures/accumulate_vec.rs
src/librustc_data_structures/ivar.rs
src/librustc_data_structures/small_vec.rs
src/librustc_driver/driver.rs
src/librustc_driver/pretty.rs
src/librustc_errors/diagnostic.rs
src/librustc_errors/diagnostic_builder.rs
src/librustc_errors/emitter.rs
src/librustc_errors/snippet.rs
src/librustc_incremental/persist/preds/compress/construct.rs
src/librustc_mir/transform/mod.rs
src/librustc_trans/attributes.rs
src/librustc_trans/base.rs
src/librustc_trans/debuginfo/doc.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/mod.rs
src/librustdoc/html/highlight.rs
src/librustdoc/html/toc.rs
src/librustdoc/lib.rs
src/libstd/ffi/c_str.rs
src/libstd/ffi/os_str.rs
src/libstd/sync/once.rs
src/libstd/sys/redox/args.rs
src/libstd/sys/unix/args.rs
src/libstd/thread/mod.rs
src/libstd/time/mod.rs
src/libsyntax/feature_gate.rs
src/libsyntax/json.rs
src/libsyntax_ext/deriving/generic/mod.rs
src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs
src/test/compile-fail/feature-gate-rvalue_static_promotion.rs [deleted file]
src/test/compile-fail/issue-11493.rs
src/test/compile-fail/issue-17545.rs
src/test/compile-fail/issue-17718-constants-not-static.rs
src/test/compile-fail/issue-27592.rs
src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs
src/test/compile-fail/regions-ret.rs
src/test/compile-fail/regions-var-type-out-of-scope.rs
src/test/compile-fail/static-reference-to-fn-2.rs
src/test/compile-fail/static-region-bound.rs
src/test/run-pass/rvalue-static-promotion.rs
src/test/rustdoc/issue-43869.rs [new file with mode: 0644]
src/test/ui/issue-41652/issue_41652.stderr
src/test/ui/lifetimes/borrowck-let-suggestion.rs
src/test/ui/lifetimes/borrowck-let-suggestion.stderr
src/test/ui/span/borrowck-let-suggestion-suffixes.rs
src/test/ui/span/borrowck-let-suggestion-suffixes.stderr
src/test/ui/span/issue-15480.rs
src/test/ui/span/issue-15480.stderr
src/test/ui/span/issue-7575.stderr
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr
src/test/ui/span/slice-borrow.rs
src/test/ui/span/slice-borrow.stderr

index 17f8bcdf03da1438f62ecd7368b295a261b72f4a..b6e009815763362db829da3b306803dd2cea3a96 100644 (file)
@@ -444,7 +444,7 @@ fn stage_out(&self, compiler: Compiler, mode: Mode) -> PathBuf {
     }
 
     /// 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,
index 59efbd5c4d20d8d9ce7f96d355cf746e20e13fec..0a307e72bf61d1a2e391949eaec721eb5f77230a 100644 (file)
@@ -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).
 //!
index 6f1a03dae6bcea44976918186f2d554186b3499c..d09c9e8144ed32170b7596abb145ade8b097acaf 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 6f1a03dae6bcea44976918186f2d554186b3499c
+Subproject commit d09c9e8144ed32170b7596abb145ade8b097acaf
index f570bcb681771d691aa4fdb8dfcfad1939844bf5..a4322ccb289a43cc238d4536982f184a3eec9ba7 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f570bcb681771d691aa4fdb8dfcfad1939844bf5
+Subproject commit a4322ccb289a43cc238d4536982f184a3eec9ba7
index 1abfbaa70313fdf527cf799ffd9b9a096a62105c..266d429a48468371d2d90669f6a30dd659bb4bdb 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1abfbaa70313fdf527cf799ffd9b9a096a62105c
+Subproject commit 266d429a48468371d2d90669f6a30dd659bb4bdb
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 (file)
index 2583d35..0000000
+++ /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);
-}
-```
index 2b3df15f716183062ba1b28cb9ee15c2f96ebd49..fc6585a9f951d6d58c6bb29dbe27ee5eed5eb1b4 100644 (file)
@@ -293,7 +293,7 @@ pub fn repeat_packed(&self, n: usize) -> Option<Self> {
     /// 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.
     ///
index b057c18fca8952c43aee42eb5c6ea747196535e8..c1618043ce66fca8f1ffc0ee9f93287b538fb708 100644 (file)
@@ -763,7 +763,7 @@ fn clone(&self) -> Self {
 }
 
 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
     }
index 9a8614895f30c30bca9fe18600624674c439a049..841f9dc64142e3528f01c2cd6b29c6dd5cb6b899 100644 (file)
@@ -544,12 +544,12 @@ pub fn reserve(&mut self, used_cap: usize, needed_extra_cap: usize) {
     /// 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.
     ///
index 2000ba91460292347aa9c04930347f4a907a17b4..a8b84203d6a6c61402d1ef4a26a586a4fd7df0c9 100644 (file)
@@ -240,7 +240,12 @@ fn hash_slice<H: Hasher>(data: &[Self], state: &mut H)
 /// [`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;
 
index 2a60292d0232e1e525606edc20ecc0a9821abc68..12960fed04550cfba525cf42952039fb1b0bdcaf 100644 (file)
@@ -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.
index 4971e825a6fbecab76c59e2f0150d0a818a5e7c3..78326c3e6391a1b36b0ff2db9a1afbb8bd86539a 100644 (file)
@@ -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
index d647a94a1efde0b26a361ad22a8089f75e5b7bc4..510e01db0e965ed190343d11552ce3343ad52b0f 100644 (file)
@@ -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);
 ///     }
 ///
index d66fba18f475c0258932deec3bb486392a7cbe50..4ee0c3d92bd2cc51eb0d7ac808c4864286d6271f 100644 (file)
@@ -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](
 //!
 //! 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 &sube; character (specified using the HTML character
+//! labeled with the &sube; character (specified using the HTML character
 //! entity `&sube`).
 //!
 //! ```rust
@@ -789,7 +789,7 @@ fn edge(from: usize, to: usize, label: &'static str, style: Style) -> Edge {
     }
 
     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
index 188e71f3fa948271ff5052e21baff67b0c1bb778..e796197ab5bf24e16ae23416cd17c66b7fb9d758 100644 (file)
@@ -254,7 +254,7 @@ fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
 
 /// 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 {
index 2baa07e370e1740c775ee5ceabf57ab87fd4fbea..96ce0905e384da72f72f008acd0f8be8dc71fad7 100644 (file)
@@ -76,7 +76,7 @@ pub fn new_unseeded() -> 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 @@ pub fn new_unseeded() -> 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) {
index a1b6ddcb331a82de0dc8f9b6d16a8a439b1172ff..a3c4f6a4b1db11ed4f822463ee6ec1b2b0a4386f 100644 (file)
@@ -180,7 +180,7 @@ fn next_f64(&mut self) -> f64 {
     /// 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
index 804fe9dc63c5314924c3cdb9b0db88df12304dfa..2821b7a8232df4622e4a12df47c49115c22aaff1 100644 (file)
@@ -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,
 }
 
index 522c1531c593804228a9bbad830df4d7756ef6d0..34d31028385cfa9b27b60ba95506e0ba815ab672 100644 (file)
@@ -362,6 +362,10 @@ enum Enum {
 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
 
index ed4e28cc9ebf2ddcf7502e3a63ab3c6cd5473e5e..8cd229a2adf63007ed2587daf75c00e3327304ec 100644 (file)
@@ -731,7 +731,7 @@ pub fn get_module_parent(&self, id: NodeId) -> DefId {
 
     /// 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 {
index b5390da7e852d184158109fae5afb6e16c733529..d608d09d05498051c1a4383a3ff848fefb3b71f0 100644 (file)
@@ -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.
 //!
index 6a1f8f1d069270ae341a25fab29440b8cc12fbe4..639a330dc6e67dffdb4d7026154f3a8bd2556030 100644 (file)
@@ -46,7 +46,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
 }
 
 /// 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>,
index 40d78d0138bb266cc9c60bacc06a7f4cd7c875c6..92b159a55f49accf590bef6b6a1ec935fcc3d50b 100644 (file)
@@ -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),
index 8919d0afc1d7beb80bccd87a74cbb7f09df6020e..c8a7f8c4aaf8c8d3369744ed65730379ac348a6d 100644 (file)
@@ -873,10 +873,10 @@ pub fn cat_rvalue_node(&self,
         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
index 9133a5e777db2743deea169f9a4a943dd5c27eb7..45a3080ed91ff3e5e4389e76e2a83ab5dfc0b888 100644 (file)
@@ -72,7 +72,7 @@
 ///  (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 = ...).
index 5aab46b3cefb4beaa8f39f90d54779017d422d20..74c3408c4c2f61837d9e3e7fb4841b7080ee0518 100644 (file)
@@ -216,7 +216,7 @@ fn next(&mut self) -> Option<(BasicBlock, &'a BasicBlockData<'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
 ///
index 4f1eb6169209b2696c3803e29fd2c27858588195..78e47693caaf138a47d6baaeee3cf9dd95a0654b 100644 (file)
@@ -37,7 +37,7 @@ fn as_predicate(&self) -> &Self::Predicate { &self.obligation.predicate }
 /// 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
index 7d34b908edf445672c3c71a671d79d1fbcc7f667..da1039c5de1768088a0bf4805f86c4f42c36d1de 100644 (file)
@@ -851,7 +851,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>>>,
 }
index 896682e2370e2a9e7daebf370752e64162a03906..3629709e6a48de19a1f0843f26d4b7f88099f353 100644 (file)
@@ -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]>,
 }
index 389c581ebe314b5ac363a3affc5753c0454955c4..8d6b7b7ac9fddff6537358098bc78a1e4900b394 100644 (file)
@@ -739,7 +739,7 @@ pub struct DebruijnIndex {
 ///
 /// 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
index c03c2890ba34c6cb4723c3eb00ed514a8bf2e5a5..52306de74cb8babac54713eacc81b271d7ea7b33 100644 (file)
@@ -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};
index f842f4a41a118b36d9b7d4bc1162dc0d5afda1c5..de44509ef2fd81c17b0543acf39d2af91cdfa620 100644 (file)
@@ -14,7 +14,7 @@
 /// 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
index 4e2b3786021026bf85b6821724ee0cfe3612201b..74738e61b446775aebb84e80e6e974fffae5f609 100644 (file)
@@ -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};
index 0c729b5a3fc87ed16ec48c50693e7a0d427681f8..c98f9c3d4660a2637612b5508ce7f6a84dc6cfe9 100644 (file)
@@ -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.
index 8a61a3092508383e143f099b4458f362c8ace5b7..20f2a146b0b1584c1e83a7de8365eae64a5610c2 100644 (file)
@@ -620,6 +620,15 @@ fn to_one_node_id(self, user_option: &str, sess: &Session, map: &hir_map::Map) -
 }
 
 // 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 @@ fn run<R, F: FnOnce(&mut Self) -> R>(&mut self, is_const: bool, action: F) -> R
         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 @@ fn fold_item_kind(&mut self, i: ast::ItemKind) -> ast::ItemKind {
     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 @@ fn fold_trait_item(&mut self, i: ast::TraitItem) -> SmallVector<ast::TraitItem>
     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))
index 6c52eabd66d1219826b3c9cc5575e2366f61ae59..5a7016e72395a74fd9c22befd002f56447ea987f 100644 (file)
@@ -93,9 +93,9 @@ pub fn new_with_code(level: Level, code: Option<String>, message: &str) -> Self
     }
 
     /// 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;
index ee0bd9498982c775d1ffed48651db2dcdbceb368..73e09fd8fa99350caf87e1308d141526a9aa59a7 100644 (file)
@@ -198,7 +198,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-/// 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) {
index 22b6a888f257ac6858636d03190e9d29c047b399..3b1414ef83a6998ecf285a6e362f9e0e928ae8f2 100644 (file)
@@ -822,7 +822,7 @@ fn msg_to_buffer(&self,
             .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 {
index 3c5a6c031e18c780b58b7ed7420f91106fcb97fb..52e3fcc1b474c638de8d64c6b4672ba45ba9e01f 100644 (file)
@@ -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
index 394be74f7835f08fc7975386a59691c477425cfd..0ad8d1789167df38a7cb9e0a882a64b42d7a2c65 100644 (file)
@@ -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
index 38070a4b4858a7bd2392742f5fd5161665d2dfa8..25a156ea3fd97026347178ffb305a2e22f303f96 100644 (file)
@@ -149,6 +149,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);
         }
index cbad43066e4ebe3baeb50af0ea3537633b161976..8863d4ea5ea8ace42a98c71ca388f2c68dbc9c0a 100644 (file)
@@ -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) {
index 354a85b4d29a5fe4b62d3c28d7453e1debbc3529..e4b090471d75a9ca493da22af3525d70de2f42c7 100644 (file)
@@ -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() {
index 7a739071506dbe2f3b1c933d92dd4d4ef96f6b70..93dca03e1ff8ee71a90239a574472d7f90bc8f4a 100644 (file)
@@ -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-
 //! (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
index 2337e989be46df22ead6f7224e1b4bbcb7afc02c..c8b828f3a434dca6cb9d3a103665d20e5b3cb0c1 100644 (file)
@@ -260,6 +260,7 @@ macro_rules! report_function {
                 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);
                 }
index bc03c9254173823f67e5e17b1d40547ab002b439..2489a8c6941278391e138a5c4c6f537e77945728 100644 (file)
@@ -2968,8 +2968,7 @@ fn check_field(&self,
             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 {
index dfbf435d74a51e2ab19c86ab2597cc08f6871e36..eb27fa3abfa19a240bd9d123e9af1288c11be5d7 100644 (file)
@@ -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
index 67f371313d0d63214ca9989c2dde596646f3a1d7..f3379b331556b194b280f4d3286a51903e4c0345 100644 (file)
@@ -95,7 +95,7 @@ pub fn into_toc(mut self) -> Toc {
     /// 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.
index 9264015ed9edfae068ccc6d783af38e71726498f..1c3f296bed96cbde9251c72a4c6c4ef3b0fe165e 100644 (file)
@@ -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(),
index db64d41011c6b5aa751867f6a4c200f2b8044013..7392a153e3b87a5ace60736fd78d6f75db204013 100644 (file)
@@ -830,7 +830,7 @@ pub unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &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};
index d62e3e905e3ca26d7a45b9fd1494655f689bf28b..a40a9329ed9bf85fe0ce95e3f0dbc9d09b67ab90 100644 (file)
@@ -123,7 +123,7 @@ pub fn push<T: AsRef<OsStr>>(&mut self, s: T) {
 
     /// 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.
     ///
index bb18fe95a9dbfb08cfee8456a364bc2b4f50b7c8..403685a4b8e0be9de12f829cd28171b53db39e15 100644 (file)
@@ -387,7 +387,7 @@ fn drop(&mut self) {
 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
index 6e44ad705fe72b28ae828308c515db95ee85d1b3..59ae2a74a6ddd2ceabedcf37498398aa7f19990a 100644 (file)
@@ -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.
index bbdcb5d36167ea1f608aeb6dc0481148643dab6f..810d2d40c05f44f07b19b02fd133189a3dd83172 100644 (file)
@@ -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.
index 3cd9cf7727c204bbd827814acd986645b789c6b9..83feb595bce51ed42c2a2afba13c28f7ee9122ba 100644 (file)
@@ -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.
index e8eb4abaa40c9f930b9255e5fc4f224bd032ba8f..5b893505b34d2aac1a14488de4d6e45d0f3186d1 100644 (file)
 ///            println!("{}", elapsed.as_secs());
 ///        }
 ///        Err(e) => {
-///            // an error occured!
+///            // an error occurred!
 ///            println!("Error: {:?}", e);
 ///        }
 ///    }
index 7b2a31b5705780cd2f085ed692727069ceb8cdb7..801343689b728f37f93700d16d979a45fd14ea7e 100644 (file)
@@ -345,9 +345,6 @@ pub fn new() -> 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)),
 
@@ -457,6 +454,8 @@ pub fn new() -> 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
index 19238c30670cc10f2d7ad29ecdbb810dfa3f1ce0..37a59411c16185fc7bc996c550ba04e546c159cc 100644 (file)
@@ -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
index 674facd05fdc0bab34ed6a21282ff54e2b52bd72..a0dd2975ca0c63f2aea9e8a0d16a28004f025410 100644 (file)
@@ -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:
 //!
index fbb3824cd4060089081cc91475581b5229c84658..f7514df800d99d0895e0d9d7ce58ce36c2e9f60f 100644 (file)
 // 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/feature-gate-rvalue_static_promotion.rs b/src/test/compile-fail/feature-gate-rvalue_static_promotion.rs
deleted file mode 100644 (file)
index f33d0a7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[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
-}
index 333ff7118d45b4b2b7d33275341cdd6d95a6a33d..3045c06ca4c18e9e428fcba772a535235fb0ce0f 100644 (file)
@@ -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
 }
index 45bc5ee07a527f9ed2e6d59bd98f43e4fd71c531..9264305e6ea5c55eb13263148d00cdcd520ed32b 100644 (file)
 
 #![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() {}
index db56d2c6cf3c66a67579c1eaa3e0fb6d8c65f853..9b7ed463499ded297d51d51eafe702561a5321d5 100644 (file)
@@ -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() {
index ccf5eabc1110d473e427e8609840850d9c50dd69..731d4fb2bf693ea2f1cccda229569f21aa19fc89 100644 (file)
@@ -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 @@ fn write_str(&mut self, _s: &str) -> ::std::fmt::Result {
 }
 
 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
 }
index 9c985839c4d9aa8ac5d0dd52043c03fcefff0357..46c486c63a35e87f8c9f362f23c9f2b5c08daef8 100644 (file)
@@ -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
 }
 
index 61c98d69d808f61acbcc923fd0c50150fde89b57..c7cd3ced98d2397c23da9e76259916b6ea3e5a18 100644 (file)
@@ -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() {
index 8955a26de0b93c085014b1bea5ae070d1589fc9a..031091c45234a872738a21c7c24e7a8387a2f88f 100644 (file)
@@ -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);
     }
 }
index 460154f25d7fcb5354b27b7a32b717cc279f4751..8d9f442b81d948ad58bcf17f733755bed4c290fe 100644 (file)
@@ -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 @@ fn next(&mut self) -> Option<&'static str> {
 }
 
 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
     }
 }
 
index eca22bfdda07a8a1579af54dd3cb380d5d450c6d..90ed401659c87b7f9b777f24a62e327eb9ba23f6 100644 (file)
 
 #![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);
 }
index 30643cfc3eb7d5b5c2527b847aaf3d6991d0e35e..e57491930a45b74bd1c563e8eb091cb2ba4adfec 100644 (file)
@@ -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/rustdoc/issue-43869.rs b/src/test/rustdoc/issue-43869.rs
new file mode 100644 (file)
index 0000000..2d18e4b
--- /dev/null
@@ -0,0 +1,32 @@
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(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
index 8a55c9989e18c1b9d9cb358e194ee4bda7085fe7..5d1436979082379bc4a2453bf36a76cdba05df96 100644 (file)
@@ -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
    |
index eeafaab44c62007efc8ba12c1114f1d50e9d00fb..1c904648f9e7b9827edb922dc8b7ce0b9663c4d4 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn f() {
-    let x = [1].iter();
+    let x = vec![1].iter();
 }
 
 fn main() {
index d1ba92465886e360d8f868e5a235a728d0e402c0..6316c06666003ca42b7c2d328166ad51ddef4fb5 100644 (file)
@@ -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
 
index 1206d7166726451ea5725ee4a8777e21e5a62532..9e316b989a4752284ae065a3b309ec056447afcc 100644 (file)
@@ -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
index 6ed1b7c26225e31019507ab31ea74838b6b5d6f5..86c6f28ef1c873f70e4f2629739580bc0e5c6b76 100644 (file)
@@ -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
index ea5f4d3fe60e3c8bee319374237d227dadca0ea3..871e0af50bfc6cad967347b1c496a7732353ee45 100644 (file)
@@ -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 {
index ce1c6e81b960fe148a067fe225d36c600afb112b..7f4ca19241cd2f0a53df527dd440c5c5e226f6ab 100644 (file)
@@ -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
index ff62adbfbd5fcc20cb54569979ee59e24607954d..08ec2a87fcdc4cfc584c54d22e9799d261e1fbf5 100644 (file)
@@ -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
    |
index a524562f2d959b3f0b346a3077dc2c898ba2f918..99b0d6ed2964c10eccc696fcde8e955226da5512 100644 (file)
@@ -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>;
     }
 }
index e671f1daf61da1163c9e393b1513345f7b5f1fd1..6a3625441b49edbf0058462ddae91e4d48e69e1f 100644 (file)
@@ -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
index 4ca0ccaa731d8f30b62abd9332560fe615c294cf..1b022f23246628d56f27037501a2c37c6f5c0192 100644 (file)
@@ -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..];
     }
 }
index b60ccd0fbf348d6dd033d8467966637d66fa449a..5e8edf80df69eedae6978811efa22de797d0d9c6 100644 (file)
@@ -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