1
Fork 0

Accept less invalid Rust in rustdoc

This commit is contained in:
Oli Scherer 2023-10-31 13:58:03 +00:00
parent 22b27120b9
commit 4512f211ae
35 changed files with 428 additions and 127 deletions

View file

@ -4,9 +4,11 @@
//
// Read the documentation of `rustdoc::clean::utils::print_const_expr`
// for further details.
#![feature(const_trait_impl, generic_const_exprs)]
#![feature(const_trait_impl, generic_const_exprs, adt_const_params, generic_const_items)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
// @has hide_complex_unevaluated_const_arguments/trait.Stage.html
pub trait Stage {
// A helper constant that prevents const expressions containing it
@ -29,11 +31,13 @@ pub trait Stage {
//
// @has - '//*[@id="associatedconstant.ARRAY1"]' \
// 'const ARRAY1: [u8; { _ }]'
const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)];
const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]
where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:;
// @has - '//*[@id="associatedconstant.VERBOSE"]' \
// 'const VERBOSE: [u16; { _ }]'
const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT];
const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT]
where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:;
// Check that we do not leak the private struct field contained within
// the path. The output could definitely be improved upon
@ -69,6 +73,7 @@ pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {}
pub trait Sup<const N: usize, const S: Struct> {}
#[derive(ConstParamTy, PartialEq, Eq)]
pub struct Struct { private: () }
impl Struct {