diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
index 506e2822a8745..573c08895255b 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
@@ -2972,8 +2972,40 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// `ExprKind::DropTemps` is semantically irrelevant for these suggestions.
let expr = expr.peel_drop_temps();
-
match (&expr.kind, expected.kind(), checked_ty.kind()) {
+ // Handle call arguments that need another shared or mutable reference, such as
+ // `&T` to `&&T` or `&T` to `&mut &T`.
+ // Keep ordinary `T` to `&T` cases on later path so its more
+ // specific suggestions, such as `Option::as_ref()`, are preserved.
+ (_, &ty::Ref(_, exp, mutability), _)
+ if exp.is_ref()
+ && matches!(
+ self.tcx.parent_hir_node(expr.hir_id),
+ hir::Node::Expr(hir::Expr {
+ kind:
+ hir::ExprKind::Call(_, args)
+ | hir::ExprKind::MethodCall(_, _, args, _),
+ ..
+ }) if args.iter().any(|arg| arg.hir_id == expr.hir_id)
+ )
+ && self.can_eq(self.param_env, exp, checked_ty) =>
+ {
+ let borrow = mutability.ref_prefix_str();
+ let sugg = if expr_needs_parens(expr) {
+ vec![
+ (sp.shrink_to_lo(), format!("{borrow}(")),
+ (sp.shrink_to_hi(), ")".to_string()),
+ ]
+ } else {
+ vec![(sp.shrink_to_lo(), borrow.to_string())]
+ };
+ return Some((
+ sugg,
+ format!("consider {}borrowing here", mutability.mutably_str()),
+ Applicability::MachineApplicable,
+ false,
+ ));
+ }
(_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (exp.kind(), check.kind()) {
(&ty::Str, &ty::Array(arr, _) | &ty::Slice(arr)) if arr == self.tcx.types.u8 => {
if let hir::ExprKind::Lit(_) = expr.kind
diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py
index 46a3a1602ac71..6011492ed27c9 100755
--- a/src/etc/htmldocck.py
+++ b/src/etc/htmldocck.py
@@ -624,8 +624,16 @@ def check_command(c, cache):
def check(target, commands):
cache = CachedFiles(target)
+ run_commands = 0
for c in commands:
check_command(c, cache)
+ run_commands += 1
+ if run_commands == 0 and os.environ.get("IS_RMAKE") is None:
+ stderr(
+ "\nNo check, move this file in `rustdoc-ui` testsuite if you want to check "
+ + "it doesn't crash"
+ )
+ raise SystemExit(1)
if __name__ == "__main__":
diff --git a/src/tools/compiletest/src/runtest/rustdoc.rs b/src/tools/compiletest/src/runtest/rustdoc.rs
index bee5c86ce62ed..03371e2f745c0 100644
--- a/src/tools/compiletest/src/runtest/rustdoc.rs
+++ b/src/tools/compiletest/src/runtest/rustdoc.rs
@@ -1,10 +1,19 @@
use super::{DocKind, TestCx, remove_and_create_dir_all};
use crate::util::ArgFileCommand;
+fn has_test_flag(flags: &[String]) -> bool {
+ flags.iter().any(|s| s == "--test")
+}
+
impl TestCx<'_> {
pub(super) fn run_rustdoc_html_test(&self) {
assert!(self.variant.revision.is_none(), "revisions not supported in this test suite");
+ if has_test_flag(&self.props.compile_flags) || has_test_flag(&self.props.doc_flags) {
+ panic!(
+ "If you want to check `--test`, put this test into `rustdoc-ui` testsuite instead",
+ );
+ }
let out_dir = self.output_base_dir();
remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| {
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
diff --git a/src/tools/run-make-support/src/external_deps/htmldocck.rs b/src/tools/run-make-support/src/external_deps/htmldocck.rs
index 621d386d85f71..50fd77be678cb 100644
--- a/src/tools/run-make-support/src/external_deps/htmldocck.rs
+++ b/src/tools/run-make-support/src/external_deps/htmldocck.rs
@@ -9,5 +9,6 @@ use crate::source_root;
pub fn htmldocck() -> Command {
let mut python = python_command();
python.arg(source_root().join("src/etc/htmldocck.py"));
+ python.env("IS_RMAKE", "1");
python
}
diff --git a/tests/rustdoc-gui/decl-macro-in-sidebar.goml b/tests/rustdoc-gui/decl-macro-in-sidebar.goml
new file mode 100644
index 0000000000000..d32fee94065c1
--- /dev/null
+++ b/tests/rustdoc-gui/decl-macro-in-sidebar.goml
@@ -0,0 +1,9 @@
+// This test ensures that the `foo` decl macro is present in the module sidebar.
+// Because these items are not generated into the HTML, we can't make them a `rustdoc-html`
+// test, so here we go...
+
+go-to: "file://" + |DOC_PATH| + "/test_docs/details/index.html"
+assert-text: (
+ '//*[@id="rustdoc-modnav"]/ul[@class="block macro"]//a[@href="../macro.decl_macro.html"]',
+ "decl_macro",
+)
diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs
index c9932dcf158aa..54db340e7ba64 100644
--- a/tests/rustdoc-gui/src/test_docs/lib.rs
+++ b/tests/rustdoc-gui/src/test_docs/lib.rs
@@ -14,6 +14,7 @@
#![feature(macro_derive)]
#![feature(negative_impls)]
#![feature(doc_notable_trait)]
+#![feature(decl_macro)]
/*!
Enable the feature some-feature to enjoy
@@ -822,3 +823,7 @@ pub mod notable {
pub struct Wrapper;
impl Labeled for Wrapper {}
}
+
+pub macro decl_macro {
+ () => { "bar" }
+}
diff --git a/tests/rustdoc-html/doc-cfg/extern-items.rs b/tests/rustdoc-html/doc-cfg/extern-items.rs
index 369f8a7b22ee9..bf5121639a7e3 100644
--- a/tests/rustdoc-html/doc-cfg/extern-items.rs
+++ b/tests/rustdoc-html/doc-cfg/extern-items.rs
@@ -5,15 +5,15 @@
#![feature(doc_cfg)]
#![crate_name = "foo"]
-//@has 'foo/index.html'
-//@count - '//*[@class="stab portability"]' 2
-//@has - '//*[@class="stab portability"]' 'Non-banana'
+//@ has 'foo/index.html'
+//@ count - '//*[@class="stab portability"]' 2
+//@ has - '//*[@class="stab portability"]' 'Non-banana'
-//@has 'foo/fn.doc_cfg_doesnt_work.html'
-//@has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
+//@ has 'foo/fn.doc_cfg_doesnt_work.html'
+//@ has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
-//@has 'foo/fn.doc_cfg_works.html'
-//@has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
+//@ has 'foo/fn.doc_cfg_works.html'
+//@ has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
unsafe extern "C" {
#[cfg(not(feature = "banana"))]
diff --git a/tests/rustdoc-html/doc-cfg/impl-foreign-type.rs b/tests/rustdoc-html/doc-cfg/impl-foreign-type.rs
index 81af598a55361..d28fa86c8ead5 100644
--- a/tests/rustdoc-html/doc-cfg/impl-foreign-type.rs
+++ b/tests/rustdoc-html/doc-cfg/impl-foreign-type.rs
@@ -6,8 +6,8 @@
#![feature(doc_cfg)]
#![crate_name = "foo"]
-//@has 'foo/trait.Blob.html'
-//@has - '//*[@id="impl-Blob-for-Box%3CR%3E"]//*[@class="stab portability"]' 'Available on non-crate feature alloc only.'
+//@ has 'foo/trait.Blob.html'
+//@ has - '//*[@id="impl-Blob-for-Box%3CR%3E"]//*[@class="stab portability"]' 'Available on non-crate feature alloc only.'
pub trait Blob {}
diff --git a/tests/rustdoc-html/doc-cfg/reexports.rs b/tests/rustdoc-html/doc-cfg/reexports.rs
index a5f54155ab2d4..25f40ae648050 100644
--- a/tests/rustdoc-html/doc-cfg/reexports.rs
+++ b/tests/rustdoc-html/doc-cfg/reexports.rs
@@ -6,17 +6,17 @@
#![feature(doc_cfg)]
#![crate_name = "foo"]
-//@has 'foo/struct.FlatBanana.html'
-//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature banana and non-crate feature yoyo only.'
+//@ has 'foo/struct.FlatBanana.html'
+//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature banana and non-crate feature yoyo only.'
-//@has 'foo/struct.SubBanana.html'
-//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana and non-crate feature yoyo only.'
+//@ has 'foo/struct.SubBanana.html'
+//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana and non-crate feature yoyo only.'
#[cfg(not(feature = "yoyo"))]
pub use self::banana::*;
-//@has 'foo/struct.Yolo.html'
-//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
+//@ has 'foo/struct.Yolo.html'
+//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
pub use self::banana::SubBanana as Yolo;
#[cfg(not(feature = "banana"))]
diff --git a/tests/rustdoc-html/doc-cfg/trait-impls-manual.rs b/tests/rustdoc-html/doc-cfg/trait-impls-manual.rs
index 4329d8e06dfc5..890c484c1e1de 100644
--- a/tests/rustdoc-html/doc-cfg/trait-impls-manual.rs
+++ b/tests/rustdoc-html/doc-cfg/trait-impls-manual.rs
@@ -22,36 +22,36 @@ pub trait Foo {
pub struct X;
-//@has 'foo/struct.X.html'
-//@count - '//*[@id="impl-Bob-for-X"]' 1
-//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
-//@count - '//*[@id="impl-Trait-for-X"]' 1
-//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
+//@ has 'foo/struct.X.html'
+//@ count - '//*[@id="impl-Bob-for-X"]' 1
+//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 1
+//@ count - '//*[@id="impl-Trait-for-X"]' 1
+//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 1
// If you need to update this XPath, in particular `item-info`, update all
// the others in this file.
-//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
+//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
-//@has 'foo/trait.Trait.html'
-//@count - '//*[@id="impl-Trait-for-X"]' 1
-//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
+//@ has 'foo/trait.Trait.html'
+//@ count - '//*[@id="impl-Trait-for-X"]' 1
+//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 1
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp {
impl super::Trait for super::X { fn f(&self) {} }
}
-//@has 'foo/trait.Bob.html'
-//@count - '//*[@id="impl-Bob-for-X"]' 1
-//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
+//@ has 'foo/trait.Bob.html'
+//@ count - '//*[@id="impl-Bob-for-X"]' 1
+//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 1
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg = false)]
mod imp2 {
impl super::Bob for super::X { fn bob(&self) {} }
}
-//@has 'foo/trait.Foo.html'
-//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
+//@ has 'foo/trait.Foo.html'
+//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
// We use this to force xpath tests to be updated if `item-info` class is changed.
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
mod imp3 {
@@ -60,9 +60,9 @@ mod imp3 {
pub struct Y;
-//@has 'foo/struct.Y.html'
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
+//@ has 'foo/struct.Y.html'
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp4 {
@@ -71,9 +71,9 @@ mod imp4 {
pub struct Z;
-//@has 'foo/struct.Z.html'
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
+//@ has 'foo/struct.Z.html'
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg = false)]
mod imp5 {
@@ -83,9 +83,9 @@ mod imp5 {
// The "witness" which has the item info.
pub struct W;
-//@has 'foo/struct.W.html'
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 1
+//@ has 'foo/struct.W.html'
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 1
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
mod imp6 {
impl super::W { pub fn plain_auto() {} }
diff --git a/tests/rustdoc-html/doc-cfg/trait-impls.rs b/tests/rustdoc-html/doc-cfg/trait-impls.rs
index 9ea6490ae8e21..4242e57bf434f 100644
--- a/tests/rustdoc-html/doc-cfg/trait-impls.rs
+++ b/tests/rustdoc-html/doc-cfg/trait-impls.rs
@@ -1,6 +1,9 @@
// This test ensures that `doc_cfg` feature is working as expected on trait impls.
// Regression test for .
+//@ only-linux
+//@ only-x86_64
+
#![feature(doc_cfg)]
#![doc(auto_cfg(hide(
target_pointer_width, values("64"),
@@ -22,36 +25,36 @@ pub trait Foo {
pub struct X;
-//@has 'foo/struct.X.html'
-//@count - '//*[@id="impl-Bob-for-X"]' 1
-//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
-//@count - '//*[@id="impl-Trait-for-X"]' 1
-//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
+//@ has 'foo/struct.X.html'
+//@ count - '//*[@id="impl-Bob-for-X"]' 1
+//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
+//@ count - '//*[@id="impl-Trait-for-X"]' 1
+//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
// If you need to update this XPath, in particular `item-info`, update all
// the others in this file.
-//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
+//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
-//@has 'foo/trait.Trait.html'
-//@count - '//*[@id="impl-Trait-for-X"]' 1
-//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
+//@ has 'foo/trait.Trait.html'
+//@ count - '//*[@id="impl-Trait-for-X"]' 1
+//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp {
impl super::Trait for super::X { fn f(&self) {} }
}
-//@has 'foo/trait.Bob.html'
-//@count - '//*[@id="impl-Bob-for-X"]' 1
-//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
+//@ has 'foo/trait.Bob.html'
+//@ count - '//*[@id="impl-Bob-for-X"]' 1
+//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg = false)]
mod imp2 {
impl super::Bob for super::X { fn bob(&self) {} }
}
-//@has 'foo/trait.Foo.html'
-//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
+//@ has 'foo/trait.Foo.html'
+//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
// We use this to force xpath tests to be updated if `item-info` class is changed.
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
mod imp3 {
@@ -60,9 +63,9 @@ mod imp3 {
pub struct Y;
-//@has 'foo/struct.Y.html'
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
+//@ has 'foo/struct.Y.html'
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp4 {
@@ -71,9 +74,9 @@ mod imp4 {
pub struct Z;
-//@has 'foo/struct.Z.html'
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
+//@ has 'foo/struct.Z.html'
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg = false)]
mod imp5 {
@@ -83,9 +86,9 @@ mod imp5 {
// The "witness" which has the item info.
pub struct W;
-//@has 'foo/struct.W.html'
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
-//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 1
+//@ has 'foo/struct.W.html'
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
+//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]//*[@class="item-info"]' 1
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
mod imp6 {
impl super::W { pub fn plain_auto() {} }
diff --git a/tests/rustdoc-html/duplicate_impls/impls.rs b/tests/rustdoc-html/duplicate_impls/auxiliary/impls.rs
similarity index 100%
rename from tests/rustdoc-html/duplicate_impls/impls.rs
rename to tests/rustdoc-html/duplicate_impls/auxiliary/impls.rs
diff --git a/tests/rustdoc-html/duplicate_impls/sidebar-links-duplicate-impls-33054.rs b/tests/rustdoc-html/duplicate_impls/sidebar-links-duplicate-impls-33054.rs
index 511a40c38a0a2..84637a6aea3d6 100644
--- a/tests/rustdoc-html/duplicate_impls/sidebar-links-duplicate-impls-33054.rs
+++ b/tests/rustdoc-html/duplicate_impls/sidebar-links-duplicate-impls-33054.rs
@@ -10,6 +10,7 @@
//@ has foo/impls/bar/trait.Bar.html
//@ has - '//h3[@class="code-header"]' 'impl Bar for Foo'
//@ count - '//*[@class="struct"]' 1
+#[path = "auxiliary/impls.rs"]
pub mod impls;
#[doc(inline)]
diff --git a/tests/rustdoc-html/macro/decl_macro-sidebar.rs b/tests/rustdoc-html/macro/decl_macro-sidebar.rs
deleted file mode 100644
index 468b36c746db3..0000000000000
--- a/tests/rustdoc-html/macro/decl_macro-sidebar.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// This test ensures that the `foo` decl macro is present in the module sidebar.
-
-#![feature(decl_macro)]
-#![crate_name = "foo"]
-
-//@has 'foo/bar/index.html'
-//@has - '//*[@id="rustdoc-modnav"]/ul[@class="block macro"]//a[@href="../macro.foo.html"]' 'foo'
-
-pub macro foo {
- () => { "bar" }
-}
-
-/// docs
-pub mod bar {
-}
diff --git a/tests/rustdoc-html/auto/auto-impl-for-trait.rs b/tests/rustdoc-ui/auto/auto-impl-for-trait.rs
similarity index 94%
rename from tests/rustdoc-html/auto/auto-impl-for-trait.rs
rename to tests/rustdoc-ui/auto/auto-impl-for-trait.rs
index bc658fbfc8cce..8849a25458457 100644
--- a/tests/rustdoc-html/auto/auto-impl-for-trait.rs
+++ b/tests/rustdoc-ui/auto/auto-impl-for-trait.rs
@@ -1,5 +1,7 @@
// Test for https://github.com/rust-lang/rust/issues/48463 issue.
+//@ check-pass
+
use std::any::Any;
use std::ops::Deref;
diff --git a/tests/rustdoc-html/constant/document-item-with-associated-const-in-where-clause.rs b/tests/rustdoc-ui/constant/document-item-with-associated-const-in-where-clause.rs
similarity index 94%
rename from tests/rustdoc-html/constant/document-item-with-associated-const-in-where-clause.rs
rename to tests/rustdoc-ui/constant/document-item-with-associated-const-in-where-clause.rs
index c9408ef3360b4..9c16fa0b9b4fa 100644
--- a/tests/rustdoc-html/constant/document-item-with-associated-const-in-where-clause.rs
+++ b/tests/rustdoc-ui/constant/document-item-with-associated-const-in-where-clause.rs
@@ -1,6 +1,8 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
+//@ check-pass
+
pub trait Enumerable {
const N: usize;
}
diff --git a/tests/rustdoc-html/deep-structures.rs b/tests/rustdoc-ui/deep-structures.rs
similarity index 99%
rename from tests/rustdoc-html/deep-structures.rs
rename to tests/rustdoc-ui/deep-structures.rs
index cd3b0d3ec9706..e763f6bbf652c 100644
--- a/tests/rustdoc-html/deep-structures.rs
+++ b/tests/rustdoc-ui/deep-structures.rs
@@ -1,6 +1,8 @@
// This test verifies that we do not hit recursion limit trying to prove auto-trait bounds for
// reasonably deep structures.
+//@ check-pass
+
#![crate_type="rlib"]
pub struct A01(A02);
diff --git a/tests/rustdoc-html/type-alias/deeply-nested-112515.rs b/tests/rustdoc-ui/deeply-nested-112515.rs
similarity index 95%
rename from tests/rustdoc-html/type-alias/deeply-nested-112515.rs
rename to tests/rustdoc-ui/deeply-nested-112515.rs
index 9530feb78de66..81b11cca1ac90 100644
--- a/tests/rustdoc-html/type-alias/deeply-nested-112515.rs
+++ b/tests/rustdoc-ui/deeply-nested-112515.rs
@@ -2,7 +2,9 @@
// It's to ensure that this code doesn't have infinite loop in rustdoc when
// trying to retrieve type alias implementations.
-// ignore-tidy-linelength
+// ignore-tidy-file-linelength
+
+//@ check-pass
pub type Boom = S, ()>, ()>, ()>, u8>, ()>, u8>, ()>, u8>, u8>, ()>, ()>, ()>, u8>, u8>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, u8>, ()>, ()>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, u8>, u8>, u8>, ()>, u8>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>;
pub struct S(T, U);
diff --git a/tests/rustdoc-html/empty-doc-comment.rs b/tests/rustdoc-ui/empty-doc-comment.rs
similarity index 91%
rename from tests/rustdoc-html/empty-doc-comment.rs
rename to tests/rustdoc-ui/empty-doc-comment.rs
index b1dae930e066b..7543553e60d56 100644
--- a/tests/rustdoc-html/empty-doc-comment.rs
+++ b/tests/rustdoc-ui/empty-doc-comment.rs
@@ -1,5 +1,7 @@
// Ensure that empty doc comments don't panic.
+//@ check-pass
+
/*!
*/
diff --git a/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs b/tests/rustdoc-ui/intra-doc/ice-deprecated-note-on-reexport.rs
similarity index 96%
rename from tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs
rename to tests/rustdoc-ui/intra-doc/ice-deprecated-note-on-reexport.rs
index 99415a9a2fd4a..43ec497d9de7a 100644
--- a/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs
+++ b/tests/rustdoc-ui/intra-doc/ice-deprecated-note-on-reexport.rs
@@ -4,6 +4,8 @@
//
// This is a regression test for .
+//@ check-pass
+
#![crate_name = "foo"]
#[deprecated(note = "use [`std::mem::forget`]")]
diff --git a/tests/rustdoc-html/intra-doc/in-bodies.rs b/tests/rustdoc-ui/intra-doc/in-bodies.rs
similarity index 97%
rename from tests/rustdoc-html/intra-doc/in-bodies.rs
rename to tests/rustdoc-ui/intra-doc/in-bodies.rs
index 55169e5d3c459..69ebe459b681f 100644
--- a/tests/rustdoc-html/intra-doc/in-bodies.rs
+++ b/tests/rustdoc-ui/intra-doc/in-bodies.rs
@@ -1,5 +1,7 @@
// we need to make sure that intra-doc links on trait impls get resolved in the right scope
+//@ check-pass
+
#![deny(rustdoc::broken_intra_doc_links)]
pub mod inner {
diff --git a/tests/rustdoc-html/intra-doc/libstd-re-export.rs b/tests/rustdoc-ui/intra-doc/libstd-re-export.rs
similarity index 85%
rename from tests/rustdoc-html/intra-doc/libstd-re-export.rs
rename to tests/rustdoc-ui/intra-doc/libstd-re-export.rs
index 6c41eb2b5b7c3..29cf3f8b295c7 100644
--- a/tests/rustdoc-html/intra-doc/libstd-re-export.rs
+++ b/tests/rustdoc-ui/intra-doc/libstd-re-export.rs
@@ -1,3 +1,5 @@
+//@ check-pass
+
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(intra_doc_pointers)]
diff --git a/tests/rustdoc-html/intra-doc/private-failures-ignored.rs b/tests/rustdoc-ui/intra-doc/private-failures-ignored.rs
similarity index 95%
rename from tests/rustdoc-html/intra-doc/private-failures-ignored.rs
rename to tests/rustdoc-ui/intra-doc/private-failures-ignored.rs
index b272bfb5a4df2..c36947286b57b 100644
--- a/tests/rustdoc-html/intra-doc/private-failures-ignored.rs
+++ b/tests/rustdoc-ui/intra-doc/private-failures-ignored.rs
@@ -2,6 +2,8 @@
// These failures were legitimate, but not truly relevant - the docs in question couldn't be
// checked for accuracy anyway.
+//@ check-pass
+
#![deny(rustdoc::broken_intra_doc_links)]
/// ooh, i'm a [rebel] just for kicks
diff --git a/tests/rustdoc-html/macro/doc-proc-macro.rs b/tests/rustdoc-ui/macro/doc-proc-macro.rs
similarity index 94%
rename from tests/rustdoc-html/macro/doc-proc-macro.rs
rename to tests/rustdoc-ui/macro/doc-proc-macro.rs
index 19172ffa41deb..c1e53b24eb2f2 100644
--- a/tests/rustdoc-html/macro/doc-proc-macro.rs
+++ b/tests/rustdoc-ui/macro/doc-proc-macro.rs
@@ -3,6 +3,8 @@
// As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't
// crash when we try.
+//@ check-pass
+
extern crate proc_macro;
pub use proc_macro::*;
diff --git a/tests/rustdoc-html/macro/macro-ice-16019.rs b/tests/rustdoc-ui/macro/macro-ice-16019.rs
similarity index 89%
rename from tests/rustdoc-html/macro/macro-ice-16019.rs
rename to tests/rustdoc-ui/macro/macro-ice-16019.rs
index d0f82e0a314ce..fc217434d3811 100644
--- a/tests/rustdoc-html/macro/macro-ice-16019.rs
+++ b/tests/rustdoc-ui/macro/macro-ice-16019.rs
@@ -1,11 +1,13 @@
// https://github.com/rust-lang/rust/issues/16019
+//@ check-pass
+
macro_rules! define_struct {
($rounds:expr) => (
struct Struct {
sk: [u32; $rounds + 1]
}
- )
+ )
}
define_struct!(2);
diff --git a/tests/rustdoc-html/macro/macro-in-closure.rs b/tests/rustdoc-ui/macro/macro-in-closure.rs
similarity index 94%
rename from tests/rustdoc-html/macro/macro-in-closure.rs
rename to tests/rustdoc-ui/macro/macro-in-closure.rs
index b4411d927e271..adf87516c793f 100644
--- a/tests/rustdoc-html/macro/macro-in-closure.rs
+++ b/tests/rustdoc-ui/macro/macro-in-closure.rs
@@ -1,5 +1,7 @@
// Regression issue for rustdoc ICE encountered in PR #65252.
+//@ check-pass
+
#![feature(decl_macro)]
fn main() {
diff --git a/tests/rustdoc-html/markdown-60482.rs b/tests/rustdoc-ui/markdown-60482.rs
similarity index 93%
rename from tests/rustdoc-html/markdown-60482.rs
rename to tests/rustdoc-ui/markdown-60482.rs
index e40af12e02258..4d817f3fe99e9 100644
--- a/tests/rustdoc-html/markdown-60482.rs
+++ b/tests/rustdoc-ui/markdown-60482.rs
@@ -1,8 +1,9 @@
// This code caused a panic in `pulldown-cmark` 0.4.1.
// https://github.com/rust-lang/rust/issues/60482
-pub const BASIC_UNICODE: bool = true;
+//@ check-pass
+pub const BASIC_UNICODE: bool = true;
/// # `BASIC_UNICODE`: `A` `|`
/// ```text
diff --git a/tests/rustdoc-html/private/private-use.rs b/tests/rustdoc-ui/private/private-use.rs
similarity index 95%
rename from tests/rustdoc-html/private/private-use.rs
rename to tests/rustdoc-ui/private/private-use.rs
index 689ed73140d98..c2185f10d4059 100644
--- a/tests/rustdoc-html/private/private-use.rs
+++ b/tests/rustdoc-ui/private/private-use.rs
@@ -1,6 +1,8 @@
// Regression test for to
// ensure it doesn't panic.
+//@ check-pass
+
mod generics {
pub enum WherePredicate {
EqPredicate,
diff --git a/tests/rustdoc-html/recursion1.rs b/tests/rustdoc-ui/recursion/recursion1.rs
similarity index 90%
rename from tests/rustdoc-html/recursion1.rs
rename to tests/rustdoc-ui/recursion/recursion1.rs
index edf7e440fe7c4..c477510b89e11 100644
--- a/tests/rustdoc-html/recursion1.rs
+++ b/tests/rustdoc-ui/recursion/recursion1.rs
@@ -1,3 +1,5 @@
+//@ check-pass
+
#![crate_type = "lib"]
mod m {
diff --git a/tests/rustdoc-html/recursion2.rs b/tests/rustdoc-ui/recursion/recursion2.rs
similarity index 90%
rename from tests/rustdoc-html/recursion2.rs
rename to tests/rustdoc-ui/recursion/recursion2.rs
index edf7e440fe7c4..c477510b89e11 100644
--- a/tests/rustdoc-html/recursion2.rs
+++ b/tests/rustdoc-ui/recursion/recursion2.rs
@@ -1,3 +1,5 @@
+//@ check-pass
+
#![crate_type = "lib"]
mod m {
diff --git a/tests/rustdoc-html/recursion3.rs b/tests/rustdoc-ui/recursion/recursion3.rs
similarity index 95%
rename from tests/rustdoc-html/recursion3.rs
rename to tests/rustdoc-ui/recursion/recursion3.rs
index e69b4301646b7..e65632b830678 100644
--- a/tests/rustdoc-html/recursion3.rs
+++ b/tests/rustdoc-ui/recursion/recursion3.rs
@@ -1,3 +1,5 @@
+//@ check-pass
+
pub mod longhands {
pub use super::*;
diff --git a/tests/rustdoc-html/resolve-ice-124363.rs b/tests/rustdoc-ui/resolve-ice-124363.rs
similarity index 80%
rename from tests/rustdoc-html/resolve-ice-124363.rs
rename to tests/rustdoc-ui/resolve-ice-124363.rs
index 111916cc59050..a790972a53f2e 100644
--- a/tests/rustdoc-html/resolve-ice-124363.rs
+++ b/tests/rustdoc-ui/resolve-ice-124363.rs
@@ -1,3 +1,5 @@
+//@ check-pass
+
/**
*/
pub mod A {
diff --git a/tests/rustdoc-html/synthetic_auto/issue-72213-projection-lifetime.rs b/tests/rustdoc-ui/synthetic-auto-trait-impls/issue-72213-projection-lifetime.rs
similarity index 96%
rename from tests/rustdoc-html/synthetic_auto/issue-72213-projection-lifetime.rs
rename to tests/rustdoc-ui/synthetic-auto-trait-impls/issue-72213-projection-lifetime.rs
index 6f66b8e556388..660672f01192c 100644
--- a/tests/rustdoc-html/synthetic_auto/issue-72213-projection-lifetime.rs
+++ b/tests/rustdoc-ui/synthetic-auto-trait-impls/issue-72213-projection-lifetime.rs
@@ -2,6 +2,8 @@
// Tests that we don't ICE when we have projection predicates
// in our initial ParamEnv
+//@ check-pass
+
pub struct Lines<'a, L>
where
L: Iterator- ,
diff --git a/tests/rustdoc-ui/type-alias/deeply-nested-112515.rs b/tests/rustdoc-ui/type-alias/deeply-nested-112515.rs
new file mode 100644
index 0000000000000..81b11cca1ac90
--- /dev/null
+++ b/tests/rustdoc-ui/type-alias/deeply-nested-112515.rs
@@ -0,0 +1,32 @@
+// Regression test for .
+// It's to ensure that this code doesn't have infinite loop in rustdoc when
+// trying to retrieve type alias implementations.
+
+// ignore-tidy-file-linelength
+
+//@ check-pass
+
+pub type Boom = S
, ()>, ()>, ()>, u8>, ()>, u8>, ()>, u8>, u8>, ()>, ()>, ()>, u8>, u8>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, u8>, ()>, ()>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, u8>, u8>, u8>, ()>, u8>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>;
+pub struct S(T, U);
+
+pub trait A {}
+
+pub trait B {
+ type P;
+}
+
+impl A for u64 {}
+
+impl A for S {}
+
+impl B for S
+where
+ T: B,
+ >::P: A,
+{
+ type P = ();
+}
+
+impl B for S {
+ type P = ();
+}
diff --git a/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.fixed b/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.fixed
new file mode 100644
index 0000000000000..1e414476c34a1
--- /dev/null
+++ b/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.fixed
@@ -0,0 +1,44 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/78613.
+//! A call argument that needs one more reference should suggest borrowing it.
+
+//@ run-rustfix
+
+fn takes_nested_ref(_: &&str) {}
+
+fn takes_generic_nested_ref(_: &&T) {}
+
+fn takes_nested_mut_ref(_: &mut &str) {}
+
+fn takes_ref(_: &i32) {}
+
+struct Foo;
+
+fn takes_foo_ref(_: &Foo) {}
+
+fn main() {
+ let haystack = [&["A1", "A2"][..], &["B1", "B2"], &["C1", "C2"]];
+ let needle: &[&str] = &["D1", "D2"];
+ let _ = haystack.contains(&needle);
+ //~^ ERROR mismatched types
+
+ let text = "text";
+ takes_nested_ref(&text);
+ //~^ ERROR mismatched types
+
+ let number = &1;
+ takes_generic_nested_ref(&number);
+ //~^ ERROR mismatched types
+
+ let mut mutable_text = text;
+ takes_nested_mut_ref(&mut mutable_text);
+ //~^ ERROR mismatched types
+
+ takes_ref(if true { &1 } else { &2 });
+ //~^ ERROR mismatched types
+ //~| ERROR mismatched types
+
+ // Ordinary `T` to `&T` cases should retain more specific suggestions from the existing path.
+ let ref opt = Some(Foo);
+ opt.as_ref().map(|arg| takes_foo_ref(arg));
+ //~^ ERROR mismatched types
+}
diff --git a/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.rs b/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.rs
new file mode 100644
index 0000000000000..98cffb0aeabc8
--- /dev/null
+++ b/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.rs
@@ -0,0 +1,44 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/78613.
+//! A call argument that needs one more reference should suggest borrowing it.
+
+//@ run-rustfix
+
+fn takes_nested_ref(_: &&str) {}
+
+fn takes_generic_nested_ref(_: &&T) {}
+
+fn takes_nested_mut_ref(_: &mut &str) {}
+
+fn takes_ref(_: &i32) {}
+
+struct Foo;
+
+fn takes_foo_ref(_: &Foo) {}
+
+fn main() {
+ let haystack = [&["A1", "A2"][..], &["B1", "B2"], &["C1", "C2"]];
+ let needle: &[&str] = &["D1", "D2"];
+ let _ = haystack.contains(needle);
+ //~^ ERROR mismatched types
+
+ let text = "text";
+ takes_nested_ref(text);
+ //~^ ERROR mismatched types
+
+ let number = &1;
+ takes_generic_nested_ref(number);
+ //~^ ERROR mismatched types
+
+ let mut mutable_text = text;
+ takes_nested_mut_ref(mutable_text);
+ //~^ ERROR mismatched types
+
+ takes_ref(if true { 1 } else { 2 });
+ //~^ ERROR mismatched types
+ //~| ERROR mismatched types
+
+ // Ordinary `T` to `&T` cases should retain more specific suggestions from the existing path.
+ let ref opt = Some(Foo);
+ opt.map(|arg| takes_foo_ref(arg));
+ //~^ ERROR mismatched types
+}
diff --git a/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.stderr b/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.stderr
new file mode 100644
index 0000000000000..f0d0deff599db
--- /dev/null
+++ b/tests/ui/mismatched_types/suggest-extra-borrow-issue-78613.stderr
@@ -0,0 +1,120 @@
+error[E0308]: mismatched types
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:21:31
+ |
+LL | let _ = haystack.contains(needle);
+ | -------- ^^^^^^ expected `&&[&str]`, found `&[&str]`
+ | |
+ | arguments to this method are incorrect
+ |
+ = note: expected reference `&&[&str]`
+ found reference `&[&str]`
+note: method defined here
+ --> $SRC_DIR/core/src/slice/mod.rs:LL:COL
+help: consider borrowing here
+ |
+LL | let _ = haystack.contains(&needle);
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:25:22
+ |
+LL | takes_nested_ref(text);
+ | ---------------- ^^^^ expected `&&str`, found `&str`
+ | |
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&&_`
+ found reference `&_`
+note: function defined here
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:6:4
+ |
+LL | fn takes_nested_ref(_: &&str) {}
+ | ^^^^^^^^^^^^^^^^ --------
+help: consider borrowing here
+ |
+LL | takes_nested_ref(&text);
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:29:30
+ |
+LL | takes_generic_nested_ref(number);
+ | ------------------------ ^^^^^^ expected `&&_`, found `&{integer}`
+ | |
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&&_`
+ found reference `&{integer}`
+note: function defined here
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:8:4
+ |
+LL | fn takes_generic_nested_ref(_: &&T) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ ------
+help: consider borrowing here
+ |
+LL | takes_generic_nested_ref(&number);
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:33:26
+ |
+LL | takes_nested_mut_ref(mutable_text);
+ | -------------------- ^^^^^^^^^^^^ types differ in mutability
+ | |
+ | arguments to this function are incorrect
+ |
+ = note: expected mutable reference `&mut &_`
+ found reference `&_`
+note: function defined here
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:10:4
+ |
+LL | fn takes_nested_mut_ref(_: &mut &str) {}
+ | ^^^^^^^^^^^^^^^^^^^^ ------------
+help: consider mutably borrowing here
+ |
+LL | takes_nested_mut_ref(&mut mutable_text);
+ | ++++
+
+error[E0308]: mismatched types
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:36:25
+ |
+LL | takes_ref(if true { 1 } else { 2 });
+ | ^ expected `&i32`, found integer
+ |
+help: consider borrowing here
+ |
+LL | takes_ref(if true { &1 } else { 2 });
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:36:36
+ |
+LL | takes_ref(if true { 1 } else { 2 });
+ | ^ expected `&i32`, found integer
+ |
+help: consider borrowing here
+ |
+LL | takes_ref(if true { 1 } else { &2 });
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:42:33
+ |
+LL | opt.map(|arg| takes_foo_ref(arg));
+ | ------------- ^^^ expected `&Foo`, found `Foo`
+ | |
+ | arguments to this function are incorrect
+ |
+note: function defined here
+ --> $DIR/suggest-extra-borrow-issue-78613.rs:16:4
+ |
+LL | fn takes_foo_ref(_: &Foo) {}
+ | ^^^^^^^^^^^^^ -------
+help: consider using `as_ref` instead
+ |
+LL | opt.as_ref().map(|arg| takes_foo_ref(arg));
+ | +++++++++
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0308`.