Rollup merge of #137955 - Noratrieb:rustdoc-json-long-lines, r=aDotInTheVoid,jieyouxu
Always allow rustdoc-json tests to contain long lines The rustdoc-json test syntax often requires very long lines, so the checks for long lines aren't really useful. `@aDotInTheVoid` told me she'd like this and r? jieyouxu you're gonna tell me that the implementation is terrible. at least the performance seems reasonable: 2.5s after and 2.5s before.
This commit is contained in:
commit
e2d40b2d80
44 changed files with 17 additions and 76 deletions
|
@ -72,12 +72,14 @@ const ANNOTATIONS_TO_IGNORE: &[&str] = &[
|
|||
"//@ normalize-stderr",
|
||||
];
|
||||
|
||||
const LINELENGTH_CHECK: &str = "linelength";
|
||||
|
||||
// If you edit this, also edit where it gets used in `check` (calling `contains_ignore_directives`)
|
||||
const CONFIGURABLE_CHECKS: [&str; 11] = [
|
||||
"cr",
|
||||
"undocumented-unsafe",
|
||||
"tab",
|
||||
"linelength",
|
||||
LINELENGTH_CHECK,
|
||||
"filelength",
|
||||
"end-whitespace",
|
||||
"trailing-newlines",
|
||||
|
@ -250,14 +252,24 @@ enum Directive {
|
|||
// Use a fixed size array in the return type to catch mistakes with changing `CONFIGURABLE_CHECKS`
|
||||
// without changing the code in `check` easier.
|
||||
fn contains_ignore_directives<const N: usize>(
|
||||
path_str: &str,
|
||||
can_contain: bool,
|
||||
contents: &str,
|
||||
checks: [&str; N],
|
||||
) -> [Directive; N] {
|
||||
if !can_contain {
|
||||
// The rustdoc-json test syntax often requires very long lines, so the checks
|
||||
// for long lines aren't really useful.
|
||||
let always_ignore_linelength = path_str.contains("rustdoc-json");
|
||||
|
||||
if !can_contain && !always_ignore_linelength {
|
||||
return [Directive::Deny; N];
|
||||
}
|
||||
|
||||
checks.map(|check| {
|
||||
if check == LINELENGTH_CHECK && always_ignore_linelength {
|
||||
return Directive::Ignore(false);
|
||||
}
|
||||
|
||||
// Update `can_contain` when changing this
|
||||
if contents.contains(&format!("// ignore-tidy-{check}"))
|
||||
|| contents.contains(&format!("# ignore-tidy-{check}"))
|
||||
|
@ -367,6 +379,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||
|
||||
walk(path, skip, &mut |entry, contents| {
|
||||
let file = entry.path();
|
||||
let path_str = file.to_string_lossy();
|
||||
let filename = file.file_name().unwrap().to_string_lossy();
|
||||
|
||||
let is_css_file = filename.ends_with(".css");
|
||||
|
@ -422,7 +435,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||
mut skip_copyright,
|
||||
mut skip_dbg,
|
||||
mut skip_odd_backticks,
|
||||
] = contains_ignore_directives(can_contain, &contents, CONFIGURABLE_CHECKS);
|
||||
] = contains_ignore_directives(&path_str, can_contain, &contents, CONFIGURABLE_CHECKS);
|
||||
let mut leading_new_lines = false;
|
||||
let mut trailing_new_lines = 0;
|
||||
let mut lines = 0;
|
||||
|
@ -502,7 +515,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||
let contains_potential_directive =
|
||||
possible_line_start && (line.contains("-tidy") || line.contains("tidy-"));
|
||||
let has_recognized_ignore_directive =
|
||||
contains_ignore_directives(can_contain, line, CONFIGURABLE_CHECKS)
|
||||
contains_ignore_directives(&path_str, can_contain, line, CONFIGURABLE_CHECKS)
|
||||
.into_iter()
|
||||
.any(|directive| matches!(directive, Directive::Ignore(_)));
|
||||
let has_alphabetical_directive = line.contains("tidy-alphabetical-start")
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
#![feature(repr128)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#[repr(u32)]
|
||||
pub enum Foo {
|
||||
//@ is "$.index[*][?(@.name=='Basic')].inner.variant.discriminant.value" '"0"'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
pub enum Foo {
|
||||
//@ is "$.index[*][?(@.name=='Has')].inner.variant.discriminant" '{"expr":"0", "value":"0"}'
|
||||
Has = 0,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#[repr(i32)]
|
||||
//@ is "$.index[*][?(@.name=='Foo')].attrs" '["#[attr=\"Repr([ReprInt(SignedInt(I32))])\")]\n"]'
|
||||
pub enum Foo {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#[repr(u32)]
|
||||
//@ is "$.index[*][?(@.name=='Foo')].attrs" '["#[attr=\"Repr([ReprInt(UnsignedInt(U32))])\")]\n"]'
|
||||
pub enum Foo {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
pub enum Foo {
|
||||
//@ set Unit = "$.index[*][?(@.name=='Unit')].id"
|
||||
//@ is "$.index[*][?(@.name=='Unit')].inner.variant.kind" '"plain"'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(abi_vectorcall)]
|
||||
|
||||
//@ is "$.index[*][?(@.name=='AbiRust')].inner.type_alias.type.function_pointer.header.abi" \"Rust\"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.sig.inputs[*]" 1
|
||||
//@ is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.sig.inputs[0][0]" '"val"'
|
||||
//@ is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.sig.inputs[0][1].borrowed_ref.lifetime" \"\'c\"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.is_unsafe" false
|
||||
//@ is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.is_const" false
|
||||
//@ is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.is_async" false
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(abi_vectorcall)]
|
||||
|
||||
//@ is "$.index[*][?(@.name=='abi_rust')].inner.function.header.abi" \"Rust\"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//@ edition:2021
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/101199>
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ set foo = "$.index[*][?(@.name=='Foo')].id"
|
||||
pub trait Foo {}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ count "$.index[*][?(@.name=='generic_returns')].inner.module.items[*]" 2
|
||||
|
||||
//@ set foo = "$.index[*][?(@.name=='Foo')].id"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ set wham_id = "$.index[*][?(@.name=='Wham')].id"
|
||||
pub trait Wham {}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
pub trait Display {}
|
||||
|
||||
pub trait LendingIterator {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
#![feature(impl_trait_in_assoc_type)]
|
||||
|
||||
pub struct AlwaysTrue;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].name" \"\'a\"
|
||||
//@ is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].kind" '{"lifetime": {"outlives": []}}'
|
||||
//@ is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].kind" '{"lifetime": {"outlives": []}}'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ count "$.index[*][?(@.name=='foo')].inner.function.generics.params[*]" 3
|
||||
//@ is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates" []
|
||||
//@ is "$.index[*][?(@.name=='foo')].inner.function.generics.params[0].name" \"\'a\"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ count '$.index[*][?(@.name=="outlives")].inner.function.generics.params[*]' 2
|
||||
//@ is '$.index[*][?(@.name=="outlives")].inner.function.generics.params[0].name' \"\'a\"
|
||||
//@ is '$.index[*][?(@.name=="outlives")].inner.function.generics.params[0].kind.lifetime.outlives' []
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ is '$.index[*][?(@.name=="on_lifetimes")].inner.function.generics.where_predicates' '[{"lifetime_predicate": {"lifetime": "'\''all", "outlives": ["'\''a", "'\''b", "'\''c"]}}]'
|
||||
pub fn on_lifetimes<'a, 'b, 'c, 'all>()
|
||||
where
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(abi_vectorcall)]
|
||||
|
||||
//@ has "$.index[*][?(@.name=='Foo')]"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(non_lifetime_binders)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// See https://github.com/rust-lang/rust/issues/135600
|
||||
// and https://github.com/rust-lang/rust/pull/134880#issuecomment-2596386111
|
||||
//
|
||||
// ignore-tidy-linelength
|
||||
//@ aux-build: defines_and_reexports.rs
|
||||
extern crate defines_and_reexports;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// Regression Test for https://github.com/rust-lang/rust/issues/110138
|
||||
//@ aux-build: enum_with_discriminant.rs
|
||||
// ignore-tidy-linelength
|
||||
|
||||
#[doc(inline)]
|
||||
pub extern crate enum_with_discriminant;
|
||||
|
|
|
@ -2,7 +2,5 @@
|
|||
|
||||
#![crate_name = "export_extern_crate_as_self"]
|
||||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
//@ is "$.index[*][?(@.inner.module)].name" \"export_extern_crate_as_self\"
|
||||
pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//@ aux-build:pub-struct.rs
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// Test for the ICE in https://github.com/rust-lang/rust/issues/83057
|
||||
// An external type re-exported with different attributes shouldn't cause an error
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
// Test for the ICE in https://github.com/rust-lang/rust/issues/83720
|
||||
// A pub-in-private type re-exported under two different names shouldn't cause an error
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/97432>.
|
||||
|
||||
#![no_std]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// Regression test for <https://github.com/rust-lang/rust/issues/96161>.
|
||||
// ignore-tidy-linelength
|
||||
|
||||
mod secret {
|
||||
//@ set struct_secret = "$.index[*][?(@.name == 'Secret' && @.inner.struct)].id"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
//@ edition: 2021
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ is "$.index[*][?(@.name=='WithPrimitives')].visibility" \"public\"
|
||||
//@ has "$.index[*][?(@.name=='WithPrimitives')].inner.struct"
|
||||
//@ is "$.index[*][?(@.name=='WithPrimitives')].inner.struct.generics.params[0].name" \"\'a\"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
#![feature(trait_alias)]
|
||||
|
||||
//@ set StrLike = "$.index[*][?(@.name=='StrLike')].id"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ !has "$.index[*][?(@.name == 'sealed')]"
|
||||
mod sealed {
|
||||
//@ set sealed_id = "$.index[*][?(@.name=='Sealed')].id"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
pub struct Foo;
|
||||
|
||||
// Check that Self is represented uniformly between inherent impls, trait impls,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ set loud_id = "$.index[*][?(@.name=='Loud')].id"
|
||||
pub trait Loud {}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// Regression test for <https://github.com/rust-lang/rust/issues/104923>
|
||||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(trait_alias)]
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
use std::fmt::Debug;
|
||||
|
||||
//@ count "$.index[*][?(@.name=='dyn')].inner.module.items[*]" 3
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ has "$.index[*][?(@.name=='GenericFn')].inner.type_alias"
|
||||
|
||||
//@ ismany "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.params[*].name" \"\'a\"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ set result = "$.index[*][?(@.name=='Result')].id"
|
||||
pub enum Result<T, E> {
|
||||
Ok(T),
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
//@ is "$.index[*][?(@.name=='genfn')].inner.function.generics.where_predicates[0].bound_predicate.type" '{"generic": "F"}'
|
||||
//@ is "$.index[*][?(@.name=='genfn')].inner.function.generics.where_predicates[0].bound_predicate.generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]'
|
||||
pub fn genfn<F>(f: F)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// ignore-tidy-linelength
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue