Skip to content
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

Move is_min_const_fn query to librustc_mir. #67781

Merged
merged 2 commits into from
Jan 8, 2020

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Jan 1, 2020

The only two uses of the associated methods are in librustc_mir and
librustdoc. Please tell me if there is a better choice.

cc #65031

Comment on lines 10 to 22
pub trait TyCtxtConstExt {
/// Whether the `def_id` counts as const fn in your current crate, considering all active
/// feature gates
pub fn is_const_fn(self, def_id: DefId) -> bool {
fn is_const_fn(self, def_id: DefId) -> bool;

/// Whether the `def_id` is an unstable const fn and what feature gate is necessary to enable it
fn is_unstable_const_fn(self, def_id: DefId) -> Option<Symbol>;

/// Returns `true` if this function must conform to `min_const_fn`
fn is_min_const_fn(self, def_id: DefId) -> bool;
}

impl<'tcx> TyCtxtConstExt for TyCtxt<'tcx> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can just be free functions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that seems better than an extension trait.

@Dylan-DPC-zz Dylan-DPC-zz added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 2, 2020
@bors
Copy link
Contributor

bors commented Jan 6, 2020

☔ The latest upstream changes (presumably #67886) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc
Copy link
Contributor

Zoxc commented Jan 7, 2020

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned eddyb Jan 7, 2020
@@ -1,16 +1,28 @@
use crate::hir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this file to src/librustc_mir/const_eval/fn_queries.rs and reexport the functions in the const_eval module

The only two uses of the associated methods are in librustc_mir and
librustdoc. Please tell me if there is a better choice.
@cjgillot
Copy link
Contributor Author

cjgillot commented Jan 8, 2020

Rebased with review comments.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 8, 2020

@bors r+ rollup

Thanks!

@bors
Copy link
Contributor

bors commented Jan 8, 2020

📌 Commit c1c09be has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 8, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 8, 2020
Move `is_min_const_fn` query to librustc_mir.

The only two uses of the associated methods are in `librustc_mir` and
`librustdoc`. Please tell me if there is a better choice.

cc rust-lang#65031
bors added a commit that referenced this pull request Jan 8, 2020
Rollup of 10 pull requests

Successful merges:

 - #67774 (Try statx for all linux-gnu target.)
 - #67781 (Move `is_min_const_fn` query to librustc_mir.)
 - #67798 (Remove wrong advice about spin locks from `spin_loop_hint` docs)
 - #67849 (Add a check for swapped words when we can't find an identifier)
 - #67875 (Distinguish between private items and hidden items in rustdoc)
 - #67887 (`Option::{expect,unwrap}` and `Result::{expect, expect_err, unwrap, unwrap_err}` have `#[track_caller]`)
 - #67955 (rustdoc: Remove more `#[doc(cfg(..))]` duplicates)
 - #67977 (Updates for VxWorks)
 - #67985 (Remove insignificant notes from CStr documentation)
 - #68003 (ci: fix wrong shared.sh import for publish_toolstate)

Failed merges:

 - #67820 (Parse the syntax described in RFC 2632)
 - #67979 (Move `intravisit` => `rustc_hir` + misc cleanup)

r? @ghost
bors added a commit that referenced this pull request Jan 8, 2020
Rollup of 10 pull requests

Successful merges:

 - #67774 (Try statx for all linux-gnu target.)
 - #67781 (Move `is_min_const_fn` query to librustc_mir.)
 - #67798 (Remove wrong advice about spin locks from `spin_loop_hint` docs)
 - #67849 (Add a check for swapped words when we can't find an identifier)
 - #67875 (Distinguish between private items and hidden items in rustdoc)
 - #67887 (`Option::{expect,unwrap}` and `Result::{expect, expect_err, unwrap, unwrap_err}` have `#[track_caller]`)
 - #67955 (rustdoc: Remove more `#[doc(cfg(..))]` duplicates)
 - #67977 (Updates for VxWorks)
 - #67985 (Remove insignificant notes from CStr documentation)
 - #68003 (ci: fix wrong shared.sh import for publish_toolstate)

Failed merges:

 - #67820 (Parse the syntax described in RFC 2632)
 - #67979 (Move `intravisit` => `rustc_hir` + misc cleanup)

r? @ghost
@bors bors merged commit c1c09be into rust-lang:master Jan 8, 2020
JohnTitor added a commit to JohnTitor/rust-clippy that referenced this pull request Jan 9, 2020
bors added a commit to rust-lang/rust-clippy that referenced this pull request Jan 9, 2020
@cjgillot cjgillot deleted the passes-const branch January 9, 2020 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

7 participants