You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Function with impl trait in argument position does not see all impls of trait on value returned from function with impl trait in return position #59365
Compiling playground v0.0.1 (/playground)
warning: unused variable: `combined4`
--> src/main.rs:40:9
|
40 | let combined4 = combine(&combined2, &a_b);
| ^^^^^^^^^ help: consider using `_combined4` instead
|
= note: #[warn(unused_variables)] on by default
warning: struct is never constructed: `B`
--> src/main.rs:2:1
|
2 | struct B {}
| ^^^^^^^^
|
= note: #[warn(dead_code)] on by default
Finished dev [unoptimized + debuginfo] target(s) in 0.77s
Running `target/debug/playground`
With the second commented line uncommented:
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `impl Marked<B>+Marked<B>: Marked<A>` is not satisfied
--> src/main.rs:42:5
|
42 | consume_a(&combined4); // Errors???
| ^^^^^^^^^ the trait `Marked<A>` is not implemented for `impl Marked<B>+Marked<B>`
|
note: required by `consume_a`
--> src/main.rs:27:1
|
27 | fn consume_a(_: &impl Marked<A>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
I tested this across Stable, Beta, and Nightly in the playground, same behavior in all of them.
My intent with this code was to have a set of "markers" that could be associated with a type purely at a type-system level, with the actual implementation being a single concrete ZST. As the first commented-out line shows, this works in the simple case, but things get confused if you compose markers together multiple times.
Activity
Centril commentedon Mar 22, 2019
Simplified: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9bb30a29adb5af30e9675b81614f1b87
istankovic commentedon Oct 20, 2023
This seems to have been fixed. Tested with 1.73.