-
Notifications
You must be signed in to change notification settings - Fork 13.3k
"Unused" associated type bounds in dyn
no longer parameterize the type
#140645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't believe that this behavioral change is worth concern. I'll discuss this with @lcnr tomorrow since we worked together on these dyn issues, b/c we have several options here:
I kinda prefer (0.) or (1.) here, personally. I don't see any problem with writing these bounds, but we could probably be clearer in explaining to users that we now don't consider
Side-note, it's not exactly true to say that This is IMO irrelevant because that bound is never relevant for a dyn type. It's as if we were saying "if |
The fact that impossible associated type bounds used to constrain type parameters to me is interesting at best, but is technically an observable change. I think this warrants an FCP, and I'll open up one tomorrow when I can write up some coherent justification for why this behavioral change is at best desirable and at worst worth ignoring. |
Let me call out one particular part of my more complete playground: // SAFETY:
// - `BaseType: Use<Assoc = Assoc>` is guaranteed by unsizing coercion Or in other words: " With that in mind, here's a version of the playground where code that used to be sound by relying on that implication is no longer sound, but still compiles on Beta. Even ignoring soundness, the code suddenly becomes very misleading IMO. I think assuming the implication holds is reasonable, but on Beta it's no longer always true. Even if (2) and (3) won't happen, perhaps this is relevant re: If do-nothing bounds are eventually disallowed, the implication that "what you can (syntactically) coerce to reflects the capability of the coercee" will become true again.
Under a mental model of " Anyway, I don't care strongly enough to argue hard for (2) or (3), and I'm not trying to do that. The lost ability is neat but I also recognize the change is cleaner. The code I wrote using the lost ability were POCs, not load bearing. And I only pointed out the But I do think "do-nothing item bounds" are quite misleading without the invariant, and should be loud about it. I think one can see how |
I changed my mind and implemented #140684. |
Code
I tried this code:
I expected to see this happen: successful compilation.
Instead, this happened:
Version it worked on
It most recently worked on: Rust 1.86.0
Version with regression
Playground: Beta version: 1.87.0-beta.8 (2025-05-03 973ec11)
More notes
CC #125560
Before Beta,
dyn Trait
anddyn Trait<Assoc = ()>
were different types. Now they are the same type.Here's a more complete example that makes practical (albeit contrived) use of distinct
dyn Trait<Assoc = ...>
types.Considering the release notes, #136458 may be the cause (but there's no discussion about this change in particular). Assuming this is the case and the use case that broke is considered unimportant, this aspect of the change could at least be mentioned in the release notes.
Incidentally, this also means
dyn Trait<Assoc = &'can_be_non_static str>
meets a'static
bound now. Hopefully irrelevant, but it does seem like an exception to outlive bounds being syntactical.@rustbot modify labels: +regression-from-stable-to-beta, -regression-untriaged
The text was updated successfully, but these errors were encountered: