Skip to content

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jan 15, 2025

Just a small FIXME that gets resolved.

I think the constness query should not cover all const callable things

@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2025

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2025

Some changes occurred to the CTFE machinery

cc @rust-lang/wg-const-eval

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 15, 2025
hir::Constness::NotConst
}
}
_ => hir::Constness::NotConst,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This catch all is a bit sad, but since a parent could be anything that a fn is in, it could be a module, another fn, anything really.

Imran-imtiaz48

This comment was marked as spam.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

r=me

@@ -6,12 +6,16 @@ use rustc_middle::ty::TyCtxt;

fn parent_impl_constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness {
Copy link
Member

Choose a reason for hiding this comment

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

Can u rename this to parent_impl_or_trait_constness?

@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 15, 2025

@bors r=compiler-errors

@bors
Copy link
Collaborator

bors commented Jan 15, 2025

📌 Commit a61cd86 has been approved by compiler-errors

It is now in the queue for this repository.

@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 15, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 15, 2025
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#135497 (fix typo in typenames of pin documentation)
 - rust-lang#135522 (add incremental test for issue 135514)
 - rust-lang#135523 (const traits: remove some known-bug that do not seem to make sense)
 - rust-lang#135535 (Add GUI test for rust-lang#135499)
 - rust-lang#135541 (Methods of const traits are const)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2ea07de into rust-lang:master Jan 16, 2025
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2025
Rollup merge of rust-lang#135541 - oli-obk:push-lqlmstussztp, r=compiler-errors

Methods of const traits are const

Just a small FIXME that gets resolved.

I think the `constness` query should not cover all const callable things
@rustbot rustbot added this to the 1.86.0 milestone Jan 16, 2025
@matthiaskrgr
Copy link
Member

Uuh, I'm seeing a bunch of new false positives for the clippy::missing-const-for-fn lint popping up, presumably due to this change.

For example

//@ run-pass
use std::ops::Add;

fn f<T: Add>(a: T, b: T) -> <T as Add>::Output {
    a + b
}

fn main() {
    println!("a + b is {}", f::<f32>(100f32, 200f32));
}

now lints

warning: this could be a `const fn`
 --> ./tests/ui/issues/issue-22258.rs:4:1
  |
4 | / fn f<T: Add>(a: T, b: T) -> <T as Add>::Output {
5 | |     a + b
6 | | }
  | |_^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
  = note: requested on the command line with `-W clippy::missing-const-for-fn`
help: make the function `const`
  |
4 | const fn f<T: Add>(a: T, b: T) -> <T as Add>::Output {
  | +++++

which is not correct

@oli-obk oli-obk deleted the push-lqlmstussztp branch January 16, 2025 17:39
@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 16, 2025

yes, the clippy lint needs to look at const stability of traits. The add trait specifically is unstably const

github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request Mar 11, 2025
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#135497 (fix typo in typenames of pin documentation)
 - rust-lang#135522 (add incremental test for issue 135514)
 - rust-lang#135523 (const traits: remove some known-bug that do not seem to make sense)
 - rust-lang#135535 (Add GUI test for rust-lang#135499)
 - rust-lang#135541 (Methods of const traits are const)

r? `@ghost`
`@rustbot` modify labels: rollup
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants