rust/tests/rustdoc-ui
Michael Goulet f41ad1bc9c
Rollup merge of #119148 - estebank:bare-traits, r=davidtwco
Tweak suggestions for bare trait used as a type

```
error[E0782]: trait objects must include the `dyn` keyword
  --> $DIR/not-on-bare-trait-2021.rs:11:11
   |
LL | fn bar(x: Foo) -> Foo {
   |           ^^^
   |
help: use a generic type parameter, constrained by the trait `Foo`
   |
LL | fn bar<T: Foo>(x: T) -> Foo {
   |       ++++++++    ~
help: you can also use `impl Foo`, but users won't be able to specify the type paramer when calling the `fn`, having to rely exclusively on type inference
   |
LL | fn bar(x: impl Foo) -> Foo {
   |           ++++
help: alternatively, use a trait object to accept any type that implements `Foo`, accessing its methods at runtime using dynamic dispatch
   |
LL | fn bar(x: &dyn Foo) -> Foo {
   |           ++++

error[E0782]: trait objects must include the `dyn` keyword
  --> $DIR/not-on-bare-trait-2021.rs:11:19
   |
LL | fn bar(x: Foo) -> Foo {
   |                   ^^^
   |
help: use `impl Foo` to return an opaque type, as long as you return a single underlying type
   |
LL | fn bar(x: Foo) -> impl Foo {
   |                   ++++
help: alternatively, you can return an owned trait object
   |
LL | fn bar(x: Foo) -> Box<dyn Foo> {
   |                   +++++++    +
```

Fix #119525:

```

error[E0038]: the trait `Ord` cannot be made into an object
  --> $DIR/bare-trait-dont-suggest-dyn.rs:3:33
   |
LL | fn ord_prefer_dot(s: String) -> Ord {
   |                                 ^^^ `Ord` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> $SRC_DIR/core/src/cmp.rs:LL:COL
   |
   = note: the trait cannot be made into an object because it uses `Self` as a type parameter
  ::: $SRC_DIR/core/src/cmp.rs:LL:COL
   |
   = note: the trait cannot be made into an object because it uses `Self` as a type parameter
help: consider using an opaque type instead
   |
LL | fn ord_prefer_dot(s: String) -> impl Ord {
   |                                 ++++
```
2024-01-05 10:57:20 -05:00
..
auxiliary rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
check-cfg Add more suggestion to unexpected cfg names and values 2023-12-13 17:48:04 +01:00
coverage Update tests for rustc_doc_primitive 2023-03-30 22:56:52 +02:00
doctest Auto merge of #118213 - Urgau:check-cfg-diagnostics-rustc-cargo, r=petrochenkov 2023-12-13 19:45:57 +00:00
error-in-impl-trait Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug. 2023-12-02 09:01:19 +11:00
generate-link-to-definition Move some rustdoc-ui tests to subdirectories 2023-04-29 11:36:19 -05:00
intra-doc Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
issues Rollup merge of #119148 - estebank:bare-traits, r=davidtwco 2024-01-05 10:57:20 -05:00
lints Add a test for a codeblock with multiple invalid attributes 2023-12-12 19:41:09 +01:00
scrape-examples Move some rustdoc-ui tests to subdirectories 2023-04-29 11:36:19 -05:00
suggestions
ambiguous-inherent-assoc-ty.rs
apit-46976.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
bounded-hr-lifetime.rs Simple modification of diagnostic information 2023-12-21 10:17:11 +08:00
bounded-hr-lifetime.stderr Simple modification of diagnostic information 2023-12-21 10:17:11 +08:00
check-doc-alias-attr-location.rs
check-doc-alias-attr-location.stderr
check-doc-alias-attr.rs
check-doc-alias-attr.stderr
circular-intra-doc-link-48414.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
commandline-argfile-badutf8.args
commandline-argfile-badutf8.rs
commandline-argfile-badutf8.stderr
commandline-argfile-missing.rs
commandline-argfile-missing.stderr
commandline-argfile.args
commandline-argfile.rs
const_arg_in_type_position.rs rustdoc: run more HIR validation to mirror rustc 2023-03-30 14:55:03 +02:00
const_arg_in_type_position.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
const-evalutation-ice.rs
const-evalutation-ice.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
crate-reference-in-block-module.rs rustdoc: Don't crash on crate references in blocks 2023-03-10 17:49:13 +01:00
crate-reference-in-block-module.stderr rustdoc: Don't crash on crate references in blocks 2023-03-10 17:49:13 +01:00
custom_code_classes_in_docs-warning3.rs Add support for double quotes in markdown codeblock attributes 2023-09-15 21:32:28 +02:00
custom_code_classes_in_docs-warning3.stderr Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
custom_code_classes_in_docs-warning.rs Update tests for custom classes 2023-09-19 17:29:39 +02:00
custom_code_classes_in_docs-warning.stderr Update tests for custom classes 2023-09-19 17:29:39 +02:00
deprecated-attrs.rs
deprecated-attrs.stderr
deref-generic.rs
diagnostic-width.rs
diagnostic-width.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
doc-alias-assoc-const.rs
doc-alias-assoc-const.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
doc-alias-crate-level.rs
doc-alias-crate-level.stderr
doc-alias-same-name.rs
doc-alias-same-name.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
doc-cfg.rs
doc-cfg.stderr
doc-include-suggestion.rs
doc-include-suggestion.stderr
feature-gate-custom_code_classes_in_docs.rs Update tests for custom classes 2023-09-19 17:29:39 +02:00
feature-gate-custom_code_classes_in_docs.stderr Update tests for custom classes 2023-09-19 17:29:39 +02:00
feature-gate-doc_cfg_hide.rs
feature-gate-doc_cfg_hide.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
hidden-trait-method-34423.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
ice-assoc-const-for-primitive-31808.rs rustdoc: add check-pass to ICE test with no expected output 2023-10-16 18:03:22 -07:00
ice-bug-report-url.rs Fix test output. 2023-07-29 11:42:53 +02:00
ice-bug-report-url.stderr Fix test output. 2023-07-29 11:42:53 +02:00
ignore-block-help.rs
ignore-block-help.stderr
impl-fn-nesting.rs
impl-fn-nesting.stderr Make configure_and_expand "infalllible" by just aborting the compilation if it fails instead of bubbling out an error 2023-02-20 15:28:59 +00:00
infinite-recursive-type.rs
infinite-recursive-type.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
inherent-assoc-consts-36031.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
invalid_associated_const.rs rustdoc: run more HIR validation to mirror rustc 2023-03-30 14:55:03 +02:00
invalid_associated_const.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
invalid_const_in_lifetime_position.rs Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
invalid_const_in_lifetime_position.stderr Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
invalid_infered_static_and_const.rs rustdoc: run more HIR validation to mirror rustc 2023-03-30 14:55:03 +02:00
invalid_infered_static_and_const.stderr rustdoc: run more HIR validation to mirror rustc 2023-03-30 14:55:03 +02:00
invalid-cfg.rs
invalid-cfg.stderr
invalid-keyword.rs
invalid-keyword.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
invalid-syntax.rs
invalid-syntax.stderr Emit a single error for contiguous sequences of Unicode homoglyphs 2023-01-12 00:15:32 +00:00
invalid-theme-name.rs
invalid-theme-name.stderr
issue-102467.rs Add regression test for #102467 2023-09-24 14:09:38 +02:00
issue-102467.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
issue-110629-private-type-cycle-dyn.rs rustdoc: catch and don't blow up on impl Trait cycles 2023-04-29 16:53:02 -07:00
issue-110629-private-type-cycle-dyn.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
issue-110629-private-type-cycle.rs rustdoc: catch and don't blow up on impl Trait cycles 2023-04-29 16:53:02 -07:00
macro-docs.rs
macro-docs.stderr
macro-docs.stdout
mismatched_arg_count.rs rustdoc: remove excess from rustdoc test 2023-03-30 14:55:03 +02:00
mismatched_arg_count.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
nested-extern-crate-46271.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
nested-macro-rules-47639.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
normalize-cycle.rs
normalize-overflow.rs
not-wf-ambiguous-normalization.rs Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
not-wf-ambiguous-normalization.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
output-format-html-stable.rs
proc_macro_bug.rs Test rustdoc encountering proc_macro_derive in a non-proc-macro crate 2023-02-23 09:00:33 +00:00
proc_macro_bug.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
range-pattern.rs
recursive-deref-ice.rs Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
rustc-check-passes.rs
rustc-check-passes.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
search-index-generics-recursion-bug-issue-59502.rs
super-glob-40936.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
track-diagnostics.rs
track-diagnostics.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
tuple-variadic-check.rs
tuple-variadic-check.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
unable-fulfill-trait.rs Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
unable-fulfill-trait.stderr Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
unescaped_backticks.rs Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug. 2023-12-02 09:01:19 +11:00
unescaped_backticks.stderr Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug. 2023-12-02 09:01:19 +11:00
unused-extern-crate.rs
use_both_out_dir_and_output_options.rs
use_both_out_dir_and_output_options.stderr
wasm-safe.rs