question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discuss the possibility of denying `bare_trait_objects` in 2021 edition

See original GitHub issue

Summary

Bare trait objects do not interact well with const generics, as if a user does not surround a const expression with {}, it can be parsed as a trait object (e.g. foo + bar is interpreted as dyn foo + bar), which leads to confusing errors. See, for instance: https://github.com/rust-lang/rust/pull/77502#discussion_r499172677. If we deny bare_trait_objects in the 2021 edition, which is a permitted edition change, we can emit better errors for const generics, a feature we hope to stabilise in the form of min_const_generics in the near future.

bare_trait_objects would continue to work pre-2021 edition. Thus, the better error messages will only be available in the 2021 edition.

About this issue

This issue corresponds to a lang-team design meeting proposal. It corresponds to a possible topic of discussion that may be scheduled for deeper discussion during one of our design meetings.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
scottmcmcommented, Dec 30, 2020

To me, at least, those don’t seem persuasive enough to dissuade from making dyn strictly required.

  • One can presumably just do type MyBoxedDynAny<T> = dyn MyBoxedDynAnyTrait<T>; if you want to expose something as a type instead of a trait.
  • That use has always felt somewhat like a hack to me, vs a representation like would be done at runtime like transmute::<{ Neglect { alignment: true, .. } }(...) or something. Or even transmute::<{Neglect::Alignment | Neglect::SomethingElse}>(...) with a const BitOr for whatever that type would be. It’s certainly a fun hack, while const generics are as limited as they currently are, but I’m still not a fan of it.
0reactions
Mark-Simulacrumcommented, Apr 14, 2021

Closing in favor of https://github.com/rust-lang/rust/pull/83213, as discussed in today’s planning meeting. That PR has the outcome of various discussions (and is currently in FCP).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Idiom lints - HackMD
Migration: Hard error in Rust 2021, warning in earlier editions; Idiom lint: Deny-by-default in Rust 2021, warning in earlier editions.
Read more >
Warn-by-default Lints - The rustc book
In the 2015 edition, this lint is "warn" by default. This lint enables the cargo fix tool with the --edition flag to automatically...
Read more >
What does it mean to deny yourself? What is self-denial?
It means acknowledging that the old self is dead and the new life is now hidden with Christ in God (Colossians 3:3–5). From...
Read more >
How God Taught a Man to Deny Himself - ManInTheMirror.org
What is tugging at your heart? It may just be the Spirit saying, “Here's the chance to get out of your comfort zone...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found