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

lazy_type_alias: type is forbidden as the type of a const generic parameter #114217

Open
matthiaskrgr opened this issue Jul 29, 2023 · 2 comments
Assignees
Labels
C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

I tried this code:
tests/rustdoc/issue-101743-bold-tag.rs

// Regression test for https://github.com/rust-lang/rust/issues/101743

#![crate_name="foo"]

pub type Word = usize;
pub struct Repr<const B: usize>([i32; B]);
pub struct IBig(usize);

pub const fn base_as_ibig<const B: Word>() -> IBig {
    IBig(B)
}

impl<const B: Word> Repr<B> {
    // If we change back to rendering the value of consts, check this doesn't add
    // a <b> tag, but escapes correctly

    // @has foo/struct.Repr.html '//section[@id="associatedconstant.BASE"]/h4' '= _'
    pub const BASE: IBig = base_as_ibig::<B>();
}

without `-Zcrate-attr=feature(lazy_type_alias)´: no warnings

with -Zcrate-attr=feature(lazy_type_alias):

error: `Word` is forbidden as the type of a const generic parameter
 --> tests/rustdoc/issue-101743-bold-tag.rs:9:36
  |
9 | pub const fn base_as_ibig<const B: Word>() -> IBig {
  |                                    ^^^^
  |
  = note: the only supported types are integers, `bool` and `char`
  = help: more complex types are supported with `#![feature(adt_const_params)]`

error: `Word` is forbidden as the type of a const generic parameter
  --> tests/rustdoc/issue-101743-bold-tag.rs:13:15
   |
13 | impl<const B: Word> Repr<B> {
   |               ^^^^
   |
   = note: the only supported types are integers, `bool` and `char`
   = help: more complex types are supported with `#![feature(adt_const_params)]`

error: aborting due to 2 previous errors
rustc 1.73.0-nightly (04abc370b 2023-07-28)
binary: rustc
commit-hash: 04abc370b9f3855b28172b65a7f7d5a433f41412
commit-date: 2023-07-28
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5
@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` labels Jul 29, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2023
@compiler-errors compiler-errors added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 29, 2023
@matthiaskrgr
Copy link
Member Author

#![feature(lazy_type_alias)]

pub type Word = usize;

pub struct IBig(usize);

pub const fn base_as_ibig<const B: Word>() -> IBig {
    IBig(B)
}

@compiler-errors compiler-errors removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jul 29, 2023
@GuillaumeGomez GuillaumeGomez self-assigned this Aug 10, 2023
@GuillaumeGomez
Copy link
Member

I have a fix for this one, sending it shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants