Skip to content

Conversation

camelid
Copy link
Member

@camelid camelid commented Apr 8, 2025

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 8, 2025
@camelid camelid added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2025
@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the mgca-const-items branch from fa42f86 to 6054bd5 Compare April 9, 2025 16:14
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the mgca-const-items branch from 4f6c9ab to a46aa4c Compare May 15, 2025 12:37
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label May 15, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid camelid added A-const-generics Area: const generics (parameters and arguments) F-min_generic_const_args `#![feature(min_generic_const_args)]` labels May 17, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 21, 2025

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

@BoxyUwU
Copy link
Member

BoxyUwU commented May 23, 2025

@oli-obk I've assigned you to this PR alongside me because I'd definitely want you to review it before it lands since its so CTFE involved 🤔 I don't think it needs reviewing rn though, things are so up in the air and we're not bootstrapping yet :3

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Oct 13, 2025
)? {
TypeRelativePath::AssocItem(def_id, args) => {
if !tcx.associated_item(def_id).is_type_const_capable(tcx) {
if !find_attr!(self.tcx().get_all_attrs(def_id), AttributeKind::TypeConst(_)) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't know why find_attr! works here but tcx.has_attr(sym::type_const) doesnt. cc @jdonszelmann does has_attr work with new style attributes?

Copy link
Member

@BoxyUwU BoxyUwU Oct 13, 2025

Choose a reason for hiding this comment

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

https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_hir/hir.rs.html#1283 seems like no new style attributes don't work with has_attr if it's been parsed

Copy link
Member

@BoxyUwU BoxyUwU Oct 13, 2025

Choose a reason for hiding this comment

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

it works sometimes though because we added has_attr calls in some places to fix ICEs which worked.

edit: ah no it probably just made that code unreachable lmao

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

pub generics: Generics,
pub ty: Box<Ty>,
pub expr: Option<Box<Expr>>,
pub body: Option<ConstItemRhs>,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub body: Option<ConstItemRhs>,
pub rhs: Option<ConstItemRhs>,

body terminology doesn't make too much sense since it's only sometimes a body

Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
/// A `const` item.
Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, BodyId),
// TODO: make sure we only allow usage of path RHS in generic contexts under mgca, not stable!
Copy link
Member

Choose a reason for hiding this comment

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

This is now done, uncertain whether we may want some kind of ast validator or hir visitor to assert this :3

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] askama test:false 0.180
error[E0308]: mismatched types
    --> src/librustdoc/clean/mod.rs:1205:39
     |
1205 |                     kind: clean_const(default, Some(local_did), cx),
     |                           ----------- ^^^^^^^ expected `&ConstArg<'_>`, found `ConstItemRhs<'_>`
     |                           |
     |                           arguments to this function are incorrect
     |
     = note: expected reference `&rustc_hir::ConstArg<'_>`
                     found enum `rustc_hir::ConstItemRhs<'_>`
note: function defined here
    --> src/librustdoc/clean/mod.rs:309:15
     |
 309 | pub(crate) fn clean_const<'tcx>(
     |               ^^^^^^^^^^^
 310 |     constant: &hir::ConstArg<'tcx>,
     |     ------------------------------

error[E0308]: mismatched types
    --> src/librustdoc/clean/mod.rs:1255:35
     |
1255 |                 kind: clean_const(expr, Some(local_did), cx),
     |                       ----------- ^^^^ expected `&ConstArg<'_>`, found `ConstItemRhs<'_>`
     |                       |
     |                       arguments to this function are incorrect
     |
     = note: expected reference `&rustc_hir::ConstArg<'_>`
                     found enum `rustc_hir::ConstItemRhs<'_>`
note: function defined here
    --> src/librustdoc/clean/mod.rs:309:15
     |
 309 | pub(crate) fn clean_const<'tcx>(
     |               ^^^^^^^^^^^
 310 |     constant: &hir::ConstArg<'tcx>,
     |     ------------------------------

error[E0308]: mismatched types
    --> src/librustdoc/clean/mod.rs:2800:35
     |
2800 |                 kind: clean_const(body, Some(def_id), cx),
     |                       ----------- ^^^^ expected `&ConstArg<'_>`, found `ConstItemRhs<'_>`
     |                       |
     |                       arguments to this function are incorrect
     |
     = note: expected reference `&rustc_hir::ConstArg<'_>`
                     found enum `rustc_hir::ConstItemRhs<'_>`
note: function defined here
    --> src/librustdoc/clean/mod.rs:309:15
     |
 309 | pub(crate) fn clean_const<'tcx>(
     |               ^^^^^^^^^^^
 310 |     constant: &hir::ConstArg<'tcx>,
     |     ------------------------------

error[E0004]: non-exhaustive patterns: `&ConstArgKind::Error(_, _)` not covered
   --> src/librustdoc/clean/mod.rs:315:11
    |
315 |     match &constant.kind {
    |           ^^^^^^^^^^^^^^ pattern `&ConstArgKind::Error(_, _)` not covered
    |
note: `ConstArgKind<'_>` defined here
   --> /checkout/compiler/rustc_hir/src/hir.rs:500:1
    |
500 | pub enum ConstArgKind<'hir, Unambig = ()> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
509 |     Error(Span, ErrorGuaranteed),
    |     ----- not covered
    = note: the matched value is of type `&ConstArgKind<'_>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
326 ~         hir::ConstArgKind::Infer(..) => ConstantKind::Infer,
327 ~         &ConstArgKind::Error(_, _) => todo!(),
    |

error[E0004]: non-exhaustive patterns: `ConstArgKind::Error(_, _)` not covered
    --> src/librustdoc/clean/mod.rs:1810:32
     |
1810 |             let length = match const_arg.kind {
     |                                ^^^^^^^^^^^^^^ pattern `ConstArgKind::Error(_, _)` not covered
     |
note: `ConstArgKind<'_>` defined here
    --> /checkout/compiler/rustc_hir/src/hir.rs:500:1
     |
 500 | pub enum ConstArgKind<'hir, Unambig = ()> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
 509 |     Error(Span, ErrorGuaranteed),
     |     ----- not covered
     = note: the matched value is of type `ConstArgKind<'_>`

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-const-generics Area: const generics (parameters and arguments) F-min_generic_const_args `#![feature(min_generic_const_args)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants