diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 38b12405ea821..020829df7b6a0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -561,12 +561,7 @@ fn clean_generic_param_def( def.name, GenericParamDefKind::Const { ty: Box::new(clean_middle_ty( - ty::Binder::dummy( - cx.tcx - .type_of(def.def_id) - .no_bound_vars() - .expect("const parameter types cannot be generic"), - ), + ty::Binder::dummy(cx.tcx.type_of(def.def_id).instantiate_identity()), cx, Some(def.def_id), None, diff --git a/tests/rustdoc/const-generics/const-param-type-references-generics.rs b/tests/rustdoc/const-generics/const-param-type-references-generics.rs new file mode 100644 index 0000000000000..47bf3e253e69d --- /dev/null +++ b/tests/rustdoc/const-generics/const-param-type-references-generics.rs @@ -0,0 +1,16 @@ +//! rustdoc regression test for #149288: const generic parameter types may depend on +//! other generics when `generic_const_parameter_types` is enabled. +#![allow(incomplete_features)] +#![feature(adt_const_params, generic_const_parameter_types)] +#![crate_name = "foo"] + +pub struct Bar; + +pub fn takes(_: Bar) {} + +pub fn instantiate() { + takes(Bar::<2, { [1; 2] }>); +} + +//@ has foo/struct.Bar.html '//pre[@class="rust item-decl"]' 'pub struct Bar' +//@ has foo/fn.takes.html '//pre[@class="rust item-decl"]' 'pub fn takes(_: Bar)'