Skip to content

Allow trait methods to be called on concrete types in a const context#68847

Merged
bors merged 16 commits intorust-lang:masterfrom
ecstatic-morse:const-impl
Feb 20, 2020
Merged

Allow trait methods to be called on concrete types in a const context#68847
bors merged 16 commits intorust-lang:masterfrom
ecstatic-morse:const-impl

Conversation

@ecstatic-morse
Copy link
Contributor

@ecstatic-morse ecstatic-morse commented Feb 5, 2020

This partially implements RFC 2632 by const-checking methods inside an impl const block and allowing those methods to be called on concrete types. Calling trait methods on type parameters in a const context is not yet allowed. Implementing this will require much more work. Since we are only concerned with methods on concrete types, we are able to take advantage of the machinery in Instance::resolve, which is doing most of the work.

This also propagates #[rustc_const_unstable] from parent items to child items, making that attribute behave like #[stable] and #[unstable] do. This allows trait methods to be marked as unstably const.

cc #67792 #57563
cc @rust-lang/wg-const-eval
r? @oli-obk

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) F-const_trait_impl `#![feature(const_trait_impl)]` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants