diff --git a/RELEASES.md b/RELEASES.md
index 0948eb85192e5..1a77c33b9957d 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,3 +1,169 @@
+Version 1.87.0 (2025-05-15)
+==========================
+
+
+
+Language
+--------
+- [Stabilize `asm_goto` feature](https://github.com/rust-lang/rust/pull/133870)
+- [Allow parsing open beginning ranges (`..EXPR`) after unary operators `!`, `~`, `-`, and `*`}](https://github.com/rust-lang/rust/pull/134900).
+- [Don't require method impls for methods with `Self: Sized` bounds in `impl`s for unsized types](https://github.com/rust-lang/rust/pull/135480)
+- [Stabilize `feature(precise_capturing_in_traits)` allowing `use<...>` bounds on return position `impl Trait` in `trait`s](https://github.com/rust-lang/rust/pull/138128)
+
+
+
+Compiler
+--------
+- [x86: make SSE2 required for i686 targets and use it to pass SIMD types](https://github.com/rust-lang/rust/pull/135408)
+
+
+
+Platform Support
+----------------
+- [Remove `i586-pc-windows-msvc` target](https://github.com/rust-lang/rust/pull/137957)
+
+Refer to Rust's [platform support page][platform-support-doc]
+for more information on Rust's tiered platform support.
+
+[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html
+
+
+
+Libraries
+---------
+- [Stabilize the anonymous pipe API](https://github.com/rust-lang/rust/issues/127154)
+- [Add support for unbounded left/right shift operations](https://github.com/rust-lang/rust/issues/129375)
+- [Print pointer metadata in `Debug` impl of raw pointers](https://github.com/rust-lang/rust/pull/135080)
+- [`Vec::with_capacity` guarantees it allocates with the amount requested, even if `Vec::capacity` returns a different number.](https://github.com/rust-lang/rust/pull/135933)
+- Most `std::arch` intrinsics which don't take pointer arguments can now be called from safe code if the caller has the appropriate target features already enabled (https://github.com/rust-lang/stdarch/pull/1714, https://github.com/rust-lang/stdarch/pull/1716, https://github.com/rust-lang/stdarch/pull/1717)
+- [Undeprecate `env::home_dir`](https://github.com/rust-lang/rust/pull/137327)
+- [Denote `ControlFlow` as `#[must_use]`](https://github.com/rust-lang/rust/pull/137449)
+- [Macros such as `assert_eq!` and `vec!` now support `const {...}` expressions](https://github.com/rust-lang/rust/pull/138162)
+
+
+
+Stabilized APIs
+---------------
+
+- [`Vec::extract_if`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.extract_if)
+- [`vec::ExtractIf`](https://doc.rust-lang.org/nightly/std/vec/struct.ExtractIf.html)
+- [`LinkedList::extract_if`](https://doc.rust-lang.org/nightly/std/collections/struct.LinkedList.html#method.extract_if)
+- [`linked_list::ExtractIf`](https://doc.rust-lang.org/nightly/std/collections/linked_list/struct.ExtractIf.html)
+- [`<[T]>::split_off`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_off)
+- [`<[T]>::split_off_mut`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_off_mut)
+- [`<[T]>::split_off_first`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_off_first)
+- [`<[T]>::split_off_first_mut`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_off_first_mut)
+- [`<[T]>::split_off_last`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_off_last)
+- [`<[T]>::split_off_last_mut`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_off_last_mut)
+- [`String::extend_from_within`](https://doc.rust-lang.org/stable/alloc/string/struct.String.html#method.extend_from_within)
+- [`os_str::Display`](https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.Display.html)
+- [`OsString::display`](https://doc.rust-lang.org/nightly/std/ffi/struct.OsString.html#method.display)
+- [`OsStr::display`](https://doc.rust-lang.org/nightly/std/ffi/struct.OsStr.html#method.display)
+- [`io::pipe`](https://doc.rust-lang.org/nightly/std/io/fn.pipe.html)
+- [`io::PipeReader`](https://doc.rust-lang.org/nightly/std/io/struct.PipeReader.html)
+- [`io::PipeWriter`](https://doc.rust-lang.org/nightly/std/io/struct.PipeWriter.html)
+- [`impl From for OwnedHandle`](https://doc.rust-lang.org/nightly/std/os/windows/io/struct.OwnedHandle.html#impl-From%3CPipeReader%3E-for-OwnedHandle)
+- [`impl From for OwnedHandle`](https://doc.rust-lang.org/nightly/std/os/windows/io/struct.OwnedHandle.html#impl-From%3CPipeWriter%3E-for-OwnedHandle)
+- [`impl From for Stdio`](https://doc.rust-lang.org/nightly/std/process/struct.Stdio.html)
+- [`impl From for Stdio`](https://doc.rust-lang.org/nightly/std/process/struct.Stdio.html#impl-From%3CPipeWriter%3E-for-Stdio)
+- [`impl From for OwnedFd`](https://doc.rust-lang.org/nightly/std/os/fd/struct.OwnedFd.html#impl-From%3CPipeReader%3E-for-OwnedFd)
+- [`impl From for OwnedFd`](https://doc.rust-lang.org/nightly/std/os/fd/struct.OwnedFd.html#impl-From%3CPipeWriter%3E-for-OwnedFd)
+- [`Box>::write`](https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.write)
+- [`impl TryFrom> for String`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#impl-TryFrom%3CVec%3Cu8%3E%3E-for-String)
+
+These APIs are now stable in const contexts:
+
+- [`<*const T>::offset_from_unsigned`](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.offset_from_unsigned)
+- [`<*const T>::byte_offset_from_unsigned`](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.byte_offset_from_unsigned)
+- [`<*mut T>::offset_from_unsigned`](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.offset_from_unsigned-1)
+- [`<*mut T>::byte_offset_from_unsigned`](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.byte_offset_from_unsigned-1)
+- [`NonNull::offset_from_unsigned`](https://doc.rust-lang.org/nightly/std/ptr/struct.NonNull.html#method.offset_from_unsigned)
+- [`NonNull::byte_offset_from_unsigned`](https://doc.rust-lang.org/nightly/std/ptr/struct.NonNull.html#method.byte_offset_from_unsigned)
+- [`::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.usize.html#method.cast_signed)
+- [`NonZero::::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed-5).
+- [`::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.isize.html#method.cast_signed).
+- [`NonZero::::cast_unsigned`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_unsigned-5).
+- [`::is_multiple_of`](https://doc.rust-lang.org/nightly/std/primitive.usize.html#method.is_multiple_of)
+- [`::unbounded_shl`](https://doc.rust-lang.org/nightly/std/primitive.usize.html#method.unbounded_shl)
+- [`::unbounded_shr`](https://doc.rust-lang.org/nightly/std/primitive.usize.html#method.unbounded_shr)
+- [`::unbounded_shl`](https://doc.rust-lang.org/nightly/std/primitive.isize.html#method.unbounded_shl)
+- [`::unbounded_shr`](https://doc.rust-lang.org/nightly/std/primitive.isize.html#method.unbounded_shr)
+- [`::from_utf8`](https://doc.rust-lang.org/nightly/std/primitive.str.html#method.from_utf8)
+- [`::from_utf8_mut`](https://doc.rust-lang.org/nightly/std/primitive.str.html#method.from_utf8_mut)
+- [`::from_utf8_unchecked`](https://doc.rust-lang.org/nightly/std/primitive.str.html#method.from_utf8_unchecked)
+- [`::from_utf8_unchecked_mut`](https://doc.rust-lang.org/nightly/std/primitive.str.html#method.from_utf8_unchecked_mut)
+- [`core::str::from_utf8_mut`](https://doc.rust-lang.org/nightly/std/str/fn.from_utf8_mut.html)
+- [`<[T]>::copy_from_slice`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.copy_from_slice)
+- [`SocketAddr::set_ip`](https://doc.rust-lang.org/nightly/std/net/enum.SocketAddr.html#method.set_ip)
+- [`SocketAddr::set_port`](https://doc.rust-lang.org/nightly/std/net/enum.SocketAddr.html#method.set_port),
+- [`SocketAddrV4::set_ip`](https://doc.rust-lang.org/nightly/std/net/struct.SocketAddrV4.html#method.set_ip)
+- [`SocketAddrV4::set_port`](https://doc.rust-lang.org/nightly/std/net/struct.SocketAddrV4.html#method.set_port),
+- [`SocketAddrV6::set_ip`](https://doc.rust-lang.org/nightly/std/net/struct.SocketAddrV6.html#method.set_ip)
+- [`SocketAddrV6::set_port`](https://doc.rust-lang.org/nightly/std/net/struct.SocketAddrV6.html#method.set_port)
+- [`SocketAddrV6::set_flowinfo`](https://doc.rust-lang.org/nightly/std/net/struct.SocketAddrV6.html#method.set_flowinfo)
+- [`SocketAddrV6::set_scope_id`](https://doc.rust-lang.org/nightly/std/net/struct.SocketAddrV6.html#method.set_scope_id)
+- [`char::is_digit`](https://doc.rust-lang.org/nightly/std/primitive.char.html#method.is_digit)
+- [`char::is_whitespace`](https://doc.rust-lang.org/nightly/std/primitive.char.html#method.is_whitespace)
+- [`::midpoint`](https://doc.rust-lang.org/std/primitive.isize.html#method.midpoint)
+- [`<[[T; N]]>::as_flattened`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.as_flattened)
+- [`<[[T; N]]>::as_flattened_mut`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.as_flattened_mut)
+- [`String::into_bytes`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.into_bytes)
+- [`String::as_str`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.as_str)
+- [`String::capacity`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.capacity)
+- [`String::as_bytes`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.as_bytes)
+- [`String::len`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.len)
+- [`String::is_empty`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.is_empty)
+- [`String::as_mut_str`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.as_mut_str)
+- [`String::as_mut_vec`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.as_mut_vec)
+- [`Vec::as_ptr`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.as_ptr)
+- [`Vec::as_slice`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.as_slice)
+- [`Vec::capacity`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.capacity)
+- [`Vec::len`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.len)
+- [`Vec::is_empty`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.is_empty)
+- [`Vec::as_mut_slice`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.as_mut_slice)
+- [`Vec::as_mut_ptr`](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.as_mut_ptr)
+
+
+
+Cargo
+-----
+- [Add terminal integration via ANSI OSC 9;4 sequences](https://github.com/rust-lang/cargo/pull/14615/)
+- [chore: bump openssl to v3](https://github.com/rust-lang/cargo/pull/15232/)
+- [feat(package): add --exclude-lockfile flag](https://github.com/rust-lang/cargo/pull/15234/)
+
+
+
+Compatibility Notes
+-------------------
+- [Rust now raises an error for macro invocations inside the `#![crate_name]` attribute](https://github.com/rust-lang/rust/pull/127581)
+- [Unstable fields are now always considered to be inhabited](https://github.com/rust-lang/rust/pull/133889)
+- [Macro arguments of unary operators followed by open beginning ranges may now be matched differently](https://github.com/rust-lang/rust/pull/134900)
+- [Make `Debug` impl of raw pointers print metadata if present](https://github.com/rust-lang/rust/pull/135080)
+- [Warn against function pointers using unsupported ABI strings in dependencies](https://github.com/rust-lang/rust/pull/135767)
+- [Associated types on `dyn` types are no longer deduplicated](https://github.com/rust-lang/rust/pull/136458)
+- [Forbid attributes on `..` inside of struct patterns (`let Struct { #[attribute] .. }) =`](https://github.com/rust-lang/rust/pull/136490)
+- [Make `ptr_cast_add_auto_to_object` lint into hard error](https://github.com/rust-lang/rust/pull/136764)
+- Many `std::arch` intrinsics are now safe to call in some contexts, there may now be new `unused_unsafe` warnings in existing codebases.
+- [Limit `width` and `precision` formatting options to 16 bits on all targets](https://github.com/rust-lang/rust/pull/136932)
+- [Turn order dependent trait objects future incompat warning into a hard error](https://github.com/rust-lang/rust/pull/136968)
+- [Denote `ControlFlow` as `#[must_use]`](https://github.com/rust-lang/rust/pull/137449)
+- [Windows: The standard library no longer links `advapi32`, except on win7.](https://github.com/rust-lang/rust/pull/138233) Code such as C libraries that were relying on this assumption may need to explicitly link advapi32.
+- [Proc macros can no longer observe expanded `cfg(true)` attributes.](https://github.com/rust-lang/rust/pull/138844)
+- [Start changing the internal representation of pasted tokens](https://github.com/rust-lang/rust/pull/124141). Certain invalid declarative macros that were previously accepted in obscure circumstances are now correctly rejected by the compiler. Use of a `tt` fragment specifier can often fix these macros.
+- [Don't allow flattened format_args in const.](https://github.com/rust-lang/rust/pull/139624)
+
+
+
+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.
+
+- [Update to LLVM 20](https://github.com/rust-lang/rust/pull/135763)
+
+
Version 1.86.0 (2025-04-03)
==========================
diff --git a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs
index d37ede86cfd2a..c1d95d07f4c65 100644
--- a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs
@@ -53,7 +53,7 @@ fn parse_unstable<'a>(
for param in list.mixed() {
let param_span = param.span();
- if let Some(ident) = param.meta_item().and_then(|i| i.word_without_args()) {
+ if let Some(ident) = param.meta_item().and_then(|i| i.path_without_args().word()) {
res.push(ident.name);
} else {
cx.emit_err(session_diagnostics::ExpectsFeatures {
diff --git a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs
index 7d1417446b21d..fb3d5f57d4fac 100644
--- a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs
@@ -1,5 +1,4 @@
use rustc_attr_data_structures::{AttributeKind, DeprecatedSince, Deprecation};
-use rustc_span::symbol::Ident;
use rustc_span::{Span, Symbol, sym};
use super::SingleAttributeParser;
@@ -13,16 +12,13 @@ pub(crate) struct DeprecationParser;
fn get(
cx: &AcceptContext<'_>,
- ident: Ident,
+ name: Symbol,
param_span: Span,
arg: &ArgParser<'_>,
item: &Option,
) -> Option {
if item.is_some() {
- cx.emit_err(session_diagnostics::MultipleItem {
- span: param_span,
- item: ident.to_string(),
- });
+ cx.emit_err(session_diagnostics::MultipleItem { span: param_span, item: name.to_string() });
return None;
}
if let Some(v) = arg.name_value() {
@@ -83,16 +79,16 @@ impl SingleAttributeParser for DeprecationParser {
return None;
};
- let (ident, arg) = param.word_or_empty();
+ let ident_name = param.path_without_args().word_sym();
- match ident.name {
- sym::since => {
- since = Some(get(cx, ident, param_span, arg, &since)?);
+ match ident_name {
+ Some(name @ sym::since) => {
+ since = Some(get(cx, name, param_span, param.args(), &since)?);
}
- sym::note => {
- note = Some(get(cx, ident, param_span, arg, ¬e)?);
+ Some(name @ sym::note) => {
+ note = Some(get(cx, name, param_span, param.args(), ¬e)?);
}
- sym::suggestion => {
+ Some(name @ sym::suggestion) => {
if !features.deprecated_suggestion() {
cx.emit_err(session_diagnostics::DeprecatedItemSuggestion {
span: param_span,
@@ -101,12 +97,12 @@ impl SingleAttributeParser for DeprecationParser {
});
}
- suggestion = Some(get(cx, ident, param_span, arg, &suggestion)?);
+ suggestion = Some(get(cx, name, param_span, param.args(), &suggestion)?);
}
_ => {
cx.emit_err(session_diagnostics::UnknownMetaItem {
span: param_span,
- item: ident.to_string(),
+ item: param.path_without_args().to_string(),
expected: if features.deprecated_suggestion() {
&["since", "note", "suggestion"]
} else {
diff --git a/compiler/rustc_attr_parsing/src/attributes/repr.rs b/compiler/rustc_attr_parsing/src/attributes/repr.rs
index 26ca637faec68..43dfb85a7c411 100644
--- a/compiler/rustc_attr_parsing/src/attributes/repr.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/repr.rs
@@ -96,58 +96,75 @@ fn parse_repr(cx: &AcceptContext<'_>, param: &MetaItemParser<'_>) -> Option {
- cx.emit_err(session_diagnostics::InvalidReprAlignNeedArg { span: ident.span });
+ match (name, args) {
+ (Some(sym::align), ArgParser::NoArgs) => {
+ cx.emit_err(session_diagnostics::InvalidReprAlignNeedArg { span: ident_span });
None
}
- (sym::align, ArgParser::List(l)) => parse_repr_align(cx, l, param.span(), AlignKind::Align),
+ (Some(sym::align), ArgParser::List(l)) => {
+ parse_repr_align(cx, l, param.span(), AlignKind::Align)
+ }
- (sym::packed, ArgParser::NoArgs) => Some(ReprPacked(Align::ONE)),
- (sym::packed, ArgParser::List(l)) => {
+ (Some(sym::packed), ArgParser::NoArgs) => Some(ReprPacked(Align::ONE)),
+ (Some(sym::packed), ArgParser::List(l)) => {
parse_repr_align(cx, l, param.span(), AlignKind::Packed)
}
- (sym::align | sym::packed, ArgParser::NameValue(l)) => {
+ (Some(name @ sym::align | name @ sym::packed), ArgParser::NameValue(l)) => {
cx.emit_err(session_diagnostics::IncorrectReprFormatGeneric {
span: param.span(),
// FIXME(jdonszelmann) can just be a string in the diag type
- repr_arg: &ident.to_string(),
+ repr_arg: name,
cause: IncorrectReprFormatGenericCause::from_lit_kind(
param.span(),
&l.value_as_lit().kind,
- ident.name.as_str(),
+ name,
),
});
None
}
- (sym::Rust, ArgParser::NoArgs) => Some(ReprRust),
- (sym::C, ArgParser::NoArgs) => Some(ReprC),
- (sym::simd, ArgParser::NoArgs) => Some(ReprSimd),
- (sym::transparent, ArgParser::NoArgs) => Some(ReprTransparent),
- (i @ int_pat!(), ArgParser::NoArgs) => {
+ (Some(sym::Rust), ArgParser::NoArgs) => Some(ReprRust),
+ (Some(sym::C), ArgParser::NoArgs) => Some(ReprC),
+ (Some(sym::simd), ArgParser::NoArgs) => Some(ReprSimd),
+ (Some(sym::transparent), ArgParser::NoArgs) => Some(ReprTransparent),
+ (Some(name @ int_pat!()), ArgParser::NoArgs) => {
// int_pat!() should make sure it always parses
- Some(ReprInt(int_type_of_word(i).unwrap()))
+ Some(ReprInt(int_type_of_word(name).unwrap()))
}
(
- sym::Rust | sym::C | sym::simd | sym::transparent | int_pat!(),
+ Some(
+ name @ sym::Rust
+ | name @ sym::C
+ | name @ sym::simd
+ | name @ sym::transparent
+ | name @ int_pat!(),
+ ),
ArgParser::NameValue(_),
) => {
- cx.emit_err(session_diagnostics::InvalidReprHintNoValue {
- span: param.span(),
- name: ident.to_string(),
- });
+ cx.emit_err(session_diagnostics::InvalidReprHintNoValue { span: param.span(), name });
None
}
- (sym::Rust | sym::C | sym::simd | sym::transparent | int_pat!(), ArgParser::List(_)) => {
- cx.emit_err(session_diagnostics::InvalidReprHintNoParen {
- span: param.span(),
- name: ident.to_string(),
- });
+ (
+ Some(
+ name @ sym::Rust
+ | name @ sym::C
+ | name @ sym::simd
+ | name @ sym::transparent
+ | name @ int_pat!(),
+ ),
+ ArgParser::List(_),
+ ) => {
+ cx.emit_err(session_diagnostics::InvalidReprHintNoParen { span: param.span(), name });
None
}
diff --git a/compiler/rustc_attr_parsing/src/attributes/stability.rs b/compiler/rustc_attr_parsing/src/attributes/stability.rs
index bdad6b50186dd..cd1f21d92e7e2 100644
--- a/compiler/rustc_attr_parsing/src/attributes/stability.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/stability.rs
@@ -242,9 +242,9 @@ pub(crate) fn parse_stability(
return None;
};
- match param.word_or_empty_without_args().name {
- sym::feature => insert_value_into_option_or_error(cx, ¶m, &mut feature)?,
- sym::since => insert_value_into_option_or_error(cx, ¶m, &mut since)?,
+ match param.path_without_args().word_sym() {
+ Some(sym::feature) => insert_value_into_option_or_error(cx, ¶m, &mut feature)?,
+ Some(sym::since) => insert_value_into_option_or_error(cx, ¶m, &mut since)?,
_ => {
cx.emit_err(session_diagnostics::UnknownMetaItem {
span: param_span,
@@ -310,11 +310,10 @@ pub(crate) fn parse_unstability(
return None;
};
- let (word, args) = param.word_or_empty();
- match word.name {
- sym::feature => insert_value_into_option_or_error(cx, ¶m, &mut feature)?,
- sym::reason => insert_value_into_option_or_error(cx, ¶m, &mut reason)?,
- sym::issue => {
+ match param.path_without_args().word_sym() {
+ Some(sym::feature) => insert_value_into_option_or_error(cx, ¶m, &mut feature)?,
+ Some(sym::reason) => insert_value_into_option_or_error(cx, ¶m, &mut reason)?,
+ Some(sym::issue) => {
insert_value_into_option_or_error(cx, ¶m, &mut issue)?;
// These unwraps are safe because `insert_value_into_option_or_error` ensures the meta item
@@ -328,7 +327,7 @@ pub(crate) fn parse_unstability(
session_diagnostics::InvalidIssueString {
span: param.span(),
cause: session_diagnostics::InvalidIssueStringCause::from_int_error_kind(
- args.name_value().unwrap().value_span,
+ param.args().name_value().unwrap().value_span,
err.kind(),
),
},
@@ -338,13 +337,15 @@ pub(crate) fn parse_unstability(
},
};
}
- sym::soft => {
- if !args.no_args() {
+ Some(sym::soft) => {
+ if !param.args().no_args() {
cx.emit_err(session_diagnostics::SoftNoArgs { span: param.span() });
}
is_soft = true;
}
- sym::implied_by => insert_value_into_option_or_error(cx, ¶m, &mut implied_by)?,
+ Some(sym::implied_by) => {
+ insert_value_into_option_or_error(cx, ¶m, &mut implied_by)?
+ }
_ => {
cx.emit_err(session_diagnostics::UnknownMetaItem {
span: param.span(),
diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs
index 40aa39711d3e2..077d953cfa318 100644
--- a/compiler/rustc_attr_parsing/src/parser.rs
+++ b/compiler/rustc_attr_parsing/src/parser.rs
@@ -78,8 +78,8 @@ impl<'a> PathParser<'a> {
(self.len() == 1).then(|| **self.segments().next().as_ref().unwrap())
}
- pub fn word_or_empty(&self) -> Ident {
- self.word().unwrap_or_else(Ident::empty)
+ pub fn word_sym(&self) -> Option {
+ self.word().map(|ident| ident.name)
}
/// Asserts that this MetaItem is some specific word.
@@ -284,11 +284,6 @@ impl<'a> MetaItemParser<'a> {
Some(self.word()?.0)
}
- /// Like [`word`](Self::word), but returns an empty symbol instead of None
- pub fn word_or_empty_without_args(&self) -> Ident {
- self.word_or_empty().0
- }
-
/// Asserts that this MetaItem starts with a word, or single segment path.
///
/// Some examples:
@@ -300,12 +295,6 @@ impl<'a> MetaItemParser<'a> {
Some((path.word()?, args))
}
- /// Like [`word`](Self::word), but returns an empty symbol instead of None
- pub fn word_or_empty(&self) -> (Ident, &ArgParser<'a>) {
- let (path, args) = self.deconstruct();
- (path.word().unwrap_or(Ident::empty()), args)
- }
-
/// Asserts that this MetaItem starts with some specific word.
///
/// See [`word`](Self::word) for examples of what a word is.
diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs
index 9d34b807ac2fe..2c434175b4b69 100644
--- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs
+++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs
@@ -204,7 +204,7 @@ pub(crate) struct InvalidReprHintNoParen {
#[primary_span]
pub span: Span,
- pub name: String,
+ pub name: Symbol,
}
#[derive(Diagnostic)]
@@ -213,7 +213,7 @@ pub(crate) struct InvalidReprHintNoValue {
#[primary_span]
pub span: Span,
- pub name: String,
+ pub name: Symbol,
}
/// Error code: E0565
@@ -295,21 +295,21 @@ pub(crate) struct IncorrectReprFormatExpectInteger {
#[derive(Diagnostic)]
#[diag(attr_parsing_incorrect_repr_format_generic, code = E0693)]
-pub(crate) struct IncorrectReprFormatGeneric<'a> {
+pub(crate) struct IncorrectReprFormatGeneric {
#[primary_span]
pub span: Span,
- pub repr_arg: &'a str,
+ pub repr_arg: Symbol,
#[subdiagnostic]
- pub cause: Option>,
+ pub cause: Option,
}
#[derive(Subdiagnostic)]
-pub(crate) enum IncorrectReprFormatGenericCause<'a> {
+pub(crate) enum IncorrectReprFormatGenericCause {
#[suggestion(
attr_parsing_suggestion,
- code = "{name}({int})",
+ code = "{name}({value})",
applicability = "machine-applicable"
)]
Int {
@@ -317,15 +317,15 @@ pub(crate) enum IncorrectReprFormatGenericCause<'a> {
span: Span,
#[skip_arg]
- name: &'a str,
+ name: Symbol,
#[skip_arg]
- int: u128,
+ value: u128,
},
#[suggestion(
attr_parsing_suggestion,
- code = "{name}({symbol})",
+ code = "{name}({value})",
applicability = "machine-applicable"
)]
Symbol {
@@ -333,20 +333,20 @@ pub(crate) enum IncorrectReprFormatGenericCause<'a> {
span: Span,
#[skip_arg]
- name: &'a str,
+ name: Symbol,
#[skip_arg]
- symbol: Symbol,
+ value: Symbol,
},
}
-impl<'a> IncorrectReprFormatGenericCause<'a> {
- pub(crate) fn from_lit_kind(span: Span, kind: &ast::LitKind, name: &'a str) -> Option {
- match kind {
- ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
- Some(Self::Int { span, name, int: int.get() })
+impl IncorrectReprFormatGenericCause {
+ pub(crate) fn from_lit_kind(span: Span, kind: &ast::LitKind, name: Symbol) -> Option {
+ match *kind {
+ ast::LitKind::Int(value, ast::LitIntType::Unsuffixed) => {
+ Some(Self::Int { span, name, value: value.get() })
}
- ast::LitKind::Str(symbol, _) => Some(Self::Symbol { span, name, symbol: *symbol }),
+ ast::LitKind::Str(value, _) => Some(Self::Symbol { span, name, value }),
_ => None,
}
}
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
index 88f745892048c..f6e5149bd2b17 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
@@ -172,7 +172,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let principal_trait = regular_traits.into_iter().next();
- let mut needed_associated_types = vec![];
+ // A stable ordering of associated types from the principal trait and all its
+ // supertraits. We use this to ensure that different substitutions of a trait
+ // don't result in `dyn Trait` types with different projections lists, which
+ // can be unsound: .
+ // We achieve a stable ordering by walking over the unsubstituted principal
+ // trait ref.
+ let mut ordered_associated_types = vec![];
+
if let Some((principal_trait, ref spans)) = principal_trait {
let principal_trait = principal_trait.map_bound(|trait_pred| {
assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
@@ -197,16 +204,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// FIXME(negative_bounds): Handle this correctly...
let trait_ref =
tcx.anonymize_bound_vars(bound_predicate.rebind(pred.trait_ref));
- needed_associated_types.extend(
+ ordered_associated_types.extend(
tcx.associated_items(pred.trait_ref.def_id)
.in_definition_order()
// We only care about associated types.
.filter(|item| item.is_type())
// No RPITITs -- they're not dyn-compatible for now.
.filter(|item| !item.is_impl_trait_in_trait())
- // If the associated type has a `where Self: Sized` bound,
- // we do not need to constrain the associated type.
- .filter(|item| !tcx.generics_require_sized_self(item.def_id))
.map(|item| (item.def_id, trait_ref)),
);
}
@@ -278,14 +282,26 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
}
+ // We compute the list of projection bounds taking the ordered associated types,
+ // and check if there was an entry in the collected `projection_bounds`. Those
+ // are computed by first taking the user-written associated types, then elaborating
+ // the principal trait ref, and only using those if there was no user-written.
+ // See note below about how we handle missing associated types with `Self: Sized`,
+ // which are not required to be provided, but are still used if they are provided.
let mut missing_assoc_types = FxIndexSet::default();
- let projection_bounds: Vec<_> = needed_associated_types
+ let projection_bounds: Vec<_> = ordered_associated_types
.into_iter()
.filter_map(|key| {
if let Some(assoc) = projection_bounds.get(&key) {
Some(*assoc)
} else {
- missing_assoc_types.insert(key);
+ // If the associated type has a `where Self: Sized` bound, then
+ // we do not need to provide the associated type. This results in
+ // a `dyn Trait` type that has a different number of projection
+ // bounds, which may lead to type mismatches.
+ if !tcx.generics_require_sized_self(key.0) {
+ missing_assoc_types.insert(key);
+ }
None
}
})
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index f9502153afdc5..17d48184dd971 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -650,14 +650,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match &pat.kind {
// Type checking these product-like types successfully always require
// that the expected type be of those types and not reference types.
- PatKind::Tuple(..)
- | PatKind::Range(..)
- | PatKind::Slice(..) => AdjustMode::peel_all(),
+ PatKind::Tuple(..) | PatKind::Range(..) | PatKind::Slice(..) => AdjustMode::peel_all(),
// When checking an explicit deref pattern, only peel reference types.
// FIXME(deref_patterns): If box patterns and deref patterns need to coexist, box
// patterns may want `PeelKind::Implicit`, stopping on encountering a box.
- | PatKind::Box(_)
- | PatKind::Deref(_) => AdjustMode::Peel { kind: PeelKind::ExplicitDerefPat },
+ PatKind::Box(_) | PatKind::Deref(_) => {
+ AdjustMode::Peel { kind: PeelKind::ExplicitDerefPat }
+ }
// A never pattern behaves somewhat like a literal or unit variant.
PatKind::Never => AdjustMode::peel_all(),
// For patterns with paths, how we peel the scrutinee depends on the path's resolution.
@@ -679,7 +678,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& self.tcx.features().deref_patterns()
&& !matches!(lt.kind, PatExprKind::Lit { .. })
{
- span_bug!(lt.span, "FIXME(deref_patterns): adjust mode unimplemented for {:?}", lt.kind);
+ span_bug!(
+ lt.span,
+ "FIXME(deref_patterns): adjust mode unimplemented for {:?}",
+ lt.kind
+ );
}
// Call `resolve_vars_if_possible` here for inline const blocks.
let lit_ty = self.resolve_vars_if_possible(self.check_pat_expr_unadjusted(lt));
@@ -687,17 +690,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if self.tcx.features().deref_patterns() {
let mut peeled_ty = lit_ty;
let mut pat_ref_layers = 0;
- while let ty::Ref(_, inner_ty, mutbl) = *peeled_ty.kind() {
+ while let ty::Ref(_, inner_ty, mutbl) =
+ *self.try_structurally_resolve_type(pat.span, peeled_ty).kind()
+ {
// We rely on references at the head of constants being immutable.
debug_assert!(mutbl.is_not());
pat_ref_layers += 1;
peeled_ty = inner_ty;
}
- AdjustMode::Peel { kind: PeelKind::Implicit { until_adt: None, pat_ref_layers } }
+ AdjustMode::Peel {
+ kind: PeelKind::Implicit { until_adt: None, pat_ref_layers },
+ }
} else {
if lit_ty.is_ref() { AdjustMode::Pass } else { AdjustMode::peel_all() }
}
- },
+ }
// Ref patterns are complicated, we handle them in `check_pat_ref`.
PatKind::Ref(..)
@@ -928,6 +935,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// be peeled to `str` while ty here is still `&str`, if we don't
// err early here, a rather confusing unification error will be
// emitted instead).
+ let ty = self.try_structurally_resolve_type(expr.span, ty);
let fail =
!(ty.is_numeric() || ty.is_char() || ty.is_ty_var() || ty.references_error());
Some((fail, ty, expr.span))
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index 2165cf186bd57..c31ce1bc63070 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -723,7 +723,10 @@ impl<'tcx> Ty<'tcx> {
repr: DynKind,
) -> Ty<'tcx> {
if cfg!(debug_assertions) {
- let projection_count = obj.projection_bounds().count();
+ let projection_count = obj
+ .projection_bounds()
+ .filter(|item| !tcx.generics_require_sized_self(item.item_def_id()))
+ .count();
let expected_count: usize = obj
.principal_def_id()
.into_iter()
diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs
index 394a3ea677833..cb83540c4eaf7 100644
--- a/library/core/src/hint.rs
+++ b/library/core/src/hint.rs
@@ -320,6 +320,10 @@ pub fn spin_loop() {
/// This also means that this function does not offer any guarantees for cryptographic or security
/// purposes.
///
+/// This limitation is not specific to `black_box`; there is no mechanism in the entire Rust
+/// language that can provide the guarantees required for constant-time cryptography.
+/// (There is also no such mechanism in LLVM, so the same is true for every other LLVM-based compiler.)
+///
///
///
/// [`std::convert::identity`]: crate::convert::identity
diff --git a/tests/run-make/rustdoc-tempdir-removal/rmake.rs b/tests/run-make/rustdoc-tempdir-removal/rmake.rs
index bd87f05b7cf51..9ad369ae5b10f 100644
--- a/tests/run-make/rustdoc-tempdir-removal/rmake.rs
+++ b/tests/run-make/rustdoc-tempdir-removal/rmake.rs
@@ -1,14 +1,22 @@
// This test ensures that no temporary folder is "left behind" when doctests fail for any reason.
-//@ only-linux
+//@ ignore-cross-compile
use std::path::Path;
use run_make_support::{path, rfs, rustdoc};
fn run_doctest_and_check_tmpdir(tmp_dir: &Path, doctest: &str, edition: &str) {
- let output =
- rustdoc().input(doctest).env("TMPDIR", tmp_dir).arg("--test").edition(edition).run_fail();
+ let mut runner = rustdoc();
+ runner.input(doctest).arg("--test").edition(edition);
+ let output = if cfg!(unix) {
+ runner.env("TMPDIR", tmp_dir)
+ } else if cfg!(windows) {
+ runner.env("TEMP", tmp_dir).env("TMP", tmp_dir)
+ } else {
+ panic!("unsupported OS")
+ }
+ .run_fail();
output.assert_exit_code(101).assert_stdout_contains(
"test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out",
diff --git a/tests/ui/errors/auxiliary/file-debuginfo.rs b/tests/ui/errors/auxiliary/file-debuginfo.rs
new file mode 100644
index 0000000000000..08113ec26bfd4
--- /dev/null
+++ b/tests/ui/errors/auxiliary/file-debuginfo.rs
@@ -0,0 +1,11 @@
+//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@ compile-flags: -Zremap-path-scope=debuginfo
+
+#[macro_export]
+macro_rules! my_file {
+ () => { file!() }
+}
+
+pub fn file() -> &'static str {
+ file!()
+}
diff --git a/tests/ui/errors/auxiliary/file-diag.rs b/tests/ui/errors/auxiliary/file-diag.rs
new file mode 100644
index 0000000000000..f29c349f703b2
--- /dev/null
+++ b/tests/ui/errors/auxiliary/file-diag.rs
@@ -0,0 +1,11 @@
+//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@ compile-flags: -Zremap-path-scope=diagnostics
+
+#[macro_export]
+macro_rules! my_file {
+ () => { file!() }
+}
+
+pub fn file() -> &'static str {
+ file!()
+}
diff --git a/tests/ui/errors/auxiliary/file-macro.rs b/tests/ui/errors/auxiliary/file-macro.rs
new file mode 100644
index 0000000000000..11abc0549a7b8
--- /dev/null
+++ b/tests/ui/errors/auxiliary/file-macro.rs
@@ -0,0 +1,11 @@
+//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@ compile-flags: -Zremap-path-scope=macro
+
+#[macro_export]
+macro_rules! my_file {
+ () => { file!() }
+}
+
+pub fn file() -> &'static str {
+ file!()
+}
diff --git a/tests/ui/errors/auxiliary/file.rs b/tests/ui/errors/auxiliary/file.rs
new file mode 100644
index 0000000000000..63a7b3b58f0f5
--- /dev/null
+++ b/tests/ui/errors/auxiliary/file.rs
@@ -0,0 +1,8 @@
+#[macro_export]
+macro_rules! my_file {
+ () => { file!() }
+}
+
+pub fn file() -> &'static str {
+ file!()
+}
diff --git a/tests/ui/errors/auxiliary/trait-debuginfo.rs b/tests/ui/errors/auxiliary/trait-debuginfo.rs
new file mode 100644
index 0000000000000..d5a0825fe6d13
--- /dev/null
+++ b/tests/ui/errors/auxiliary/trait-debuginfo.rs
@@ -0,0 +1,4 @@
+//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@ compile-flags: -Zremap-path-scope=debuginfo
+
+pub trait Trait: std::fmt::Display {}
diff --git a/tests/ui/errors/auxiliary/trait-diag.rs b/tests/ui/errors/auxiliary/trait-diag.rs
new file mode 100644
index 0000000000000..e07961a276a9d
--- /dev/null
+++ b/tests/ui/errors/auxiliary/trait-diag.rs
@@ -0,0 +1,4 @@
+//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@ compile-flags: -Zremap-path-scope=diagnostics
+
+pub trait Trait: std::fmt::Display {}
diff --git a/tests/ui/errors/auxiliary/trait-macro.rs b/tests/ui/errors/auxiliary/trait-macro.rs
new file mode 100644
index 0000000000000..48673d04ee16f
--- /dev/null
+++ b/tests/ui/errors/auxiliary/trait-macro.rs
@@ -0,0 +1,4 @@
+//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@ compile-flags: -Zremap-path-scope=macro
+
+pub trait Trait: std::fmt::Display {}
diff --git a/tests/ui/errors/auxiliary/trait.rs b/tests/ui/errors/auxiliary/trait.rs
new file mode 100644
index 0000000000000..0e7e5400aac59
--- /dev/null
+++ b/tests/ui/errors/auxiliary/trait.rs
@@ -0,0 +1 @@
+pub trait Trait: std::fmt::Display {}
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr
new file mode 100644
index 0000000000000..3ddff11798de3
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `A` doesn't implement `std::fmt::Display`
+ --> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL
+ |
+LL | impl r#trait::Trait for A {}
+ | ^ `A` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `A`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Trait`
+ --> $DIR/auxiliary/trait.rs:LL:COL
+ |
+LL | pub trait Trait: std::fmt::Display {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr
new file mode 100644
index 0000000000000..85c781425b16a
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `A` doesn't implement `std::fmt::Display`
+ --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
+ |
+LL | impl r#trait::Trait for A {}
+ | ^ `A` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `A`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Trait`
+ --> $DIR/auxiliary/trait-debuginfo.rs:LL:COL
+ |
+LL | pub trait Trait: std::fmt::Display {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr
new file mode 100644
index 0000000000000..792ea7925ad56
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `A` doesn't implement `std::fmt::Display`
+ --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
+ |
+LL | impl r#trait::Trait for A {}
+ | ^ `A` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `A`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Trait`
+ --> $DIR/auxiliary/trait-diag.rs:LL:COL
+ |
+LL | pub trait Trait: std::fmt::Display {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr
new file mode 100644
index 0000000000000..d13333d2e4825
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `A` doesn't implement `std::fmt::Display`
+ --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
+ |
+LL | impl r#trait::Trait for A {}
+ | ^ `A` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `A`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Trait`
+ --> $DIR/auxiliary/trait-macro.rs:LL:COL
+ |
+LL | pub trait Trait: std::fmt::Display {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.rs b/tests/ui/errors/remap-path-prefix-diagnostics.rs
new file mode 100644
index 0000000000000..fac7e937cb0b8
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.rs
@@ -0,0 +1,57 @@
+// This test exercises `-Zremap-path-scope`, diagnostics printing paths and dependency.
+//
+// We test different combinations with/without remap in deps, with/without remap in this
+// crate but always in deps and always here but never in deps.
+
+//@ revisions: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps
+//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps
+//@ revisions: not-diag-in-deps
+
+//@[with-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@[with-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@[not-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+
+//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
+//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro
+//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo
+//@[not-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
+
+//@[with-diag-in-deps] aux-build:trait-diag.rs
+//@[with-macro-in-deps] aux-build:trait-macro.rs
+//@[with-debuginfo-in-deps] aux-build:trait-debuginfo.rs
+//@[only-diag-in-deps] aux-build:trait-diag.rs
+//@[only-macro-in-deps] aux-build:trait-macro.rs
+//@[only-debuginfo-in-deps] aux-build:trait-debuginfo.rs
+//@[not-diag-in-deps] aux-build:trait.rs
+
+// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically
+// as the remapped revision will not begin with $SRC_DIR_REAL,
+// so we have to do it ourselves.
+//@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:COL"
+
+#[cfg(any(with_diag_in_deps, only_diag_in_deps))]
+extern crate trait_diag as r#trait;
+
+#[cfg(any(with_macro_in_deps, only_macro_in_deps))]
+extern crate trait_macro as r#trait;
+
+#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))]
+extern crate trait_debuginfo as r#trait;
+
+#[cfg(not_diag_in_deps)]
+extern crate r#trait as r#trait;
+
+struct A;
+
+impl r#trait::Trait for A {}
+//[with-macro-in-deps]~^ ERROR `A` doesn't implement `std::fmt::Display`
+//[with-debuginfo-in-deps]~^^ ERROR `A` doesn't implement `std::fmt::Display`
+//[only-diag-in-deps]~^^^ ERROR `A` doesn't implement `std::fmt::Display`
+//[only-macro-in-deps]~^^^^ ERROR `A` doesn't implement `std::fmt::Display`
+//[only-debuginfo-in-deps]~^^^^^ ERROR `A` doesn't implement `std::fmt::Display`
+
+//[with-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display`
+//[not-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display`
+
+fn main() {}
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr
new file mode 100644
index 0000000000000..85c781425b16a
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `A` doesn't implement `std::fmt::Display`
+ --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
+ |
+LL | impl r#trait::Trait for A {}
+ | ^ `A` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `A`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Trait`
+ --> $DIR/auxiliary/trait-debuginfo.rs:LL:COL
+ |
+LL | pub trait Trait: std::fmt::Display {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr
new file mode 100644
index 0000000000000..08f7fb2c73642
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `A` doesn't implement `std::fmt::Display`
+ --> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL
+ |
+LL | impl r#trait::Trait for A {}
+ | ^ `A` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `A`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Trait`
+ --> remapped/errors/auxiliary/trait-diag.rs:LL:COL
+ |
+LL | pub trait Trait: std::fmt::Display {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr
new file mode 100644
index 0000000000000..d13333d2e4825
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `A` doesn't implement `std::fmt::Display`
+ --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
+ |
+LL | impl r#trait::Trait for A {}
+ | ^ `A` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `A`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Trait`
+ --> $DIR/auxiliary/trait-macro.rs:LL:COL
+ |
+LL | pub trait Trait: std::fmt::Display {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout b/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout
deleted file mode 100644
index 3bbdcbb8655b2..0000000000000
--- a/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout
+++ /dev/null
@@ -1 +0,0 @@
-remapped/errors/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.not-macro-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.not-macro-in-deps.run.stdout
new file mode 100644
index 0000000000000..13d4611ae543c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-macro.not-macro-in-deps.run.stdout
@@ -0,0 +1,3 @@
+file::my_file!() = remapped/errors/remap-path-prefix-macro.rs
+file::file() = $DIR/auxiliary/file.rs
+file!() = remapped/errors/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.only-debuginfo-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.only-debuginfo-in-deps.run.stdout
new file mode 100644
index 0000000000000..b2c62ac88c04c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-macro.only-debuginfo-in-deps.run.stdout
@@ -0,0 +1,3 @@
+file::my_file!() = $DIR/remap-path-prefix-macro.rs
+file::file() = $DIR/auxiliary/file-debuginfo.rs
+file!() = $DIR/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.only-diag-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.only-diag-in-deps.run.stdout
new file mode 100644
index 0000000000000..e64cc0723619c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-macro.only-diag-in-deps.run.stdout
@@ -0,0 +1,3 @@
+file::my_file!() = $DIR/remap-path-prefix-macro.rs
+file::file() = $DIR/auxiliary/file-diag.rs
+file!() = $DIR/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.only-macro-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.only-macro-in-deps.run.stdout
new file mode 100644
index 0000000000000..b1a93a5bc1ea2
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-macro.only-macro-in-deps.run.stdout
@@ -0,0 +1,3 @@
+file::my_file!() = $DIR/remap-path-prefix-macro.rs
+file::file() = remapped/errors/auxiliary/file-macro.rs
+file!() = $DIR/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.rs b/tests/ui/errors/remap-path-prefix-macro.rs
index 665156027c995..3e93843f91641 100644
--- a/tests/ui/errors/remap-path-prefix-macro.rs
+++ b/tests/ui/errors/remap-path-prefix-macro.rs
@@ -1,12 +1,47 @@
+// This test exercises `-Zremap-path-scope`, macros (like file!()) and dependency.
+//
+// We test different combinations with/without remap in deps, with/without remap in
+// this crate but always in deps and always here but never in deps.
+
//@ run-pass
//@ check-run-results
-//@ revisions: normal with-macro-scope without-macro-scope
-//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
-//@ [with-macro-scope]compile-flags: -Zremap-path-scope=macro,diagnostics
-//@ [without-macro-scope]compile-flags: -Zremap-path-scope=diagnostics
-// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
+//@ revisions: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps
+//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps
+//@ revisions: not-macro-in-deps
+
+//@[with-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@[with-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+//@[not-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
+
+//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
+//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro
+//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo
+//@[not-macro-in-deps] compile-flags: -Zremap-path-scope=macro
+
+//@[with-diag-in-deps] aux-build:file-diag.rs
+//@[with-macro-in-deps] aux-build:file-macro.rs
+//@[with-debuginfo-in-deps] aux-build:file-debuginfo.rs
+//@[only-diag-in-deps] aux-build:file-diag.rs
+//@[only-macro-in-deps] aux-build:file-macro.rs
+//@[only-debuginfo-in-deps] aux-build:file-debuginfo.rs
+//@[not-macro-in-deps] aux-build:file.rs
+
+#[cfg(any(with_diag_in_deps, only_diag_in_deps))]
+extern crate file_diag as file;
+
+#[cfg(any(with_macro_in_deps, only_macro_in_deps))]
+extern crate file_macro as file;
+
+#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))]
+extern crate file_debuginfo as file;
+
+#[cfg(not_macro_in_deps)]
+extern crate file;
fn main() {
- println!("{}", file!());
+ println!("file::my_file!() = {}", file::my_file!());
+ println!("file::file() = {}", file::file());
+ println!("file!() = {}", file!());
}
diff --git a/tests/ui/errors/remap-path-prefix-macro.with-debuginfo-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-debuginfo-in-deps.run.stdout
new file mode 100644
index 0000000000000..b2c62ac88c04c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-macro.with-debuginfo-in-deps.run.stdout
@@ -0,0 +1,3 @@
+file::my_file!() = $DIR/remap-path-prefix-macro.rs
+file::file() = $DIR/auxiliary/file-debuginfo.rs
+file!() = $DIR/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.with-diag-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-diag-in-deps.run.stdout
new file mode 100644
index 0000000000000..e64cc0723619c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-macro.with-diag-in-deps.run.stdout
@@ -0,0 +1,3 @@
+file::my_file!() = $DIR/remap-path-prefix-macro.rs
+file::file() = $DIR/auxiliary/file-diag.rs
+file!() = $DIR/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.with-macro-in-deps.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-macro-in-deps.run.stdout
new file mode 100644
index 0000000000000..5c1781dda1615
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-macro.with-macro-in-deps.run.stdout
@@ -0,0 +1,3 @@
+file::my_file!() = remapped/errors/remap-path-prefix-macro.rs
+file::file() = remapped/errors/auxiliary/file-macro.rs
+file!() = remapped/errors/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout
deleted file mode 100644
index 3bbdcbb8655b2..0000000000000
--- a/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout
+++ /dev/null
@@ -1 +0,0 @@
-remapped/errors/remap-path-prefix-macro.rs
diff --git a/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout b/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout
deleted file mode 100644
index 642823fec86a1..0000000000000
--- a/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout
+++ /dev/null
@@ -1 +0,0 @@
-$DIR/remap-path-prefix-macro.rs
diff --git a/tests/ui/pattern/normalize-ty-in-range.rs b/tests/ui/pattern/normalize-ty-in-range.rs
new file mode 100644
index 0000000000000..f0d22362608e1
--- /dev/null
+++ b/tests/ui/pattern/normalize-ty-in-range.rs
@@ -0,0 +1,24 @@
+//@ check-pass
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+
+// Regression test for .
+// Make sure we structurally normalize in range pattern checking in HIR typeck.
+
+trait Foo {
+ type Bar;
+}
+
+impl Foo for () {
+ type Bar = i32;
+}
+
+fn main() {
+ const X: <() as Foo>::Bar = 0;
+
+ match 0 {
+ X..=X => {}
+ _ => {}
+ }
+}
diff --git a/tests/ui/traits/object/constrain-via-unnecessary-bound.rs b/tests/ui/traits/object/constrain-via-unnecessary-bound.rs
new file mode 100644
index 0000000000000..4640d6b3ed593
--- /dev/null
+++ b/tests/ui/traits/object/constrain-via-unnecessary-bound.rs
@@ -0,0 +1,24 @@
+//@ check-pass
+
+// Regression test for .
+// Test that we lower impossible-to-satisfy associated type bounds, which
+// may for example constrain impl parameters.
+
+pub trait Other {}
+
+pub trait Trait {
+ type Assoc
+ where
+ Self: Sized;
+}
+
+impl Other for dyn Trait {}
+// `dyn Trait` is a different "nominal type" than `dyn Trait`.
+impl Other for dyn Trait {}
+//~^ WARN unnecessary associated type bound for dyn-incompatible associated type
+
+// I hope it's clear that `dyn Trait` (w/o `Assoc`) wouldn't match this impl.
+impl dyn Trait {}
+//~^ WARN unnecessary associated type bound for dyn-incompatible associated type
+
+fn main() {}
diff --git a/tests/ui/traits/object/constrain-via-unnecessary-bound.stderr b/tests/ui/traits/object/constrain-via-unnecessary-bound.stderr
new file mode 100644
index 0000000000000..4383ca869eacc
--- /dev/null
+++ b/tests/ui/traits/object/constrain-via-unnecessary-bound.stderr
@@ -0,0 +1,19 @@
+warning: unnecessary associated type bound for dyn-incompatible associated type
+ --> $DIR/constrain-via-unnecessary-bound.rs:17:26
+ |
+LL | impl Other for dyn Trait {}
+ | ^^^^^^^^^^ help: remove this bound
+ |
+ = note: this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized`
+ = note: `#[warn(unused_associated_type_bounds)]` on by default
+
+warning: unnecessary associated type bound for dyn-incompatible associated type
+ --> $DIR/constrain-via-unnecessary-bound.rs:21:19
+ |
+LL | impl dyn Trait {}
+ | ^^^^^^^^^ help: remove this bound
+ |
+ = note: this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized`
+
+warning: 2 warnings emitted
+
diff --git a/tests/ui/traits/object/pretty.stderr b/tests/ui/traits/object/pretty.stderr
index 37fe142951d89..2f9fdf151f08c 100644
--- a/tests/ui/traits/object/pretty.stderr
+++ b/tests/ui/traits/object/pretty.stderr
@@ -154,12 +154,12 @@ error[E0308]: mismatched types
--> $DIR/pretty.rs:41:56
|
LL | fn dyn_has_gat(x: &dyn HasGat = ()>) { x }
- | - ^ expected `()`, found `&dyn HasGat`
+ | - ^ expected `()`, found `&dyn HasGat = ()>`
| |
- | help: try adding a return type: `-> &dyn HasGat`
+ | help: try adding a return type: `-> &dyn HasGat = ()>`
|
= note: expected unit type `()`
- found reference `&dyn HasGat`
+ found reference `&dyn HasGat = ()>`
error: aborting due to 14 previous errors; 1 warning emitted
diff --git a/triagebot.toml b/triagebot.toml
index 57153f1d98ab5..b3a319037bd39 100644
--- a/triagebot.toml
+++ b/triagebot.toml
@@ -1397,3 +1397,7 @@ compiletest = [
# Enable issue transfers within the org
# Documentation at: https://forge.rust-lang.org/triagebot/transfer.html
[transfer]
+
+# Enable `@rustbot note` functionality
+# Documentation at: https://forge.rust-lang.org/triagebot/note.html
+[note]