From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- .../object/object-unsafe-missing-assoc-type.rs | 7 +++++++ .../object/object-unsafe-missing-assoc-type.stderr | 18 ++++++++++++++++++ tests/ui/traits/object/print_vtable_sizes.stdout | 22 +++++++++++----------- tests/ui/traits/object/safety.stderr | 2 ++ .../object/with-self-in-projection-output-bad.rs | 4 ++-- .../with-self-in-projection-output-bad.stderr | 4 ++-- 6 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 tests/ui/traits/object/object-unsafe-missing-assoc-type.rs create mode 100644 tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr (limited to 'tests/ui/traits/object') diff --git a/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs b/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs new file mode 100644 index 000000000..21f7fd92e --- /dev/null +++ b/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs @@ -0,0 +1,7 @@ +trait Foo { + type Bar; +} + +fn bar(x: &dyn Foo) {} //~ ERROR the trait `Foo` cannot be made into an object + +fn main() {} diff --git a/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr new file mode 100644 index 000000000..fcaa583e2 --- /dev/null +++ b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr @@ -0,0 +1,18 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-unsafe-missing-assoc-type.rs:5:16 + | +LL | fn bar(x: &dyn Foo) {} + | ^^^ `Foo` 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 + --> $DIR/object-unsafe-missing-assoc-type.rs:2:10 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | type Bar; + | ^^^ ...because it contains the generic associated type `Bar` + = help: consider moving `Bar` to another trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/object/print_vtable_sizes.stdout b/tests/ui/traits/object/print_vtable_sizes.stdout index ce90c7621..b43e168df 100644 --- a/tests/ui/traits/object/print_vtable_sizes.stdout +++ b/tests/ui/traits/object/print_vtable_sizes.stdout @@ -1,11 +1,11 @@ -print-vtable-sizes { "crate_name": "", "trait_name": "E", "entries": "6", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "2", "upcasting_cost_percent": "50" } -print-vtable-sizes { "crate_name": "", "trait_name": "G", "entries": "14", "entries_ignoring_upcasting": "11", "entries_for_upcasting": "3", "upcasting_cost_percent": "27.27272727272727" } -print-vtable-sizes { "crate_name": "", "trait_name": "A", "entries": "6", "entries_ignoring_upcasting": "5", "entries_for_upcasting": "1", "upcasting_cost_percent": "20" } -print-vtable-sizes { "crate_name": "", "trait_name": "B", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } -print-vtable-sizes { "crate_name": "", "trait_name": "D", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } -print-vtable-sizes { "crate_name": "", "trait_name": "F", "entries": "6", "entries_ignoring_upcasting": "6", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } -print-vtable-sizes { "crate_name": "", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } -print-vtable-sizes { "crate_name": "", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } -print-vtable-sizes { "crate_name": "", "trait_name": "help::MarkerWithSuper", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } -print-vtable-sizes { "crate_name": "", "trait_name": "help::Super", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } -print-vtable-sizes { "crate_name": "", "trait_name": "help::V", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "E", "entries": "6", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "2", "upcasting_cost_percent": "50" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "G", "entries": "14", "entries_ignoring_upcasting": "11", "entries_for_upcasting": "3", "upcasting_cost_percent": "27.27272727272727" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "A", "entries": "6", "entries_ignoring_upcasting": "5", "entries_for_upcasting": "1", "upcasting_cost_percent": "20" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "B", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "D", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "F", "entries": "6", "entries_ignoring_upcasting": "6", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "help::MarkerWithSuper", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "help::Super", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "help::V", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } diff --git a/tests/ui/traits/object/safety.stderr b/tests/ui/traits/object/safety.stderr index a51b69759..19a46a502 100644 --- a/tests/ui/traits/object/safety.stderr +++ b/tests/ui/traits/object/safety.stderr @@ -11,6 +11,7 @@ LL | trait Tr { | -- this trait cannot be made into an object... LL | fn foo(); | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `St` implements the trait, consider using it directly instead = note: required for the cast from `&St` to `&dyn Tr` help: consider turning `foo` into a method by giving it a `&self` argument | @@ -34,6 +35,7 @@ LL | trait Tr { | -- this trait cannot be made into an object... LL | fn foo(); | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `St` implements the trait, consider using it directly instead help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self); diff --git a/tests/ui/traits/object/with-self-in-projection-output-bad.rs b/tests/ui/traits/object/with-self-in-projection-output-bad.rs index f34fa80a0..9515397fb 100644 --- a/tests/ui/traits/object/with-self-in-projection-output-bad.rs +++ b/tests/ui/traits/object/with-self-in-projection-output-bad.rs @@ -43,8 +43,8 @@ impl NormalizableHelper for u32 fn main() { let _x: Box> = Box::new(2u32); - //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` in `Base` must be specified let _y: Box> = Box::new(2u32); - //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` in `Base` must be specified } diff --git a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr index 641bfe236..c9b36e8d2 100644 --- a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr +++ b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified +error[E0191]: the value of the associated type `Output` in `Base` must be specified --> $DIR/with-self-in-projection-output-bad.rs:45:21 | LL | type Output; @@ -7,7 +7,7 @@ LL | type Output; LL | let _x: Box> = Box::new(2u32); | ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper` -error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified +error[E0191]: the value of the associated type `Output` in `Base` must be specified --> $DIR/with-self-in-projection-output-bad.rs:48:21 | LL | type Output; -- cgit v1.2.3