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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ambiguous-inherent-assoc-ty.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
check-doc-alias-attr-location.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
check-doc-alias-attr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
check-doc-alias-attr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
circular-intra-doc-link-48414.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
commandline-argfile-badutf8.args Move /src/test to /tests 2023-01-11 09:32:08 +00:00
commandline-argfile-badutf8.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
commandline-argfile-badutf8.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
commandline-argfile-missing.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
commandline-argfile-missing.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
commandline-argfile.args Move /src/test to /tests 2023-01-11 09:32:08 +00:00
commandline-argfile.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-evalutation-ice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-evalutation-ice.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
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
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-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
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
deprecated-attrs.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deprecated-attrs.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deref-generic.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
diagnostic-width.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
diagnostic-width.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
doc-alias-assoc-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doc-alias-assoc-const.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
doc-alias-crate-level.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doc-alias-crate-level.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doc-alias-same-name.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doc-alias-same-name.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
doc-cfg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doc-cfg.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doc-include-suggestion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doc-include-suggestion.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ignore-block-help.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
impl-fn-nesting.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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-cfg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-cfg.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-keyword.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-keyword.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
invalid-syntax.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-theme-name.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00: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
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
macro-docs.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
macro-docs.stdout Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
normalize-overflow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
recursive-deref-ice.rs Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
rustc-check-passes.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
rustc-check-passes.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
search-index-generics-recursion-bug-issue-59502.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
super-glob-40936.rs rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
track-diagnostics.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
track-diagnostics.stderr Bless rustdoc-ui tests 2023-11-24 19:15:52 +01:00
tuple-variadic-check.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
use_both_out_dir_and_output_options.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
use_both_out_dir_and_output_options.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
wasm-safe.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00