diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
index d533e267fd702..d9a1193aac4ba 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
@@ -287,6 +287,7 @@ pub struct InferenceDiagnosticsData {
pub struct InferenceDiagnosticsParentData {
pub prefix: &'static str,
pub name: String,
+ pub def_id: DefId,
}
pub enum UnderspecifiedArgKind {
@@ -328,6 +329,7 @@ impl InferenceDiagnosticsParentData {
Some(InferenceDiagnosticsParentData {
prefix: tcx.def_kind(parent_def_id).descr(parent_def_id),
name: parent_name,
+ def_id: parent_def_id,
})
}
}
@@ -754,12 +756,30 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
if let (UnderspecifiedArgKind::Const { .. }, Some(parent_data)) =
(&arg_data.kind, &arg_data.parent)
{
- err.span_suggestion_verbose(
- span,
- "consider specifying the const argument",
- format!("{}::<{}>", parent_data.name, arg_data.name),
- Applicability::MaybeIncorrect,
- );
+ let has_impl_trait =
+ self.tcx.generics_of(parent_data.def_id).params.iter().any(|param| {
+ matches!(
+ param.kind,
+ ty::GenericParamDefKind::Type {
+ synthetic: Some(
+ hir::SyntheticTyParamKind::ImplTrait
+ | hir::SyntheticTyParamKind::FromAttr,
+ ),
+ ..
+ }
+ )
+ });
+
+ // (#83606): Do not emit a suggestion if the parent has an `impl Trait`
+ // as an argument otherwise it will cause the E0282 error.
+ if !has_impl_trait {
+ err.span_suggestion_verbose(
+ span,
+ "consider specifying the const argument",
+ format!("{}::<{}>", parent_data.name, arg_data.name),
+ Applicability::MaybeIncorrect,
+ );
+ }
}
err.span_label(
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index c1b105f1d8489..32f8a16908af9 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -28,6 +28,7 @@ use std::fmt;
use super::InferCtxtPrivExt;
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
+use rustc_middle::ty::print::with_no_trimmed_paths;
#[derive(Debug)]
pub enum GeneratorInteriorOrUpvar {
@@ -440,7 +441,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
{
// Missing generic type parameter bound.
let param_name = self_ty.to_string();
- let constraint = trait_ref.print_only_trait_path().to_string();
+ let constraint =
+ with_no_trimmed_paths(|| trait_ref.print_only_trait_path().to_string());
if suggest_constraining_type_param(
self.tcx,
generics,
diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs
index e64cbc18bf71b..2a3d44fb17d9f 100644
--- a/library/std/src/keyword_docs.rs
+++ b/library/std/src/keyword_docs.rs
@@ -547,15 +547,18 @@ mod fn_keyword {}
/// # fn code() { }
/// # let iterator = 0..2;
/// {
-/// let mut _iter = std::iter::IntoIterator::into_iter(iterator);
-/// loop {
-/// match _iter.next() {
-/// Some(loop_variable) => {
-/// code()
-/// },
-/// None => break,
-/// }
-/// }
+/// let result = match IntoIterator::into_iter(iterator) {
+/// mut iter => loop {
+/// let next;
+/// match iter.next() {
+/// Some(val) => next = val,
+/// None => break,
+/// };
+/// let loop_variable = next;
+/// let () = { code(); };
+/// },
+/// };
+/// result
/// }
/// ```
///
@@ -1310,7 +1313,11 @@ mod return_keyword {}
/// [Reference]: ../reference/items/associated-items.html#methods
mod self_keyword {}
-#[doc(keyword = "Self")]
+// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we can remove the
+// three next lines and put back: `#[doc(keyword = "Self")]`.
+#[doc(alias = "Self")]
+#[allow(rustc::existing_doc_keyword)]
+#[doc(keyword = "SelfTy")]
//
/// The implementing type within a [`trait`] or [`impl`] block, or the current type within a type
/// definition.
diff --git a/library/std/src/prelude/mod.rs b/library/std/src/prelude/mod.rs
index 505b5f3013b35..1b4facdd049bb 100644
--- a/library/std/src/prelude/mod.rs
+++ b/library/std/src/prelude/mod.rs
@@ -28,53 +28,53 @@
//! The current version of the prelude (version 1) lives in
//! [`std::prelude::v1`], and re-exports the following:
//!
-//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]}:
+//! * [std::marker]::{[Copy], [Send], [Sized], [Sync], [Unpin]}
,
//! marker traits that indicate fundamental properties of types.
-//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}: various
+//! * [std::ops]::{[Drop], [Fn], [FnMut], [FnOnce]}
, various
//! operations for both destructors and overloading `()`.
-//! * [`std::mem`]::[`drop`][`mem::drop`]: a convenience function for explicitly
+//! * [std::mem]::[drop][mem::drop]
, a convenience function for explicitly
//! dropping a value.
-//! * [`std::boxed`]::[`Box`]: a way to allocate values on the heap.
-//! * [`std::borrow`]::[`ToOwned`]: the conversion trait that defines
+//! * [std::boxed]::[Box]
, a way to allocate values on the heap.
+//! * [std::borrow]::[ToOwned]
, the conversion trait that defines
//! [`to_owned`], the generic method for creating an owned type from a
//! borrowed type.
-//! * [`std::clone`]::[`Clone`]: the ubiquitous trait that defines
-//! [`clone`][`Clone::clone`], the method for producing a copy of a value.
-//! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`]}: the
+//! * [std::clone]::[Clone]
, the ubiquitous trait that defines
+//! [`clone`][Clone::clone], the method for producing a copy of a value.
+//! * [std::cmp]::{[PartialEq], [PartialOrd], [Eq], [Ord]}
, the
//! comparison traits, which implement the comparison operators and are often
//! seen in trait bounds.
-//! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}: generic
+//! * [std::convert]::{[AsRef], [AsMut], [Into], [From]}
, generic
//! conversions, used by savvy API authors to create overloaded methods.
-//! * [`std::default`]::[`Default`], types that have default values.
-//! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`],
-//! [`DoubleEndedIterator`], [`ExactSizeIterator`]}: iterators of various
+//! * [std::default]::[Default]
, types that have default values.
+//! * [std::iter]::{[Iterator], [Extend], [IntoIterator], [DoubleEndedIterator], [ExactSizeIterator]}
,
+//! iterators of various
//! kinds.
-//! * [`std::option`]::[`Option`]::{[`self`][`Option`], [`Some`], [`None`]}, a
+//! * [std::option]::[Option]::{[self][Option], [Some], [None]}
, a
//! type which expresses the presence or absence of a value. This type is so
//! commonly used, its variants are also exported.
-//! * [`std::result`]::[`Result`]::{[`self`][`Result`], [`Ok`], [`Err`]}: a type
+//! * [std::result]::[Result]::{[self][Result], [Ok], [Err]}
, a type
//! for functions that may succeed or fail. Like [`Option`], its variants are
//! exported as well.
-//! * [`std::string`]::{[`String`], [`ToString`]}: heap-allocated strings.
-//! * [`std::vec`]::[`Vec`]: a growable, heap-allocated vector.
+//! * [std::string]::{[String], [ToString]}
, heap-allocated strings.
+//! * [std::vec]::[Vec]
, a growable, heap-allocated vector.
//!
-//! [`mem::drop`]: crate::mem::drop
-//! [`std::borrow`]: crate::borrow
-//! [`std::boxed`]: crate::boxed
-//! [`std::clone`]: crate::clone
-//! [`std::cmp`]: crate::cmp
-//! [`std::convert`]: crate::convert
-//! [`std::default`]: crate::default
-//! [`std::iter`]: crate::iter
-//! [`std::marker`]: crate::marker
-//! [`std::mem`]: crate::mem
-//! [`std::ops`]: crate::ops
-//! [`std::option`]: crate::option
+//! [mem::drop]: crate::mem::drop
+//! [std::borrow]: crate::borrow
+//! [std::boxed]: crate::boxed
+//! [std::clone]: crate::clone
+//! [std::cmp]: crate::cmp
+//! [std::convert]: crate::convert
+//! [std::default]: crate::default
+//! [std::iter]: crate::iter
+//! [std::marker]: crate::marker
+//! [std::mem]: crate::mem
+//! [std::ops]: crate::ops
+//! [std::option]: crate::option
//! [`std::prelude::v1`]: v1
-//! [`std::result`]: crate::result
-//! [`std::slice`]: crate::slice
-//! [`std::string`]: crate::string
-//! [`std::vec`]: mod@crate::vec
+//! [std::result]: crate::result
+//! [std::slice]: crate::slice
+//! [std::string]: crate::string
+//! [std::vec]: mod@crate::vec
//! [`to_owned`]: crate::borrow::ToOwned::to_owned
//! [book-closures]: ../../book/ch13-01-closures.html
//! [book-dtor]: ../../book/ch15-03-drop.html
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index f4976f2f436fc..adb0a372c64dd 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -108,6 +108,19 @@ impl Step for Linkcheck {
/// documentation to ensure we don't have a bunch of dead ones.
fn run(self, builder: &Builder<'_>) {
let host = self.host;
+ let hosts = &builder.hosts;
+ let targets = &builder.targets;
+
+ // if we have different hosts and targets, some things may be built for
+ // the host (e.g. rustc) and others for the target (e.g. std). The
+ // documentation built for each will contain broken links to
+ // docs built for the other platform (e.g. rustc linking to cargo)
+ if (hosts != targets) && !hosts.is_empty() && !targets.is_empty() {
+ panic!(
+ "Linkcheck currently does not support builds with different hosts and targets.
+You can skip linkcheck with --exclude src/tools/linkchecker"
+ );
+ }
builder.info(&format!("Linkcheck ({})", host));
@@ -123,19 +136,6 @@ impl Step for Linkcheck {
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
let run = run.path("src/tools/linkchecker");
- let hosts = &builder.hosts;
- let targets = &builder.targets;
-
- // if we have different hosts and targets, some things may be built for
- // the host (e.g. rustc) and others for the target (e.g. std). The
- // documentation built for each will contain broken links to
- // docs built for the other platform (e.g. rustc linking to cargo)
- if (hosts != targets) && !hosts.is_empty() && !targets.is_empty() {
- panic!(
- "Linkcheck currently does not support builds with different hosts and targets.
-You can skip linkcheck with --exclude src/tools/linkchecker"
- );
- }
run.default_condition(builder.config.docs)
}
diff --git a/src/test/ui/associated-types/defaults-suitability.stderr b/src/test/ui/associated-types/defaults-suitability.stderr
index 274d09fd09c86..af4e6f0a5c161 100644
--- a/src/test/ui/associated-types/defaults-suitability.stderr
+++ b/src/test/ui/associated-types/defaults-suitability.stderr
@@ -31,8 +31,8 @@ LL | type Bar: Clone = Vec;
= note: required because of the requirements on the impl of `Clone` for `Vec`
help: consider restricting type parameter `T`
|
-LL | trait Foo {
- | ^^^^^^^
+LL | trait Foo {
+ | ^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `(): Foo` is not satisfied
--> $DIR/defaults-suitability.rs:34:5
@@ -99,8 +99,8 @@ LL | type Baz = T;
|
help: consider further restricting type parameter `T`
|
-LL | Self::Baz: Clone, T: Clone
- | ^^^^^^^^^^
+LL | Self::Baz: Clone, T: std::clone::Clone
+ | ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
diff --git a/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr b/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr
index 02396bd00a59d..b6122bd54d162 100644
--- a/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr
+++ b/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr
@@ -9,8 +9,8 @@ LL | copy::>(t)
|
help: consider restricting type parameter `T`
|
-LL | pub fn copy_any(t: &T) -> T {
- | ^^^^^^
+LL | pub fn copy_any(t: &T) -> T {
+ | ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
diff --git a/src/test/ui/associated-types/issue-43784-associated-type.stderr b/src/test/ui/associated-types/issue-43784-associated-type.stderr
index d5105ae3b5815..0e653a7d3b22f 100644
--- a/src/test/ui/associated-types/issue-43784-associated-type.stderr
+++ b/src/test/ui/associated-types/issue-43784-associated-type.stderr
@@ -9,8 +9,8 @@ LL | type Assoc = T;
|
help: consider restricting type parameter `T`
|
-LL | impl Complete for T {
- | ^^^^^^
+LL | impl Complete for T {
+ | ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
diff --git a/src/test/ui/async-await/issue-70818.stderr b/src/test/ui/async-await/issue-70818.stderr
index 11fca2dd8ef4c..5f39cf6dde125 100644
--- a/src/test/ui/async-await/issue-70818.stderr
+++ b/src/test/ui/async-await/issue-70818.stderr
@@ -11,8 +11,8 @@ LL | async { (ty, ty1) }
| ^^^ has type `U` which is not `Send`
help: consider restricting type parameter `U`
|
-LL | fn foo(ty: T, ty1: U) -> impl Future