diff options
23 files changed, 295 insertions, 52 deletions
diff --git a/RELEASES.md b/RELEASES.md index 694bd09658f..a3df56f1d2a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,106 @@ +Version 1.65.0 (2022-11-03) +========================== + +Language +-------- +- [Error on `as` casts of enums with `#[non_exhaustive]` variants](https://github.com/rust-lang/rust/pull/92744/) +- [Stabilize `let else`](https://github.com/rust-lang/rust/pull/93628/) +- [Stabilize generic associated types (GATs)](https://github.com/rust-lang/rust/pull/96709/) +- [Add lints `let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use` from Clippy](https://github.com/rust-lang/rust/pull/97739/) +- [Stabilize `break`ing from arbitrary labeled blocks ("label-break-value")](https://github.com/rust-lang/rust/pull/99332/) +- [Uninitialized integers, floats, and raw pointers are now considered immediate UB](https://github.com/rust-lang/rust/pull/98919/). + Usage of `MaybeUninit` is the correct way to work with uninitialized memory. +- [Stabilize raw-dylib for Windows x86_64, aarch64, and thumbv7a](https://github.com/rust-lang/rust/pull/99916/) +- [Do not allow `Drop` impl on foreign ADTs](https://github.com/rust-lang/rust/pull/99576/) + +Compiler +-------- +- [Stabilize -Csplit-debuginfo on Linux](https://github.com/rust-lang/rust/pull/98051/) +- [Use niche-filling optimization even when multiple variants have data](https://github.com/rust-lang/rust/pull/94075/) +- [Associated type projections are now verified to be well-formed prior to resolving the underlying type](https://github.com/rust-lang/rust/pull/99217/#issuecomment-1209365630) +- [Stringify non-shorthand visibility correctly](https://github.com/rust-lang/rust/pull/100350/) +- [Normalize struct field types when unsizing](https://github.com/rust-lang/rust/pull/101831/) +- [Update to LLVM 15](https://github.com/rust-lang/rust/pull/99464/) +- [Fix aarch64 call abi to correctly zeroext when needed](https://github.com/rust-lang/rust/pull/97800/) +- [debuginfo: Generalize C++-like encoding for enums](https://github.com/rust-lang/rust/pull/98393/) +- [Add `special_module_name` lint](https://github.com/rust-lang/rust/pull/94467/) +- [Add support for generating unique profraw files by default when using `-C instrument-coverage`](https://github.com/rust-lang/rust/pull/100384/) +- [Allow dynamic linking for iOS/tvOS targets](https://github.com/rust-lang/rust/pull/100636/) + +New targets: + +- [Add armv4t-none-eabi as a tier 3 target](https://github.com/rust-lang/rust/pull/100244/) +- [Add powerpc64-unknown-openbsd and riscv64-unknown-openbsd as tier 3 targets](https://github.com/rust-lang/rust/pull/101025/) + - Refer to Rust's [platform support page][platform-support-doc] for more + information on Rust's tiered platform support. + +Libraries +--------- + +- [Don't generate `PartialEq::ne` in derive(PartialEq)](https://github.com/rust-lang/rust/pull/98655/) +- [Windows RNG: Use `BCRYPT_RNG_ALG_HANDLE` by default](https://github.com/rust-lang/rust/pull/101325/) +- [Forbid mixing `System` with direct system allocator calls](https://github.com/rust-lang/rust/pull/101394/) +- [Document no support for writing to non-blocking stdio/stderr](https://github.com/rust-lang/rust/pull/101416/) +- [`std::layout::Layout` size must not overflow `isize::MAX` when rounded up to `align`](https://github.com/rust-lang/rust/pull/95295) + This also changes the safety conditions on `Layout::from_size_align_unchecked`. + +Stabilized APIs +--------------- + +- [`std::backtrace::Backtrace`](https://doc.rust-lang.org/stable/std/backtrace/struct.Backtrace.html) +- [`Bound::as_ref`](https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.as_ref) +- [`std::io::read_to_string`](https://doc.rust-lang.org/stable/std/io/fn.read_to_string.html) +- [`<*const T>::cast_mut`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.cast_mut) +- [`<*mut T>::cast_const`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.cast_const) + +These APIs are now stable in const contexts: + +- [`<*const T>::offset_from`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset_from) +- [`<*mut T>::offset_from`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset_from) + +Cargo +----- + +- [Apply GitHub fast path even for partial hashes](https://github.com/rust-lang/cargo/pull/10807/) +- [Do not add home bin path to PATH if it's already there](https://github.com/rust-lang/cargo/pull/11023/) +- [Take priority into account within the pending queue](https://github.com/rust-lang/cargo/pull/11032/). + This slightly optimizes job scheduling by Cargo, with typically small improvements on larger crate graph builds. + +Compatibility Notes +------------------- + +- [`std::layout::Layout` size must not overflow `isize::MAX` when rounded up to `align`](https://github.com/rust-lang/rust/pull/95295). + This also changes the safety conditions on `Layout::from_size_align_unchecked`. +- [`PollFn` now only implements `Unpin` if the closure is `Unpin`](https://github.com/rust-lang/rust/pull/102737). + This is a possible breaking change if users were relying on the blanket unpin implementation. + See discussion on the PR for details of why this change was made. +- [Drop ExactSizeIterator impl from std::char::EscapeAscii](https://github.com/rust-lang/rust/pull/99880) + This is a backwards-incompatible change to the standard library's surface + area, but is unlikely to affect real world usage. +- [Do not consider a single repeated lifetime eligible for elision in the return type](https://github.com/rust-lang/rust/pull/103450) + This behavior was unintentionally changed in 1.64.0, and this release reverts that change by making this an error again. +- [Reenable disabled early syntax gates as future-incompatibility lints](https://github.com/rust-lang/rust/pull/99935/) +- [Update the minimum external LLVM to 13](https://github.com/rust-lang/rust/pull/100460/) +- [Don't duplicate file descriptors into stdio fds](https://github.com/rust-lang/rust/pull/101426/) +- [Sunset RLS](https://github.com/rust-lang/rust/pull/100863/) +- [Deny usage of `#![cfg_attr(..., crate_type = ...)]` to set the crate type](https://github.com/rust-lang/rust/pull/99784/) + This strengthens the forward compatibility lint deprecated_cfg_attr_crate_type_name to deny. +- [`llvm-has-rust-patches` allows setting the build system to treat the LLVM as having Rust-specific patches](https://github.com/rust-lang/rust/pull/101072) + This option may need to be set for distributions that are building Rust with a patched LLVM via `llvm-config`, not the built-in LLVM. + +Internal Changes +---------------- + +These changes do not affect any public interfaces of Rust, but they represent +significant improvements to the performance or internals of rustc and related +tools. + +- [Add `x.sh` and `x.ps1` shell scripts](https://github.com/rust-lang/rust/pull/99992/) +- [compiletest: use target cfg instead of hard-coded tables](https://github.com/rust-lang/rust/pull/100260/) +- [Use object instead of LLVM for reading bitcode from rlibs](https://github.com/rust-lang/rust/pull/98100/) +- [Enable MIR inlining for optimized compilations](https://github.com/rust-lang/rust/pull/91743) + This provides a 3-10% improvement in compiletimes for real world crates. See [perf results](https://perf.rust-lang.org/compare.html?start=aedf78e56b2279cc869962feac5153b6ba7001ed&end=0075bb4fad68e64b6d1be06bf2db366c30bc75e1&stat=instructions:u). + Version 1.64.0 (2022-09-22) =========================== diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 858129c742d..a9e5e438cf5 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -507,7 +507,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> { _ => "aren't", }, ), - " else { todo!() }".to_string(), + " else { todo!() }", Applicability::HasPlaceholders, ); } diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 850f023b1c1..7d5fe32ee28 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -784,10 +784,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { return false; } err.code(rustc_errors::error_code!(E0411)); - err.span_label( - span, - "`Self` is only available in impls, traits, and type definitions".to_string(), - ); + err.span_label(span, "`Self` is only available in impls, traits, and type definitions"); if let Some(item_kind) = self.diagnostic_metadata.current_item { err.span_label( item_kind.ident.span, diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 84038625fb2..1de85e2f288 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -192,12 +192,12 @@ pub fn is_const_evaluatable<'tcx>( } let concrete = infcx.const_eval_resolve(param_env, uv, Some(span)); match concrete { - Err(ErrorHandled::TooGeneric) => { - Err(NotConstEvaluatable::Error(infcx.tcx.sess.delay_span_bug( - span, - format!("Missing value for constant, but no error reported?"), - ))) - } + Err(ErrorHandled::TooGeneric) => Err(NotConstEvaluatable::Error( + infcx + .tcx + .sess + .delay_span_bug(span, "Missing value for constant, but no error reported?"), + )), Err(ErrorHandled::Linted) => { let reported = infcx .tcx diff --git a/library/core/src/async_iter/async_iter.rs b/library/core/src/async_iter/async_iter.rs index 016a3685e85..12a47f9fc76 100644 --- a/library/core/src/async_iter/async_iter.rs +++ b/library/core/src/async_iter/async_iter.rs @@ -2,7 +2,7 @@ use crate::ops::DerefMut; use crate::pin::Pin; use crate::task::{Context, Poll}; -/// An interface for dealing with asynchronous iterators. +/// A trait for dealing with asynchronous iterators. /// /// This is the main async iterator trait. For more about the concept of async iterators /// generally, please see the [module-level documentation]. In particular, you diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 789a87968d1..83c7e8977e9 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -14,7 +14,7 @@ use super::super::{ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {} -/// An interface for dealing with iterators. +/// A trait for dealing with iterators. /// /// This is the main iterator trait. For more about the concept of iterators /// generally, please see the [module-level documentation]. In particular, you diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 9195da5a44f..2e1a667097c 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -1004,7 +1004,7 @@ pub fn drop<T>(_x: T) {} /// ``` #[inline] #[unstable(feature = "mem_copy_fn", issue = "98262")] -pub fn copy<T: Copy>(x: &T) -> T { +pub const fn copy<T: Copy>(x: &T) -> T { *x } diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 5e28204b21d..28136cc48d6 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -72,8 +72,12 @@ pub(crate) fn render_source_with_highlighting( line_numbers: Buffer, href_context: HrefContext<'_, '_, '_>, decoration_info: DecorationInfo, + extra: Option<&str>, ) { write_header(out, "", Some(line_numbers), Tooltip::None); + if let Some(extra) = extra { + out.push_str(extra); + } write_code(out, src, Some(href_context), Some(decoration_info)); write_footer(out, None); } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 96c57c8c85d..27dea8ec0b3 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2869,10 +2869,6 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite write!(w, r#"<span class="prev">≺</span> <span class="next">≻</span>"#); } - if needs_expansion { - write!(w, r#"<span class="expand">↕</span>"#); - } - // Look for the example file in the source map if it exists, otherwise return a dummy span let file_span = (|| { let source_map = tcx.sess.source_map(); @@ -2906,7 +2902,7 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite cx, &root_path, highlight::DecorationInfo(decoration_info), - sources::SourceContext::Embedded { offset: line_min }, + sources::SourceContext::Embedded { offset: line_min, needs_expansion }, ); write!(w, "</div></div>"); diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 7ab65bff346..8a01c01049d 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -258,7 +258,7 @@ where pub(crate) enum SourceContext { Standalone, - Embedded { offset: usize }, + Embedded { offset: usize, needs_expansion: bool }, } /// Wrapper struct to render the source code of a file. This will do things like @@ -274,14 +274,18 @@ pub(crate) fn print_src( ) { let lines = s.lines().count(); let mut line_numbers = Buffer::empty_from(buf); + let extra; line_numbers.write_str("<pre class=\"src-line-numbers\">"); match source_context { SourceContext::Standalone => { + extra = None; for line in 1..=lines { writeln!(line_numbers, "<span id=\"{0}\">{0}</span>", line) } } - SourceContext::Embedded { offset } => { + SourceContext::Embedded { offset, needs_expansion } => { + extra = + if needs_expansion { Some(r#"<span class="expand">↕</span>"#) } else { None }; for line in 1..=lines { writeln!(line_numbers, "<span>{0}</span>", line + offset) } @@ -297,5 +301,6 @@ pub(crate) fn print_src( line_numbers, highlight::HrefContext { context, file_span, root_path, current_href }, decoration_info, + extra, ); } diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 1cc954a98dc..330bdb45465 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -493,9 +493,7 @@ ul.block, .block li { .sidebar h2 { overflow-wrap: anywhere; padding: 0; - margin: 0; - margin-top: 0.7rem; - margin-bottom: 0.7rem; + margin: 0.7rem 0; } .sidebar h3 { @@ -803,10 +801,8 @@ table, } #crate-search { min-width: 115px; - padding: 0; /* keep these two in sync with "@-moz-document url-prefix()" below */ - padding-left: 4px; - padding-right: 23px; + padding: 0 23px 0 4px; /* prevents the <select> from overflowing the containing div in case it's shrunk */ max-width: 100%; /* contents can overflow because of max-width limit, then show ellipsis */ @@ -1719,7 +1715,6 @@ in storage.js /* Hide the sidebar offscreen while not in use. Doing this instead of display: none means the sidebar stays visible for screen readers, which is useful for navigation. */ left: -1000px; - margin-left: 0; margin: 0; padding: 0; z-index: 11; @@ -1772,9 +1767,7 @@ in storage.js .mobile-topbar .logo-container > img { max-width: 35px; max-height: 35px; - margin-left: 20px; - margin-top: 5px; - margin-bottom: 5px; + margin: 5px 0 5px 20px; } .mobile-topbar { @@ -2023,45 +2016,36 @@ in storage.js padding-bottom: 0; } -.scraped-example .code-wrapper .prev { +.scraped-example .code-wrapper .next, +.scraped-example .code-wrapper .prev, +.scraped-example .code-wrapper .expand { position: absolute; top: 0.25em; - right: 2.25em; - z-index: 100; + z-index: 1; cursor: pointer; } - +.scraped-example .code-wrapper .prev { + right: 2.25em; +} .scraped-example .code-wrapper .next { - position: absolute; - top: 0.25em; right: 1.25em; - z-index: 100; - cursor: pointer; } - .scraped-example .code-wrapper .expand { - position: absolute; - top: 0.25em; right: 0.25em; - z-index: 100; - cursor: pointer; } -.scraped-example:not(.expanded) .code-wrapper:before { +.scraped-example:not(.expanded) .code-wrapper:before, +.scraped-example:not(.expanded) .code-wrapper:after { content: " "; width: 100%; height: 5px; position: absolute; - z-index: 100; + z-index: 1; +} +.scraped-example:not(.expanded) .code-wrapper:before { top: 0; } - .scraped-example:not(.expanded) .code-wrapper:after { - content: " "; - width: 100%; - height: 5px; - position: absolute; - z-index: 100; bottom: 0; } diff --git a/src/test/rustdoc/auxiliary/masked.rs b/src/test/rustdoc/auxiliary/masked.rs index f289359e52a..3d722d5e0c2 100644 --- a/src/test/rustdoc/auxiliary/masked.rs +++ b/src/test/rustdoc/auxiliary/masked.rs @@ -8,3 +8,7 @@ pub trait MaskedTrait { impl MaskedTrait for String { fn masked_method() {} } + +pub trait MaskedBlanketTrait {} + +impl<T> MaskedBlanketTrait for T {} diff --git a/src/test/rustdoc/masked.rs b/src/test/rustdoc/masked.rs index 80d5b99c0b0..875c026fd05 100644 --- a/src/test/rustdoc/masked.rs +++ b/src/test/rustdoc/masked.rs @@ -10,6 +10,7 @@ extern crate masked; // @!hasraw 'search-index.js' 'masked_method' // @!hasraw 'foo/struct.String.html' 'MaskedTrait' +// @!hasraw 'foo/struct.String.html' 'MaskedBlanketTrait' // @!hasraw 'foo/struct.String.html' 'masked_method' pub use std::string::String; diff --git a/src/test/ui/coercion/coerce-block-tail-26978.rs b/src/test/ui/coercion/coerce-block-tail-26978.rs new file mode 100644 index 00000000000..01c8ab5a839 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-26978.rs @@ -0,0 +1,11 @@ +// check-fail +fn f(_: &i32) {} + +fn main() { + let x = Box::new(1i32); + + f(&x); + f(&(x)); + f(&{x}); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail-26978.stderr b/src/test/ui/coercion/coerce-block-tail-26978.stderr new file mode 100644 index 00000000000..384debd487c --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-26978.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-26978.rs:9:9 + | +LL | f(&{x}); + | ^ expected `i32`, found struct `Box` + | + = note: expected type `i32` + found struct `Box<i32>` +help: consider unboxing the value + | +LL | f(&{*x}); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail-57749.rs b/src/test/ui/coercion/coerce-block-tail-57749.rs new file mode 100644 index 00000000000..79b5b33233b --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-57749.rs @@ -0,0 +1,35 @@ +// check-fail +use std::ops::Deref; + +fn main() { + fn save(who: &str) { + println!("I'll save you, {}!", who); + } + + struct Madoka; + + impl Deref for Madoka { + type Target = str; + fn deref(&self) -> &Self::Target { + "Madoka" + } + } + + save(&{ Madoka }); + + fn reset(how: &u32) { + println!("Reset {} times", how); + } + + struct Homura; + + impl Deref for Homura { + type Target = u32; + fn deref(&self) -> &Self::Target { + &42 + } + } + + reset(&{ Homura }); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail-57749.stderr b/src/test/ui/coercion/coerce-block-tail-57749.stderr new file mode 100644 index 00000000000..d5660c81dbd --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-57749.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-57749.rs:33:14 + | +LL | reset(&{ Homura }); + | ^^^^^^ expected `u32`, found struct `Homura` + | +help: consider dereferencing the type + | +LL | reset(&{ *Homura }); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail-83783.rs b/src/test/ui/coercion/coerce-block-tail-83783.rs new file mode 100644 index 00000000000..18c8ae3bbba --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83783.rs @@ -0,0 +1,13 @@ +// check-fail +// edition:2018 +fn _consume_reference<T: ?Sized>(_: &T) {} + +async fn _foo() { + _consume_reference::<i32>(&Box::new(7_i32)); + _consume_reference::<i32>(&async { Box::new(7_i32) }.await); + //~^ ERROR mismatched types + _consume_reference::<[i32]>(&vec![7_i32]); + _consume_reference::<[i32]>(&async { vec![7_i32] }.await); +} + +fn main() { } diff --git a/src/test/ui/coercion/coerce-block-tail-83783.stderr b/src/test/ui/coercion/coerce-block-tail-83783.stderr new file mode 100644 index 00000000000..5f53606ce22 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83783.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-83783.rs:7:32 + | +LL | _consume_reference::<i32>(&async { Box::new(7_i32) }.await); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `Box` + | + = note: expected type `i32` + found struct `Box<i32>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail-83850.rs b/src/test/ui/coercion/coerce-block-tail-83850.rs new file mode 100644 index 00000000000..77fdf999833 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83850.rs @@ -0,0 +1,7 @@ +// check-fail +fn f(_: &[i32]) {} + +fn main() { + f(&Box::new([1, 2])); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail-83850.stderr b/src/test/ui/coercion/coerce-block-tail-83850.stderr new file mode 100644 index 00000000000..bbf60754370 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83850.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-83850.rs:5:7 + | +LL | f(&Box::new([1, 2])); + | - ^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found struct `Box` + | | + | arguments to this function are incorrect + | + = note: expected reference `&[i32]` + found reference `&Box<[{integer}; 2]>` +note: function defined here + --> $DIR/coerce-block-tail-83850.rs:2:4 + | +LL | fn f(_: &[i32]) {} + | ^ --------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail.rs b/src/test/ui/coercion/coerce-block-tail.rs new file mode 100644 index 00000000000..dcbcd376286 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail.rs @@ -0,0 +1,6 @@ +// check-fail +fn main() { + let _: &str = & { String::from("hahah")}; + let _: &i32 = & { Box::new(1i32) }; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail.stderr b/src/test/ui/coercion/coerce-block-tail.stderr new file mode 100644 index 00000000000..318cf75867b --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail.rs:4:23 + | +LL | let _: &i32 = & { Box::new(1i32) }; + | ^^^^^^^^^^^^^^ expected `i32`, found struct `Box` + | + = note: expected type `i32` + found struct `Box<i32>` +help: consider unboxing the value + | +LL | let _: &i32 = & { *Box::new(1i32) }; + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
