Skip to content

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

Open
@matthiaskrgr

Description

@matthiaskrgr

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

Metadata

Metadata

Labels

C-bugCategory: This is a bug.F-lazy_type_alias`#![feature(lazy_type_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

Status

Can Do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions