]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #106121 - RalfJung:miri, r=RalfJung
authorbors <bors@rust-lang.org>
Sun, 25 Dec 2022 17:39:06 +0000 (17:39 +0000)
committerbors <bors@rust-lang.org>
Sun, 25 Dec 2022 17:39:06 +0000 (17:39 +0000)
update Miri

Noteworthy PRs:
- https://github.com/rust-lang/miri/pull/2357
- https://github.com/rust-lang/miri/pull/2646
- https://github.com/rust-lang/miri/pull/2718
- https://github.com/rust-lang/miri/pull/2721
- https://github.com/rust-lang/miri/pull/2725

51 files changed:
CONTRIBUTING.md
README.md
compiler/rustc_ast/src/token.rs
compiler/rustc_const_eval/src/transform/promote_consts.rs
compiler/rustc_data_structures/src/stable_hasher.rs
compiler/rustc_hir_analysis/src/astconv/mod.rs
compiler/rustc_hir_typeck/src/demand.rs
compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
compiler/rustc_hir_typeck/src/pat.rs
compiler/rustc_lint_defs/src/builtin.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_parse/src/parser/expr.rs
compiler/rustc_target/src/spec/mod.rs
library/alloc/tests/vec.rs
library/core/src/char/decode.rs
library/core/src/ptr/mod.rs
library/core/tests/char.rs
library/std/src/sys/unix/fs.rs
library/std/src/sys/unix/kernel_copy.rs
library/std/src/sys/unix/mod.rs
library/std/src/sys/unix/stack_overflow.rs
library/std/src/sys/unix/thread.rs
src/bootstrap/README.md
src/bootstrap/config.rs
src/librustdoc/html/static/css/rustdoc.css
src/librustdoc/html/static/css/themes/ayu.css
src/librustdoc/html/static/css/themes/dark.css
src/librustdoc/html/static/css/themes/light.css
src/test/codegen/comparison-operators-newtype.rs [new file with mode: 0644]
src/test/rustdoc-gui/docblock-code-block-line-number.goml
src/test/rustdoc-gui/scrape-examples-toggle.goml
src/test/rustdoc-gui/source-code-page.goml
src/test/ui/consts/promoted_const_call.rs [new file with mode: 0644]
src/test/ui/consts/promoted_const_call.stderr [new file with mode: 0644]
src/test/ui/consts/promoted_const_call2.rs [new file with mode: 0644]
src/test/ui/consts/promoted_const_call2.stderr [new file with mode: 0644]
src/test/ui/consts/promoted_const_call3.rs [new file with mode: 0644]
src/test/ui/consts/promoted_const_call3.stderr [new file with mode: 0644]
src/test/ui/consts/promoted_const_call4.rs [new file with mode: 0644]
src/test/ui/consts/promoted_const_call5.rs [new file with mode: 0644]
src/test/ui/consts/promoted_const_call5.stderr [new file with mode: 0644]
src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.fixed [deleted file]
src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.rs [deleted file]
src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.stderr [deleted file]
src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.fixed [new file with mode: 0644]
src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.rs [new file with mode: 0644]
src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.stderr [new file with mode: 0644]
src/test/ui/parser/issue-105634.rs [new file with mode: 0644]
src/test/ui/suggestions/issue-105494.rs [new file with mode: 0644]
src/test/ui/suggestions/issue-105494.stderr [new file with mode: 0644]
src/tools/compiletest/src/runtest.rs

index 223fd0065bf4a0cd78ba6847a3ec694f3e0da5eb..d732075fb2d07fb84f1873ac7221f64f52a47947 100644 (file)
@@ -8,9 +8,9 @@ members](https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members)
 Zulip stream. We have lots of docs below of how to get started on your own, but
 the Zulip stream is the best place to *ask* for help.
 
-Documentation for contributing to Rust is located in the [Guide to Rustc Development](https://rustc-dev-guide.rust-lang.org/),
-commonly known as the [rustc-dev-guide]. Despite the name, this guide documents
-not just how to develop rustc (the Rust compiler), but also how to contribute to the standard library and rustdoc.
+Documentation for contributing to the compiler or tooling is located in the [Guide to Rustc
+Development][rustc-dev-guide], commonly known as the [rustc-dev-guide]. Documentation for the
+standard library in the [Standard library developers Guide][std-dev-guide], commonly known as the [std-dev-guide].
 
 ## About the [rustc-dev-guide]
 
@@ -35,6 +35,7 @@ refer to [this section][contributing-bug-reports] and [open an issue][issue temp
 
 [Contributing to Rust]: https://rustc-dev-guide.rust-lang.org/contributing.html#contributing-to-rust
 [rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/
+[std-dev-guide]: https://std-dev-guide.rust-lang.org/
 [contributing-bug-reports]: https://rustc-dev-guide.rust-lang.org/contributing.html#bug-reports
 [issue template]: https://github.com/rust-lang/rust/issues/new/choose
 [internals]: https://internals.rust-lang.org
index 27e7145c5a99e4afadff029b4685473f0423ac5f..2b7edf2c3c90758a298267b15228246dc280fab0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,12 +5,8 @@ standard library, and documentation.
 
 [Rust]: https://www.rust-lang.org
 
-**Note: this README is for _users_ rather than _contributors_.
-If you wish to _contribute_ to the compiler, you should read the
-[Getting Started][gettingstarted] section of the rustc-dev-guide instead.
-You can ask for help in the [#new members Zulip stream][new-members].**
-
-[new-members]: https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members
+**Note: this README is for _users_ rather than _contributors_.**
+If you wish to _contribute_ to the compiler, you should read [CONTRIBUTING.md](CONTRIBUTING.md) instead.
 
 ## Quick Start
 
@@ -48,20 +44,37 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide
 [gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html
 [rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
 
-### Building on a Unix-like system
-1. Make sure you have installed the dependencies:
+### Dependencies
+
+Make sure you have installed the dependencies:
 
-   * `g++` 5.1 or later or `clang++` 3.5 or later
    * `python` 3 or 2.7
-   * GNU `make` 3.81 or later
-   * `cmake` 3.13.4 or later
-   * `ninja`
-   * `curl`
    * `git`
-   * `ssl` which comes in `libssl-dev` or `openssl-devel`
+   * A C compiler (when building for the host, `cc` is enough; cross-compiling may need additional compilers)
+   * `curl` (not needed on Windows)
    * `pkg-config` if you are compiling on Linux and targeting Linux
+   * `libiconv` (already included with glibc on Debian-based distros)
+
+To build cargo, you'll also need OpenSSL (`libssl-dev` or `openssl-devel` on most Unix distros).
+
+If building LLVM from source, you'll need additional tools:
+
+* `g++`, `clang++`, or MSVC with versions listed on
+  [LLVM's documentation](https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library)
+* `ninja`, or GNU `make` 3.81 or later (ninja is recommended, especially on Windows)
+* `cmake` 3.13.4 or later
+* `libstdc++-static` may be required on some Linux distributions such as Fedora and Ubuntu
 
-2. Clone the [source] with `git`:
+On tier 1 or tier 2 with host tools platforms, you can also choose to download LLVM by setting `llvm.download-ci-llvm = true`.
+Otherwise, you'll need LLVM installed and `llvm-config` in your path.
+See [the rustc-dev-guide for more info][sysllvm].
+
+[sysllvm]: https://rustc-dev-guide.rust-lang.org/building/new-target.html#using-pre-built-llvm
+
+
+### Building on a Unix-like system
+
+1. Clone the [source] with `git`:
 
    ```sh
    git clone https://github.com/rust-lang/rust.git
@@ -70,22 +83,21 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide
 
 [source]: https://github.com/rust-lang/rust
 
-3. Configure the build settings:
+2. Configure the build settings:
 
     The Rust build system uses a file named `config.toml` in the root of the
     source tree to determine various configuration settings for the build.
-    Copy the default `config.toml.example` to `config.toml` to get started.
+    Set up the defaults intended for distros to get started. You can see a full list of options
+    in `config.toml.example`.
 
     ```sh
-    cp config.toml.example config.toml
+    printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml
     ```
 
     If you plan to use `x.py install` to create an installation, it is recommended
     that you set the `prefix` value in the `[install]` section to a directory.
 
-    Create an install directory if you are not installing in the default directory.
-
-4. Build and install:
+3. Build and install:
 
     ```sh
     ./x.py build && ./x.py install
@@ -93,15 +105,27 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide
 
     When complete, `./x.py install` will place several programs into
     `$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
-    API-documentation tool. This install does not include [Cargo],
-    Rust's package manager. To build and install Cargo, you may
-    run `./x.py install cargo` or set the `build.extended` key in
-    `config.toml` to `true` to build and install all tools.
+    API-documentation tool. If you've set `profile = "user"` or `build.extended = true`, it will
+    also include [Cargo], Rust's package manager.
 
 [Cargo]: https://github.com/rust-lang/cargo
 
 ### Building on Windows
 
+On Windows, we suggest using [winget] to install dependencies by running the following in a terminal:
+
+```powershell
+winget install -e Python.Python.3
+winget install -e Kitware.CMake
+winget install -e Git.Git
+```
+
+Then edit your system's `PATH` variable and add: `C:\Program Files\CMake\bin`. See
+[this guide on editing the system `PATH`](https://www.java.com/en/download/help/path.html) from the
+Java documentation.
+
+[winget]: https://github.com/microsoft/winget-cli
+
 There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by
 Visual Studio and the GNU ABI used by the GCC toolchain. Which version of Rust
 you need depends largely on what C/C++ libraries you want to interoperate with.
@@ -190,7 +214,7 @@ Windows build triples are:
     - `x86_64-pc-windows-msvc`
 
 The build triple can be specified by either specifying `--build=<triple>` when
-invoking `x.py` commands, or by copying the `config.toml` file (as described
+invoking `x.py` commands, or by creating a `config.toml` file (as described
 in [Installing From Source](#installing-from-source)), and modifying the
 `build` option under the `[build]` section.
 
@@ -204,9 +228,7 @@ configure script and makefile (the latter of which just invokes `x.py`).
 make && sudo make install
 ```
 
-When using the configure script, the generated `config.mk` file may override the
-`config.toml` file. To go back to the `config.toml` file, delete the generated
-`config.mk` file.
+`configure` generates a `config.toml` which can also be used with normal `x.py` invocations.
 
 ## Building Documentation
 
@@ -227,41 +249,20 @@ precompiled "snapshot" version of itself (made in an earlier stage of
 development). As such, source builds require an Internet connection to
 fetch snapshots, and an OS that can execute the available snapshot binaries.
 
-Snapshot binaries are currently built and tested on several platforms:
-
-| Platform / Architecture                     | x86 | x86_64 |
-|---------------------------------------------|-----|--------|
-| Windows (7, 8, 10, ...)                     | ✓   | ✓      |
-| Linux (kernel 3.2, glibc 2.17 or later)     | ✓   | ✓      |
-| macOS (10.7 Lion or later)                  | (\*) | ✓      |
-
-(\*): Apple dropped support for running 32-bit binaries starting from macOS 10.15 and iOS 11.
-Due to this decision from Apple, the targets are no longer useful to our users.
-Please read [our blog post][macx32] for more info.
-
-[macx32]: https://blog.rust-lang.org/2020/01/03/reducing-support-for-32-bit-apple-targets.html
+See https://doc.rust-lang.org/nightly/rustc/platform-support.html for a list of supported platforms.
+Only "host tools" platforms have a pre-compiled snapshot binary available; to compile for a platform
+without host tools you must cross-compile.
 
 You may find that other platforms work, but these are our officially
 supported build environments that are most likely to work.
 
 ## Getting Help
 
-The Rust community congregates in a few places:
-
-* [Stack Overflow] - Direct questions about using the language.
-* [users.rust-lang.org] - General discussion and broader questions.
-* [/r/rust] - News and general discussion.
-
-[Stack Overflow]: https://stackoverflow.com/questions/tagged/rust
-[/r/rust]: https://reddit.com/r/rust
-[users.rust-lang.org]: https://users.rust-lang.org/
+See https://www.rust-lang.org/community for a list of chat platforms and forums.
 
 ## Contributing
 
-If you are interested in contributing to the Rust project, please take a look
-at the [Getting Started][gettingstarted] guide in the [rustc-dev-guide].
-
-[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org
+See [CONTRIBUTING.md](CONTRIBUTING.md).
 
 ## License
 
index 7b8c0d79a17e8519f3fc79a3f65149db2f2537dc..5b6cf30fa96e37f416ba2edcf8cc1545d4731118 100644 (file)
@@ -379,6 +379,10 @@ pub fn uninterpolated_span(&self) -> Span {
         }
     }
 
+    pub fn is_range_separator(&self) -> bool {
+        [DotDot, DotDotDot, DotDotEq].contains(&self.kind)
+    }
+
     pub fn is_op(&self) -> bool {
         match self.kind {
             Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)
index 6777fae74f1ca5d00018354072ef0ef5c15e62c3..04ce701452b90de0c346efd4b8c8250f0e6d76f9 100644 (file)
@@ -216,12 +216,6 @@ fn validate_candidate(&mut self, candidate: Candidate) -> Result<(), Unpromotabl
                     return Err(Unpromotable);
                 }
 
-                // We cannot promote things that need dropping, since the promoted value
-                // would not get dropped.
-                if self.qualif_local::<qualifs::NeedsDrop>(place.local) {
-                    return Err(Unpromotable);
-                }
-
                 Ok(())
             }
             _ => bug!(),
@@ -262,13 +256,17 @@ fn qualif_local<Q: qualifs::Qualif>(&mut self, local: Local) -> bool {
                 }
             }
         } else {
-            let span = self.body.local_decls[local].source_info.span;
-            span_bug!(span, "{:?} not promotable, qualif_local shouldn't have been called", local);
+            false
         }
     }
 
     fn validate_local(&mut self, local: Local) -> Result<(), Unpromotable> {
         if let TempState::Defined { location: loc, uses, valid } = self.temps[local] {
+            // We cannot promote things that need dropping, since the promoted value
+            // would not get dropped.
+            if self.qualif_local::<qualifs::NeedsDrop>(local) {
+                return Err(Unpromotable);
+            }
             valid.or_else(|_| {
                 let ok = {
                     let block = &self.body[loc.block];
index 1a728f82f006fa33a92597defccda7ac8e441431..ae4836645fa41311215aaa39166c4c439766709e 100644 (file)
@@ -223,7 +223,7 @@ pub trait ToStableHashKey<HCX> {
 /// stable across compilation session boundaries. More formally:
 ///
 /// ```txt
-/// Ord::cmp(a1, b1) == Ord:cmp(a2, b2)
+/// Ord::cmp(a1, b1) == Ord::cmp(a2, b2)
 ///    where a2 = decode(encode(a1, context1), context2)
 ///          b2 = decode(encode(b1, context1), context2)
 /// ```
index c29a3afd7fba876896d006e2b0fb45407d1a3f8c..6f0c5d36a5f539c63e6365e493d51c846c5171c2 100644 (file)
@@ -2626,7 +2626,7 @@ pub fn res_to_ty(
                 let e = self
                     .tcx()
                     .sess
-                    .delay_span_bug(path.span, "path with `Res:Err` but no error emitted");
+                    .delay_span_bug(path.span, "path with `Res::Err` but no error emitted");
                 self.set_tainted_by_errors(e);
                 self.tcx().ty_error_with_guaranteed(e)
             }
index e68bd1297c87865d58574f933ec4b5e138d885ad..042ff0b46a5afbc6bd31205d2600a732d9c002c0 100644 (file)
@@ -38,6 +38,7 @@ pub fn emit_type_mismatch_suggestions(
 
         // Use `||` to give these suggestions a precedence
         let _ = self.suggest_missing_parentheses(err, expr)
+            || self.suggest_remove_last_method_call(err, expr, expected)
             || self.suggest_associated_const(err, expr, expected)
             || self.suggest_deref_ref_or_into(err, expr, expected, expr_ty, expected_ty_expr)
             || self.suggest_option_to_bool(err, expr, expr_ty, expected)
index efec0244633340e6947783902d2b1db102ba1bea..9a7d753e66b8eafd8f60edbecae8e88f2ab8a2f2 100644 (file)
@@ -329,6 +329,31 @@ pub fn suggest_two_fn_call(
         }
     }
 
+    pub fn suggest_remove_last_method_call(
+        &self,
+        err: &mut Diagnostic,
+        expr: &hir::Expr<'tcx>,
+        expected: Ty<'tcx>,
+    ) -> bool {
+        if let hir::ExprKind::MethodCall(hir::PathSegment { ident: method, .. }, recv_expr, &[], _) = expr.kind &&
+            let Some(recv_ty) = self.typeck_results.borrow().expr_ty_opt(recv_expr) &&
+            self.can_coerce(recv_ty, expected) {
+                let span = if let Some(recv_span) = recv_expr.span.find_ancestor_inside(expr.span) {
+                    expr.span.with_lo(recv_span.hi())
+                } else {
+                    expr.span.with_lo(method.span.lo() - rustc_span::BytePos(1))
+                };
+                err.span_suggestion_verbose(
+                    span,
+                    "try removing the method call",
+                    "",
+                    Applicability::MachineApplicable,
+                );
+                return true;
+            }
+        false
+    }
+
     pub fn suggest_deref_ref_or_into(
         &self,
         err: &mut Diagnostic,
index d3e88b1b80ae29a30aec1856320059b54bdbf793..0021fdd7f61a9f9200aa7e8cb29a536b97a16f2e 100644 (file)
@@ -1013,7 +1013,7 @@ fn check_pat_tuple_struct(
         let (res, opt_ty, segments) =
             self.resolve_ty_and_res_fully_qualified_call(qpath, pat.hir_id, pat.span);
         if res == Res::Err {
-            let e = tcx.sess.delay_span_bug(pat.span, "`Res:Err` but no error emitted");
+            let e = tcx.sess.delay_span_bug(pat.span, "`Res::Err` but no error emitted");
             self.set_tainted_by_errors(e);
             on_error(e);
             return tcx.ty_error_with_guaranteed(e);
index 67868ded0b86b5b4c9de2442bfc2a75515fee6a0..28317d6cea02a599a0a0cddf1a164911eba33332 100644 (file)
     /// fn main() {
     ///     let x: String = "3".try_into().unwrap();
     ///     //                  ^^^^^^^^
-    ///     // This call to try_into matches both Foo:try_into and TryInto::try_into as
+    ///     // This call to try_into matches both Foo::try_into and TryInto::try_into as
     ///     // `TryInto` has been added to the Rust prelude in 2021 edition.
     ///     println!("{x}");
     /// }
index d5d31bc3edc97af6572079812df5d2a68ad14f1b..be4a0c9bb34d2a22b5c92247574c1908845bb012 100644 (file)
@@ -76,7 +76,7 @@ pub(super) struct EncodeContext<'a, 'tcx> {
     symbol_table: FxHashMap<Symbol, usize>,
 }
 
-/// If the current crate is a proc-macro, returns early with `Lazy:empty()`.
+/// If the current crate is a proc-macro, returns early with `LazyArray::empty()`.
 /// This is useful for skipping the encoding of things that aren't needed
 /// for proc-macro crates.
 macro_rules! empty_proc_macro {
index c0ed450b98508e07beed81f05c23030695d232c5..6a115088eca61803496212c69e4614b90cec6c31 100644 (file)
@@ -182,7 +182,7 @@ pub(super) fn parse_assoc_expr_with(
                 LhsExpr::AttributesParsed(attrs) => Some(attrs),
                 _ => None,
             };
-            if [token::DotDot, token::DotDotDot, token::DotDotEq].contains(&self.token.kind) {
+            if self.token.is_range_separator() {
                 return self.parse_prefix_range_expr(attrs);
             } else {
                 self.parse_prefix_expr(attrs)?
@@ -514,7 +514,7 @@ fn parse_prefix_range_expr(&mut self, attrs: Option<AttrWrapper>) -> PResult<'a,
         }
 
         debug_assert!(
-            [token::DotDot, token::DotDotDot, token::DotDotEq].contains(&self.token.kind),
+            self.token.is_range_separator(),
             "parse_prefix_range_expr: token {:?} is not DotDot/DotDotEq",
             self.token
         );
@@ -899,7 +899,11 @@ fn parse_borrow_expr(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> {
         let has_lifetime = self.token.is_lifetime() && self.look_ahead(1, |t| t != &token::Colon);
         let lifetime = has_lifetime.then(|| self.expect_lifetime()); // For recovery, see below.
         let (borrow_kind, mutbl) = self.parse_borrow_modifiers(lo);
-        let expr = self.parse_prefix_expr(None);
+        let expr = if self.token.is_range_separator() {
+            self.parse_prefix_range_expr(None)
+        } else {
+            self.parse_prefix_expr(None)
+        };
         let (hi, expr) = self.interpolated_or_expr_span(expr)?;
         let span = lo.to(hi);
         if let Some(lt) = lifetime {
index 988cd401f406bff9f66d02a6d55895afde9a5e21..4512db49403d73602628c40dd6469c99cc58ae25 100644 (file)
@@ -2291,7 +2291,7 @@ macro_rules! key {
                     } else {
                         return Some(Err(format!(
                             "'{}' is not a valid value for lld-flavor. \
-                             Use 'darwin', 'gnu', 'link' or 'wasm.",
+                             Use 'darwin', 'gnu', 'link' or 'wasm'.",
                             s)))
                     }
                     Some(Ok(()))
index 7ebed0d5ca6994085d63c3ce2631e9c6d3cbd85d..87adcead8f62d69ba7dbcdcb4c5f331aa276b414 100644 (file)
@@ -7,7 +7,9 @@
 use std::cell::Cell;
 use std::collections::TryReserveErrorKind::*;
 use std::fmt::Debug;
+use std::hint;
 use std::iter::InPlaceIterable;
+use std::mem;
 use std::mem::{size_of, swap};
 use std::ops::Bound::*;
 use std::panic::{catch_unwind, AssertUnwindSafe};
@@ -1107,8 +1109,31 @@ unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
 
 #[test]
 fn test_into_iter_zst() {
-    for _ in vec![[0u64; 0]].into_iter() {}
-    for _ in vec![[0u64; 0]; 5].into_iter().rev() {}
+    #[derive(Debug, Clone)]
+    struct AlignedZstWithDrop([u64; 0]);
+    impl Drop for AlignedZstWithDrop {
+        fn drop(&mut self) {
+            let addr = self as *mut _ as usize;
+            assert!(hint::black_box(addr) % mem::align_of::<u64>() == 0);
+        }
+    }
+
+    const C: AlignedZstWithDrop = AlignedZstWithDrop([0u64; 0]);
+
+    for _ in vec![C].into_iter() {}
+    for _ in vec![C; 5].into_iter().rev() {}
+
+    let mut it = vec![C, C].into_iter();
+    it.advance_by(1).unwrap();
+    drop(it);
+
+    let mut it = vec![C, C].into_iter();
+    it.next_chunk::<1>().unwrap();
+    drop(it);
+
+    let mut it = vec![C, C].into_iter();
+    it.next_chunk::<4>().unwrap_err();
+    drop(it);
 }
 
 #[test]
index 11f1c30f6d55979752622d066b917c7356ef596f..eeb08803040879e86838543411d0f6bd2fcb2fca 100644 (file)
@@ -67,7 +67,7 @@ fn next(&mut self) -> Option<Result<char, DecodeUtf16Error>> {
             }
 
             // all ok, so lets decode it.
-            let c = (((u - 0xD800) as u32) << 10 | (u2 - 0xDC00) as u32) + 0x1_0000;
+            let c = (((u & 0x3ff) as u32) << 10 | (u2 & 0x3ff) as u32) + 0x1_0000;
             // SAFETY: we checked that it's a legal unicode value
             Some(Ok(unsafe { from_u32_unchecked(c) }))
         }
index 48b2e88da28413d0e96c45f7ed9f9e974f046076..5f30029eaa07d5c8d9be41bd6a6f221e13b0b43e 100644 (file)
@@ -516,6 +516,27 @@ pub const fn null<T: ?Sized + Thin>() -> *const T {
     from_raw_parts(invalid(0), ())
 }
 
+/// Creates a null mutable raw pointer.
+///
+/// # Examples
+///
+/// ```
+/// use std::ptr;
+///
+/// let p: *mut i32 = ptr::null_mut();
+/// assert!(p.is_null());
+/// ```
+#[inline(always)]
+#[must_use]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[rustc_promotable]
+#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
+#[rustc_allow_const_fn_unstable(ptr_metadata)]
+#[rustc_diagnostic_item = "ptr_null_mut"]
+pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
+    from_raw_parts_mut(invalid_mut(0), ())
+}
+
 /// Creates an invalid pointer with the given address.
 ///
 /// This is different from `addr as *const T`, which creates a pointer that picks up a previously
@@ -663,25 +684,26 @@ pub fn from_exposed_addr_mut<T>(addr: usize) -> *mut T
     addr as *mut T
 }
 
-/// Creates a null mutable raw pointer.
+/// Convert a reference to a raw pointer.
 ///
-/// # Examples
-///
-/// ```
-/// use std::ptr;
+/// This is equivalent to `r as *const T`, but is a bit safer since it will never silently change
+/// type or mutability, in particular if the code is refactored.
+#[inline(always)]
+#[must_use]
+#[unstable(feature = "ptr_from_ref", issue = "106116")]
+pub fn from_ref<T: ?Sized>(r: &T) -> *const T {
+    r
+}
+
+/// Convert a mutable reference to a raw pointer.
 ///
-/// let p: *mut i32 = ptr::null_mut();
-/// assert!(p.is_null());
-/// ```
+/// This is equivalent to `r as *mut T`, but is a bit safer since it will never silently change
+/// type or mutability, in particular if the code is refactored.
 #[inline(always)]
 #[must_use]
-#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_promotable]
-#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
-#[rustc_allow_const_fn_unstable(ptr_metadata)]
-#[rustc_diagnostic_item = "ptr_null_mut"]
-pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
-    from_raw_parts_mut(invalid_mut(0), ())
+#[unstable(feature = "ptr_from_ref", issue = "106116")]
+pub fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
+    r
 }
 
 /// Forms a raw slice from a pointer and a length.
index 8542e5c70d40c00241e0045971d1afcd97dc4290..ac0b2ca168b237133727fcfccab3470844cf4563 100644 (file)
@@ -306,6 +306,10 @@ fn check(s: &[u16], expected: &[Result<char, u16>]) {
     }
     check(&[0xD800, 0x41, 0x42], &[Err(0xD800), Ok('A'), Ok('B')]);
     check(&[0xD800, 0], &[Err(0xD800), Ok('\0')]);
+    check(&[0xD800], &[Err(0xD800)]);
+    check(&[0xD840, 0xDC00], &[Ok('\u{20000}')]);
+    check(&[0xD840, 0xD840, 0xDC00], &[Err(0xD840), Ok('\u{20000}')]);
+    check(&[0xDC00, 0xD840], &[Err(0xDC00), Err(0xD840)]);
 }
 
 #[test]
index d5f50d77911fcafe3ef883f4f85cf3d808d3e223..aea0c26ee8b60e8a2045208b6228a0dc5812d7b5 100644 (file)
@@ -1754,11 +1754,11 @@ mod remove_dir_impl {
     use crate::sys::{cvt, cvt_r};
 
     #[cfg(not(any(
-        target_os = "linux",
+        all(target_os = "linux", target_env = "gnu"),
         all(target_os = "macos", not(target_arch = "aarch64"))
     )))]
     use libc::{fdopendir, openat, unlinkat};
-    #[cfg(target_os = "linux")]
+    #[cfg(all(target_os = "linux", target_env = "gnu"))]
     use libc::{fdopendir, openat64 as openat, unlinkat};
     #[cfg(all(target_os = "macos", not(target_arch = "aarch64")))]
     use macos_weak::{fdopendir, openat, unlinkat};
index 6fa85e859c05b303495ac8e2d808832a13fd0e5b..0f7107122b7e86ecbba33e56b46efcd52ef2fcbc 100644 (file)
@@ -61,9 +61,9 @@
 use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
 use crate::sys::cvt;
 use crate::sys::weak::syscall;
-#[cfg(not(target_os = "linux"))]
+#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
 use libc::sendfile as sendfile64;
-#[cfg(target_os = "linux")]
+#[cfg(all(target_os = "linux", target_env = "gnu"))]
 use libc::sendfile64;
 use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
 
index 3d60941e84e393c0a7fac39d1fb70f736ed448db..83a43b6ee2697ca14c6e8e75c8d3b4788c32cd59 100644 (file)
@@ -95,9 +95,9 @@ unsafe fn sanitize_standard_fds() {
         )))]
         'poll: {
             use crate::sys::os::errno;
-            #[cfg(not(target_os = "linux"))]
+            #[cfg(not(all(target_os = "linux", target_env = "gnu")))]
             use libc::open as open64;
-            #[cfg(target_os = "linux")]
+            #[cfg(all(target_os = "linux", target_env = "gnu"))]
             use libc::open64;
             let pfds: &mut [_] = &mut [
                 libc::pollfd { fd: 0, events: 0, revents: 0 },
@@ -143,9 +143,9 @@ unsafe fn sanitize_standard_fds() {
         )))]
         {
             use crate::sys::os::errno;
-            #[cfg(not(target_os = "linux"))]
+            #[cfg(not(all(target_os = "linux", target_env = "gnu")))]
             use libc::open as open64;
-            #[cfg(target_os = "linux")]
+            #[cfg(all(target_os = "linux", target_env = "gnu"))]
             use libc::open64;
             for fd in 0..3 {
                 if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
index 957e086798fd3cd786acd7f01970f42b813f2231..b59d4ba26afb9b3d4d7259bc85a87f6955564741 100644 (file)
@@ -45,9 +45,9 @@ mod imp {
     use crate::thread;
 
     use libc::MAP_FAILED;
-    #[cfg(not(target_os = "linux"))]
+    #[cfg(not(all(target_os = "linux", target_env = "gnu")))]
     use libc::{mmap as mmap64, munmap};
-    #[cfg(target_os = "linux")]
+    #[cfg(all(target_os = "linux", target_env = "gnu"))]
     use libc::{mmap64, munmap};
     use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIG_DFL};
     use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
index d454a2a717c0639a326555d3dc8b21a60450b1dd..d847f2775ab7611bfcc249c32763179683f0cb04 100644 (file)
@@ -653,9 +653,9 @@ pub unsafe fn init() -> Option<Guard> {
 ))]
 #[cfg_attr(test, allow(dead_code))]
 pub mod guard {
-    #[cfg(not(target_os = "linux"))]
+    #[cfg(not(all(target_os = "linux", target_env = "gnu")))]
     use libc::{mmap as mmap64, mprotect};
-    #[cfg(target_os = "linux")]
+    #[cfg(all(target_os = "linux", target_env = "gnu"))]
     use libc::{mmap64, mprotect};
     use libc::{MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE};
 
index 985727bddc53358756bf41134fcd3ee03775e4d2..79c2eb31cdae07b3fca56104c8d9b806bfc87276 100644 (file)
@@ -80,18 +80,12 @@ The script accepts commands, flags, and arguments to determine what to do:
 
 ## Configuring rustbuild
 
-There are currently two methods for configuring the rustbuild build system.
-
-First, rustbuild offers a TOML-based configuration system with a `config.toml`
+rustbuild offers a TOML-based configuration system with a `config.toml`
 file. An example of this configuration can be found at `config.toml.example`,
 and the configuration file can also be passed as `--config path/to/config.toml`
 if the build system is being invoked manually (via the python script).
 
-Next, the `./configure` options serialized in `config.mk` will be
-parsed and read. That is, if any `./configure` options are passed, they'll be
-handled naturally. `./configure` should almost never be used for local
-installations, and is primarily useful for CI. Prefer to customize behavior
-using `config.toml`.
+You can generate a config.toml using `./configure` options if you want to automate creating the file without having to edit it.
 
 Finally, rustbuild makes use of the [cc-rs crate] which has [its own
 method][env-vars] of configuring C compilers and C flags via environment
index 842785838460f719cb9fa41e8075ac6e65769dc2..b41d60d51a8b5972f75ea63e518d68e461f7df0e 100644 (file)
@@ -49,10 +49,7 @@ pub enum DryRun {
 
 /// Global configuration for the entire build and/or bootstrap.
 ///
-/// This structure is derived from a combination of both `config.toml` and
-/// `config.mk`. As of the time of this writing it's unlikely that `config.toml`
-/// is used all that much, so this is primarily filled out by `config.mk` which
-/// is generated from `./configure`.
+/// This structure is parsed from `config.toml`, and some of the fields are inferred from `git` or build-time parameters.
 ///
 /// Note that this structure is not decoded directly into, but rather it is
 /// filled out from the decoded forms of the structs below. For documentation
index 2b2b148f05e07944a7515c195649ad5e9122a457..5a94abab34a0d3b6ede965907e430594020c40b2 100644 (file)
@@ -347,6 +347,9 @@ pre {
 .source .content pre {
        padding: 20px;
 }
+.rustdoc.source .example-wrap > pre.src-line-numbers  {
+       padding: 20px 0 20px 4px;
+}
 
 img {
        max-width: 100%;
@@ -519,10 +522,6 @@ ul.block, .block li {
        display: none;
 }
 
-.source .content pre.rust {
-       padding-left: 0;
-}
-
 .rustdoc .example-wrap {
        display: flex;
        position: relative;
@@ -550,23 +549,21 @@ ul.block, .block li {
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
+       padding: 14px 8px;
+       color: var(--src-line-numbers-span-color);
 }
 
-.example-line-numbers {
-       border: 1px solid;
-       padding: 13px 8px;
-       border-top-left-radius: 5px;
-       border-bottom-left-radius: 5px;
-       border-color: var(--example-line-numbers-border-color);
+.rustdoc .example-wrap > pre.src-line-numbers {
+       padding: 14px 0;
 }
-
 .src-line-numbers a, .src-line-numbers span {
        color: var(--src-line-numbers-span-color);
+       padding: 0 8px;
 }
 .src-line-numbers :target {
        background-color: transparent;
        border-right: none;
-       padding-right: 0;
+       padding: 0 8px;
 }
 .src-line-numbers .line-highlighted {
        background-color: var(--src-line-number-highlighted-background-color);
@@ -1958,15 +1955,6 @@ in storage.js
        bottom: 0;
 }
 
-.scraped-example .code-wrapper .src-line-numbers {
-       padding: 14px 0;
-}
-
-.scraped-example .code-wrapper .src-line-numbers a,
-.scraped-example .code-wrapper .src-line-numbers span {
-       padding: 0 14px;
-}
-
 .scraped-example .code-wrapper .example-wrap {
        width: 100%;
        overflow-y: hidden;
@@ -2005,6 +1993,11 @@ in storage.js
 .toggle-line-inner {
        min-width: 2px;
        height: 100%;
+       background: var(--scrape-example-toggle-line-background);
+}
+
+.toggle-line:hover .toggle-line-inner {
+       background: var(--scrape-example-toggle-line-hover-background);
 }
 
 .more-scraped-examples .scraped-example, .example-links {
index ce416f77afe903388096c01011716dc71d822829..4ffc25e2688e4d02bb3285cac4febe8edea19694 100644 (file)
@@ -62,7 +62,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
        --code-highlight-question-mark-color: #ff9011;
        --code-highlight-comment-color: #788797;
        --code-highlight-doc-comment-color: #a1ac88;
-       --example-line-numbers-border-color: none;
        --src-line-numbers-span-color: #5c6773;
        --src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06);
        --test-arrow-color: #788797;
@@ -90,6 +89,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
        --source-sidebar-background-hover: #14191f;
        --table-alt-row-background-color: #191f26;
        --codeblock-link-background: #333;
+       --scrape-example-toggle-line-background: #999;
+       --scrape-example-toggle-line-hover-background: #c5c5c5;
 }
 
 h1, h2, h3, h4 {
@@ -132,7 +133,7 @@ pre, .rustdoc.source .example-wrap {
 
 .src-line-numbers .line-highlighted {
        color: #708090;
-       padding-right: 4px;
+       padding-right: 7px;
        border-right: 1px solid #ffb44c;
 }
 
@@ -221,9 +222,3 @@ pre.rust .kw-2, pre.rust .prelude-ty {}
 .scraped-example:not(.expanded) .code-wrapper::after {
        background: linear-gradient(to top, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
 }
-.toggle-line-inner {
-       background: #999;
-}
-.toggle-line:hover .toggle-line-inner {
-       background: #c5c5c5;
-}
index 33d934ff3c31224f9261eb60659640bac0f8a2a2..a7922cdeba1004b07f990843477c168bc8616c5a 100644 (file)
@@ -57,7 +57,6 @@
        --code-highlight-question-mark-color: #ff9011;
        --code-highlight-comment-color: #8d8d8b;
        --code-highlight-doc-comment-color: #8ca375;
-       --example-line-numbers-border-color: #4a4949;
        --src-line-numbers-span-color: #3b91e2;
        --src-line-number-highlighted-background-color: #0a042f;
        --test-arrow-color: #dedede;
@@ -85,6 +84,8 @@
        --source-sidebar-background-hover: #444;
        --table-alt-row-background-color: #2A2A2A;
        --codeblock-link-background: #333;
+       --scrape-example-toggle-line-background: #999;
+       --scrape-example-toggle-line-hover-background: #c5c5c5;
 }
 
 #titles > button:not(.selected) {
 .scraped-example:not(.expanded) .code-wrapper::after {
        background: linear-gradient(to top, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
 }
-.toggle-line-inner {
-       background: #999;
-}
-.toggle-line:hover .toggle-line-inner {
-       background: #c5c5c5;
-}
index 30e91077d33ffce60c5432266f1e7c7a27ec0b4f..aff46f8dc6dff3b1afca88a04818c5fbe0c0cb62 100644 (file)
@@ -57,7 +57,6 @@
        --code-highlight-question-mark-color: #ff9011;
        --code-highlight-comment-color: #8e908c;
        --code-highlight-doc-comment-color: #4d4d4c;
-       --example-line-numbers-border-color: #c7c7c7;
        --src-line-numbers-span-color: #c67e2d;
        --src-line-number-highlighted-background-color: #fdffd3;
        --test-arrow-color: #f5f5f5;
@@ -82,6 +81,8 @@
        --source-sidebar-background-hover: #e0e0e0;
        --table-alt-row-background-color: #F5F5F5;
        --codeblock-link-background: #eee;
+       --scrape-example-toggle-line-background: #ccc;
+       --scrape-example-toggle-line-hover-background: #999;
 }
 
 #titles > button:not(.selected) {
 .scraped-example:not(.expanded) .code-wrapper::after {
        background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
 }
-.toggle-line-inner {
-       background: #ccc;
-}
-.toggle-line:hover .toggle-line-inner {
-       background: #999;
-}
diff --git a/src/test/codegen/comparison-operators-newtype.rs b/src/test/codegen/comparison-operators-newtype.rs
new file mode 100644 (file)
index 0000000..5cf6c3a
--- /dev/null
@@ -0,0 +1,49 @@
+// The `derive(PartialOrd)` for a newtype doesn't override `lt`/`le`/`gt`/`ge`.
+// This double-checks that the `Option<Ordering>` intermediate values used
+// in the operators for such a type all optimize away.
+
+// compile-flags: -C opt-level=1
+// min-llvm-version: 15.0
+
+#![crate_type = "lib"]
+
+use std::cmp::Ordering;
+
+#[derive(PartialOrd, PartialEq)]
+pub struct Foo(u16);
+
+// CHECK-LABEL: @check_lt
+// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
+#[no_mangle]
+pub fn check_lt(a: Foo, b: Foo) -> bool {
+    // CHECK: %[[R:.+]] = icmp ult i16 %[[A]], %[[B]]
+    // CHECK-NEXT: ret i1 %[[R]]
+    a < b
+}
+
+// CHECK-LABEL: @check_le
+// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
+#[no_mangle]
+pub fn check_le(a: Foo, b: Foo) -> bool {
+    // CHECK: %[[R:.+]] = icmp ule i16 %[[A]], %[[B]]
+    // CHECK-NEXT: ret i1 %[[R]]
+    a <= b
+}
+
+// CHECK-LABEL: @check_gt
+// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
+#[no_mangle]
+pub fn check_gt(a: Foo, b: Foo) -> bool {
+    // CHECK: %[[R:.+]] = icmp ugt i16 %[[A]], %[[B]]
+    // CHECK-NEXT: ret i1 %[[R]]
+    a > b
+}
+
+// CHECK-LABEL: @check_ge
+// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
+#[no_mangle]
+pub fn check_ge(a: Foo, b: Foo) -> bool {
+    // CHECK: %[[R:.+]] = icmp uge i16 %[[A]], %[[B]]
+    // CHECK-NEXT: ret i1 %[[R]]
+    a >= b
+}
index b094c483876410365962462bcc910734c8492814..a3ed008719c00237a1cd50d51a74d8ed9ac8da6e 100644 (file)
@@ -1,23 +1,53 @@
 // Checks that the setting "line numbers" is working as expected.
 goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
 
+// Otherwise, we can't check text color
+show-text: true
+
 // We check that without this setting, there is no line number displayed.
 assert-false: "pre.example-line-numbers"
 
-// We now set the setting to show the line numbers on code examples.
-local-storage: {"rustdoc-line-numbers": "true" }
-// We reload to make the line numbers appear.
-reload:
-
-// We wait for them to be added into the DOM by the JS...
-wait-for: "pre.example-line-numbers"
-// If the test didn't fail, it means that it was found!
 // Let's now check some CSS properties...
-assert-css: ("pre.example-line-numbers", {
-    "margin": "0px",
-    "padding": "13px 8px",
-    "text-align": "right",
+define-function: (
+    "check-colors",
+    (theme, color),
+    [
+        // We now set the setting to show the line numbers on code examples.
+        ("local-storage", {
+            "rustdoc-theme": |theme|,
+            "rustdoc-use-system-theme": "false",
+            "rustdoc-line-numbers": "true"
+        }),
+        // We reload to make the line numbers appear and change theme.
+        ("reload"),
+        // We wait for them to be added into the DOM by the JS...
+        ("wait-for", "pre.example-line-numbers"),
+        // If the test didn't fail, it means that it was found!
+        ("assert-css", (
+            "pre.example-line-numbers",
+            {
+                "color": |color|,
+                "margin": "0px",
+                "padding": "14px 8px",
+                "text-align": "right",
+            },
+            ALL,
+        )),
+    ],
+)
+call-function: ("check-colors", {
+    "theme": "ayu",
+    "color": "rgb(92, 103, 115)",
 })
+call-function: ("check-colors", {
+    "theme": "dark",
+    "color": "rgb(59, 145, 226)",
+})
+call-function: ("check-colors", {
+    "theme": "light",
+    "color": "rgb(198, 126, 45)",
+})
+
 // The first code block has two lines so let's check its `<pre>` elements lists both of them.
 assert-text: ("pre.example-line-numbers", "1\n2")
 
index a0b696ee3363d970acd8f59b62f569ec6b882903..8c84fbc0c30568d121d08aa2a289697d7b10c451 100644 (file)
@@ -1,10 +1,46 @@
 // This tests checks that the "scraped examples" toggle is working as expected.
 goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
 
-// Clicking "More examples..." will open additional examples
-assert-attribute-false: (".more-examples-toggle", {"open": ""})
-click: ".more-examples-toggle"
-assert-attribute: (".more-examples-toggle", {"open": ""})
+// Checking the color of the toggle line.
+show-text: true
+define-function: (
+    "check-color",
+    (theme, toggle_line_color, toggle_line_hover_color),
+    [
+        ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
+        ("reload"),
+
+        // Clicking "More examples..." will open additional examples
+        ("assert-attribute-false", (".more-examples-toggle", {"open": ""})),
+        ("click", ".more-examples-toggle"),
+        ("assert-attribute", (".more-examples-toggle", {"open": ""})),
+
+        ("assert-css", (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL)),
+        ("move-cursor-to", ".toggle-line"),
+        ("assert-css", (
+            ".toggle-line:hover .toggle-line-inner",
+            {"background-color": |toggle_line_hover_color|},
+        )),
+        // Moving cursor away from the toggle line to prevent disrupting next test.
+        ("move-cursor-to", ".search-input"),
+    ],
+)
+
+call-function: ("check-color", {
+    "theme": "ayu",
+    "toggle_line_color": "rgb(153, 153, 153)",
+    "toggle_line_hover_color": "rgb(197, 197, 197)",
+})
+call-function: ("check-color", {
+    "theme": "dark",
+    "toggle_line_color": "rgb(153, 153, 153)",
+    "toggle_line_hover_color": "rgb(197, 197, 197)",
+})
+call-function: ("check-color", {
+    "theme": "light",
+    "toggle_line_color": "rgb(204, 204, 204)",
+    "toggle_line_hover_color": "rgb(153, 153, 153)",
+})
 
 // Toggling all docs will close additional examples
 click: "#toggle-all-docs"
index 25da74e5173eba34e77995a5e0ee083e010a8d24..8a33e713191292cebd0082c94858ddf0b12fe3cf 100644 (file)
@@ -89,9 +89,9 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
 // do anything (and certainly not add a `#NaN` to the URL!).
 goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
 // We use this assert-position to know where we will click.
-assert-position: ("//*[@id='1']", {"x": 104, "y": 112})
+assert-position: ("//*[@id='1']", {"x": 88, "y": 112})
 // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
-click: (103, 103)
+click: (87, 103)
 assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
 
 // Checking the source code sidebar.
diff --git a/src/test/ui/consts/promoted_const_call.rs b/src/test/ui/consts/promoted_const_call.rs
new file mode 100644 (file)
index 0000000..30ae730
--- /dev/null
@@ -0,0 +1,19 @@
+#![feature(const_mut_refs)]
+#![feature(const_trait_impl)]
+struct Panic;
+impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
+pub const fn id<T>(x: T) -> T { x }
+pub const C: () = {
+    let _: &'static _ = &id(&Panic);
+    //~^ ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+};
+
+fn main() {
+    let _: &'static _ = &id(&Panic);
+    //~^ ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+    let _: &'static _ = &&(Panic, 0).1;
+    //~^ ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+}
diff --git a/src/test/ui/consts/promoted_const_call.stderr b/src/test/ui/consts/promoted_const_call.stderr
new file mode 100644 (file)
index 0000000..83cc16f
--- /dev/null
@@ -0,0 +1,65 @@
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call.rs:7:26
+   |
+LL |     let _: &'static _ = &id(&Panic);
+   |            ----------    ^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call.rs:7:30
+   |
+LL |     let _: &'static _ = &id(&Panic);
+   |            ----------        ^^^^^ - temporary value is freed at the end of this statement
+   |            |                 |
+   |            |                 creates a temporary value which is freed while still in use
+   |            type annotation requires that borrow lasts for `'static`
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call.rs:13:26
+   |
+LL |     let _: &'static _ = &id(&Panic);
+   |            ----------    ^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call.rs:13:30
+   |
+LL |     let _: &'static _ = &id(&Panic);
+   |            ----------        ^^^^^ - temporary value is freed at the end of this statement
+   |            |                 |
+   |            |                 creates a temporary value which is freed while still in use
+   |            type annotation requires that borrow lasts for `'static`
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call.rs:16:26
+   |
+LL |     let _: &'static _ = &&(Panic, 0).1;
+   |            ----------    ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call.rs:16:27
+   |
+LL |     let _: &'static _ = &&(Panic, 0).1;
+   |            ----------     ^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0716`.
diff --git a/src/test/ui/consts/promoted_const_call2.rs b/src/test/ui/consts/promoted_const_call2.rs
new file mode 100644 (file)
index 0000000..f332cd1
--- /dev/null
@@ -0,0 +1,14 @@
+#![feature(const_precise_live_drops)]
+pub const fn id<T>(x: T) -> T { x }
+pub const C: () = {
+    let _: &'static _ = &id(&String::new());
+    //~^ ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+    //~| ERROR: destructor of `String` cannot be evaluated at compile-time
+};
+
+fn main() {
+    let _: &'static _ = &id(&String::new());
+    //~^ ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+}
diff --git a/src/test/ui/consts/promoted_const_call2.stderr b/src/test/ui/consts/promoted_const_call2.stderr
new file mode 100644 (file)
index 0000000..13d864e
--- /dev/null
@@ -0,0 +1,50 @@
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call2.rs:4:26
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------    ^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call2.rs:4:30
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------        ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
+   |            |                 |
+   |            |                 creates a temporary value which is freed while still in use
+   |            type annotation requires that borrow lasts for `'static`
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call2.rs:11:26
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------    ^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call2.rs:11:30
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------        ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
+   |            |                 |
+   |            |                 creates a temporary value which is freed while still in use
+   |            type annotation requires that borrow lasts for `'static`
+
+error[E0493]: destructor of `String` cannot be evaluated at compile-time
+  --> $DIR/promoted_const_call2.rs:4:30
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |                              ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0493, E0716.
+For more information about an error, try `rustc --explain E0493`.
diff --git a/src/test/ui/consts/promoted_const_call3.rs b/src/test/ui/consts/promoted_const_call3.rs
new file mode 100644 (file)
index 0000000..6d68a2d
--- /dev/null
@@ -0,0 +1,26 @@
+pub const fn id<T>(x: T) -> T { x }
+pub const C: () = {
+    let _: &'static _ = &String::new();
+    //~^ ERROR: destructor of `String` cannot be evaluated at compile-time
+    //~| ERROR: temporary value dropped while borrowed
+
+    let _: &'static _ = &id(&String::new());
+    //~^ ERROR: destructor of `String` cannot be evaluated at compile-time
+    //~| ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+
+    let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
+    //~^ ERROR: temporary value dropped while borrowed
+};
+
+fn main() {
+    let _: &'static _ = &String::new();
+    //~^ ERROR: temporary value dropped while borrowed
+
+    let _: &'static _ = &id(&String::new());
+    //~^ ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+
+    let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
+    //~^ ERROR: temporary value dropped while borrowed
+}
diff --git a/src/test/ui/consts/promoted_const_call3.stderr b/src/test/ui/consts/promoted_const_call3.stderr
new file mode 100644 (file)
index 0000000..af17457
--- /dev/null
@@ -0,0 +1,105 @@
+error[E0493]: destructor of `String` cannot be evaluated at compile-time
+  --> $DIR/promoted_const_call3.rs:7:30
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |                              ^^^^^^^^^^^^^ - value is dropped here
+   |                              |
+   |                              the destructor for this type cannot be evaluated in constants
+
+error[E0493]: destructor of `String` cannot be evaluated at compile-time
+  --> $DIR/promoted_const_call3.rs:3:26
+   |
+LL |     let _: &'static _ = &String::new();
+   |                          ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
+...
+LL | };
+   | - value is dropped here
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:3:26
+   |
+LL |     let _: &'static _ = &String::new();
+   |            ----------    ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:7:26
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------    ^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:7:30
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------        ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
+   |            |                 |
+   |            |                 creates a temporary value which is freed while still in use
+   |            type annotation requires that borrow lasts for `'static`
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:12:26
+   |
+LL |     let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
+   |            ----------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+LL |
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:17:26
+   |
+LL |     let _: &'static _ = &String::new();
+   |            ----------    ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:20:26
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------    ^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:20:30
+   |
+LL |     let _: &'static _ = &id(&String::new());
+   |            ----------        ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
+   |            |                 |
+   |            |                 creates a temporary value which is freed while still in use
+   |            type annotation requires that borrow lasts for `'static`
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call3.rs:24:26
+   |
+LL |     let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
+   |            ----------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+LL |
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error: aborting due to 10 previous errors
+
+Some errors have detailed explanations: E0493, E0716.
+For more information about an error, try `rustc --explain E0493`.
diff --git a/src/test/ui/consts/promoted_const_call4.rs b/src/test/ui/consts/promoted_const_call4.rs
new file mode 100644 (file)
index 0000000..82a17b7
--- /dev/null
@@ -0,0 +1,18 @@
+// run-pass
+
+use std::sync::atomic::*;
+
+static FLAG: AtomicBool = AtomicBool::new(false);
+
+struct NoisyDrop(&'static str);
+impl Drop for NoisyDrop {
+    fn drop(&mut self) {
+        FLAG.store(true, Ordering::SeqCst);
+    }
+}
+fn main() {
+    {
+        let _val = &&(NoisyDrop("drop!"), 0).1;
+    }
+    assert!(FLAG.load(Ordering::SeqCst));
+}
diff --git a/src/test/ui/consts/promoted_const_call5.rs b/src/test/ui/consts/promoted_const_call5.rs
new file mode 100644 (file)
index 0000000..3ac8d35
--- /dev/null
@@ -0,0 +1,42 @@
+#![feature(rustc_attrs)]
+#![feature(staged_api)]
+#![stable(feature = "a", since = "1.0.0")]
+
+#[rustc_promotable]
+#[stable(feature = "a", since = "1.0.0")]
+#[rustc_const_stable(feature = "a", since = "1.0.0")]
+pub const fn id<T>(x: &'static T) -> &'static T { x }
+
+#[rustc_promotable]
+#[stable(feature = "a", since = "1.0.0")]
+#[rustc_const_stable(feature = "a", since = "1.0.0")]
+pub const fn new_string() -> String {
+    String::new()
+}
+
+#[rustc_promotable]
+#[stable(feature = "a", since = "1.0.0")]
+#[rustc_const_stable(feature = "a", since = "1.0.0")]
+pub const fn new_manually_drop<T>(t: T) -> std::mem::ManuallyDrop<T>  {
+    std::mem::ManuallyDrop::new(t)
+}
+
+
+const C: () = {
+    let _: &'static _ = &id(&new_string());
+    //~^ ERROR destructor of `String` cannot be evaluated at compile-time
+    //~| ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+
+    let _: &'static _ = &new_manually_drop(new_string());
+    //~^ ERROR: temporary value dropped while borrowed
+};
+
+fn main() {
+    let _: &'static _ = &id(&new_string());
+    //~^ ERROR: temporary value dropped while borrowed
+    //~| ERROR: temporary value dropped while borrowed
+
+    let _: &'static _ = &new_manually_drop(new_string());
+    //~^ ERROR: temporary value dropped while borrowed
+}
diff --git a/src/test/ui/consts/promoted_const_call5.stderr b/src/test/ui/consts/promoted_const_call5.stderr
new file mode 100644 (file)
index 0000000..f736220
--- /dev/null
@@ -0,0 +1,74 @@
+error[E0493]: destructor of `String` cannot be evaluated at compile-time
+  --> $DIR/promoted_const_call5.rs:26:30
+   |
+LL |     let _: &'static _ = &id(&new_string());
+   |                              ^^^^^^^^^^^^ - value is dropped here
+   |                              |
+   |                              the destructor for this type cannot be evaluated in constants
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call5.rs:26:26
+   |
+LL |     let _: &'static _ = &id(&new_string());
+   |            ----------    ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call5.rs:26:30
+   |
+LL |     let _: &'static _ = &id(&new_string());
+   |                          ----^^^^^^^^^^^^-- temporary value is freed at the end of this statement
+   |                          |   |
+   |                          |   creates a temporary value which is freed while still in use
+   |                          argument requires that borrow lasts for `'static`
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call5.rs:31:26
+   |
+LL |     let _: &'static _ = &new_manually_drop(new_string());
+   |            ----------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+LL |
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call5.rs:36:26
+   |
+LL |     let _: &'static _ = &id(&new_string());
+   |            ----------    ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call5.rs:36:30
+   |
+LL |     let _: &'static _ = &id(&new_string());
+   |                          ----^^^^^^^^^^^^-- temporary value is freed at the end of this statement
+   |                          |   |
+   |                          |   creates a temporary value which is freed while still in use
+   |                          argument requires that borrow lasts for `'static`
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/promoted_const_call5.rs:40:26
+   |
+LL |     let _: &'static _ = &new_manually_drop(new_string());
+   |            ----------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
+   |            |
+   |            type annotation requires that borrow lasts for `'static`
+LL |
+LL | }
+   | - temporary value is freed at the end of this statement
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0493, E0716.
+For more information about an error, try `rustc --explain E0493`.
diff --git a/src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.fixed b/src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.fixed
deleted file mode 100644 (file)
index 63b65ab..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// run-rustfix
-
-macro_rules! my_wrapper {
-    ($expr:expr) => { MyWrapper($expr) }
-}
-
-pub struct MyWrapper(u32);
-
-fn main() {
-    let value = MyWrapper(123);
-    some_fn(value); //~ ERROR mismatched types
-    some_fn(my_wrapper!(123)); //~ ERROR mismatched types
-}
-
-fn some_fn(wrapped: MyWrapper) {
-    drop(wrapped);
-}
diff --git a/src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.rs b/src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.rs
deleted file mode 100644 (file)
index 2ab4e39..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// run-rustfix
-
-macro_rules! my_wrapper {
-    ($expr:expr) => { MyWrapper($expr) }
-}
-
-pub struct MyWrapper(u32);
-
-fn main() {
-    let value = MyWrapper(123);
-    some_fn(value.0); //~ ERROR mismatched types
-    some_fn(my_wrapper!(123).0); //~ ERROR mismatched types
-}
-
-fn some_fn(wrapped: MyWrapper) {
-    drop(wrapped);
-}
diff --git a/src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.stderr b/src/test/ui/mismatched_types/suggest-removing-tulpe-struct-field.stderr
deleted file mode 100644 (file)
index 82a7f27..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/suggest-removing-tulpe-struct-field.rs:11:13
-   |
-LL |     some_fn(value.0);
-   |     ------- ^^^^^^^ expected struct `MyWrapper`, found `u32`
-   |     |
-   |     arguments to this function are incorrect
-   |
-note: function defined here
-  --> $DIR/suggest-removing-tulpe-struct-field.rs:15:4
-   |
-LL | fn some_fn(wrapped: MyWrapper) {
-   |    ^^^^^^^ ------------------
-help: consider removing the tuple struct field `0`
-   |
-LL -     some_fn(value.0);
-LL +     some_fn(value);
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/suggest-removing-tulpe-struct-field.rs:12:13
-   |
-LL |     some_fn(my_wrapper!(123).0);
-   |     ------- ^^^^^^^^^^^^^^^^^^ expected struct `MyWrapper`, found `u32`
-   |     |
-   |     arguments to this function are incorrect
-   |
-note: function defined here
-  --> $DIR/suggest-removing-tulpe-struct-field.rs:15:4
-   |
-LL | fn some_fn(wrapped: MyWrapper) {
-   |    ^^^^^^^ ------------------
-help: consider removing the tuple struct field `0`
-   |
-LL -     some_fn(my_wrapper!(123).0);
-LL +     some_fn(my_wrapper!(123));
-   |
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.fixed b/src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.fixed
new file mode 100644 (file)
index 0000000..63b65ab
--- /dev/null
@@ -0,0 +1,17 @@
+// run-rustfix
+
+macro_rules! my_wrapper {
+    ($expr:expr) => { MyWrapper($expr) }
+}
+
+pub struct MyWrapper(u32);
+
+fn main() {
+    let value = MyWrapper(123);
+    some_fn(value); //~ ERROR mismatched types
+    some_fn(my_wrapper!(123)); //~ ERROR mismatched types
+}
+
+fn some_fn(wrapped: MyWrapper) {
+    drop(wrapped);
+}
diff --git a/src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.rs b/src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.rs
new file mode 100644 (file)
index 0000000..2ab4e39
--- /dev/null
@@ -0,0 +1,17 @@
+// run-rustfix
+
+macro_rules! my_wrapper {
+    ($expr:expr) => { MyWrapper($expr) }
+}
+
+pub struct MyWrapper(u32);
+
+fn main() {
+    let value = MyWrapper(123);
+    some_fn(value.0); //~ ERROR mismatched types
+    some_fn(my_wrapper!(123).0); //~ ERROR mismatched types
+}
+
+fn some_fn(wrapped: MyWrapper) {
+    drop(wrapped);
+}
diff --git a/src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.stderr b/src/test/ui/mismatched_types/suggest-removing-tuple-struct-field.stderr
new file mode 100644 (file)
index 0000000..35871af
--- /dev/null
@@ -0,0 +1,41 @@
+error[E0308]: mismatched types
+  --> $DIR/suggest-removing-tuple-struct-field.rs:11:13
+   |
+LL |     some_fn(value.0);
+   |     ------- ^^^^^^^ expected struct `MyWrapper`, found `u32`
+   |     |
+   |     arguments to this function are incorrect
+   |
+note: function defined here
+  --> $DIR/suggest-removing-tuple-struct-field.rs:15:4
+   |
+LL | fn some_fn(wrapped: MyWrapper) {
+   |    ^^^^^^^ ------------------
+help: consider removing the tuple struct field `0`
+   |
+LL -     some_fn(value.0);
+LL +     some_fn(value);
+   |
+
+error[E0308]: mismatched types
+  --> $DIR/suggest-removing-tuple-struct-field.rs:12:13
+   |
+LL |     some_fn(my_wrapper!(123).0);
+   |     ------- ^^^^^^^^^^^^^^^^^^ expected struct `MyWrapper`, found `u32`
+   |     |
+   |     arguments to this function are incorrect
+   |
+note: function defined here
+  --> $DIR/suggest-removing-tuple-struct-field.rs:15:4
+   |
+LL | fn some_fn(wrapped: MyWrapper) {
+   |    ^^^^^^^ ------------------
+help: consider removing the tuple struct field `0`
+   |
+LL -     some_fn(my_wrapper!(123).0);
+LL +     some_fn(my_wrapper!(123));
+   |
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/parser/issue-105634.rs b/src/test/ui/parser/issue-105634.rs
new file mode 100644 (file)
index 0000000..579aa6e
--- /dev/null
@@ -0,0 +1,8 @@
+// check-pass
+
+fn main() {
+    let _a = ..;
+    let _b = ..=10;
+    let _c = &..;
+    let _d = &..=10;
+}
diff --git a/src/test/ui/suggestions/issue-105494.rs b/src/test/ui/suggestions/issue-105494.rs
new file mode 100644 (file)
index 0000000..8b40923
--- /dev/null
@@ -0,0 +1,22 @@
+fn test1() {
+    let _v: i32 = (1 as i32).to_string(); //~ ERROR mismatched types
+
+    // won't suggestion
+    let _v: i32 = (1 as i128).to_string(); //~ ERROR mismatched types
+
+    let _v: &str = "foo".to_string(); //~ ERROR mismatched types
+}
+
+fn test2() {
+    let mut path: String = "/usr".to_string();
+    let folder: String = "lib".to_string();
+
+    path = format!("{}/{}", path, folder).as_str(); //~ ERROR mismatched types
+
+    println!("{}", &path);
+}
+
+fn main() {
+    test1();
+    test2();
+}
diff --git a/src/test/ui/suggestions/issue-105494.stderr b/src/test/ui/suggestions/issue-105494.stderr
new file mode 100644 (file)
index 0000000..5aa3f2a
--- /dev/null
@@ -0,0 +1,54 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-105494.rs:2:19
+   |
+LL |     let _v: i32 = (1 as i32).to_string();
+   |             ---   ^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String`
+   |             |
+   |             expected due to this
+   |
+help: try removing the method call
+   |
+LL -     let _v: i32 = (1 as i32).to_string();
+LL +     let _v: i32 = (1 as i32);
+   |
+
+error[E0308]: mismatched types
+  --> $DIR/issue-105494.rs:5:19
+   |
+LL |     let _v: i32 = (1 as i128).to_string();
+   |             ---   ^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String`
+   |             |
+   |             expected due to this
+
+error[E0308]: mismatched types
+  --> $DIR/issue-105494.rs:7:20
+   |
+LL |     let _v: &str = "foo".to_string();
+   |             ----   ^^^^^^^^^^^^^^^^^ expected `&str`, found struct `String`
+   |             |
+   |             expected due to this
+   |
+help: try removing the method call
+   |
+LL -     let _v: &str = "foo".to_string();
+LL +     let _v: &str = "foo";
+   |
+
+error[E0308]: mismatched types
+  --> $DIR/issue-105494.rs:14:12
+   |
+LL |     let mut path: String = "/usr".to_string();
+   |                   ------ expected due to this type
+...
+LL |     path = format!("{}/{}", path, folder).as_str();
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `String`, found `&str`
+   |
+help: try removing the method call
+   |
+LL -     path = format!("{}/{}", path, folder).as_str();
+LL +     path = format!("{}/{}", path, folder);
+   |
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
index 95f6e047bf9e6dffbd488daffbe3b6cda744ecba..7a3c0d28fc3e98ee83bdfab1a3fe0b8208e30bea 100644 (file)
@@ -2303,6 +2303,8 @@ fn verify_with_filecheck(&self, output: &Path) -> ProcRes {
         } else {
             filecheck.args(&["--check-prefixes", &prefixes]);
         }
+        // Provide more context on failures.
+        filecheck.args(&["--dump-input-context", "100"]);
         self.compose_and_run(filecheck, "", None, None)
     }