Skip to content

Commit

Permalink
Rollup merge of #117679 - aDotInTheVoid:yes-core, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
tests/rustdoc-json: Avoid needless use of `no_core` and `lang_items`

See #117487 for motivation.

I've split it into three commits, depending on how much work it was to remove `#![no_core]`. The first is entirely mechanical, the second makes no logical changes but couldn't be done with find+replace, and the third required rewriting assertions no not depend on having `#![no_core]`. All of the interesting changes for review are in the third commit, so I recommend reviewing commit-by-commit.

After this, 3 tests still use `#![no_core]`:

- `./tests/rustdoc-json/primitives/primitive_impls.rs`. Uses impls on primitives, so needs to simulate core
- `./tests/rustdoc-json/primitives/local_primitive.rs`: Uses `rustc_doc_primitive`, so needs to simulate core
- `./tests/rustdoc-json/impls/auto.rs`: Uses auto traits, so needs to simulate core

But after this change, we only rely on the core-rustc boundary in tests that deliberately test those interactions.

r? ``@GuillaumeGomez``

Fixes #117487
  • Loading branch information
GuillaumeGomez committed Nov 8, 2023
2 parents c828371 + 434b69a commit 5d00a5d
Show file tree
Hide file tree
Showing 50 changed files with 41 additions and 202 deletions.
3 changes: 0 additions & 3 deletions tests/rustdoc-json/doc_hidden_failure.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Regression test for <https://github.com/rust-lang/rust/issues/98007>.

#![feature(no_core)]
#![no_core]

mod auto {
mod action_row {
pub struct ActionRowBuilder;
Expand Down
6 changes: 0 additions & 6 deletions tests/rustdoc-json/enums/field_hidden.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
// Regression test for <https://github.com/rust-lang/rust/issues/100529>.

#![no_core]
#![feature(no_core, lang_items)]

#[lang = "sized"]
trait Sized {}

// @has "$.index[*][?(@.name=='ParseError')]"
// @has "$.index[*][?(@.name=='UnexpectedEndTag')]"
// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant.kind.tuple" [null]
Expand Down
6 changes: 0 additions & 6 deletions tests/rustdoc-json/enums/kind.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
// ignore-tidy-linelength

#![feature(no_core, lang_items)]
#![no_core]

#[lang = "sized"]
trait Sized {}

pub enum Foo {
// @set Unit = "$.index[*][?(@.name=='Unit')].id"
// @is "$.index[*][?(@.name=='Unit')].inner.variant.kind" '"plain"'
Expand Down
6 changes: 0 additions & 6 deletions tests/rustdoc-json/enums/tuple_fields_hidden.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#![feature(no_core, lang_items)]
#![no_core]

#[lang = "sized"]
trait Sized {}

// @set 1.1.0 = "$.index[*][?(@.docs=='1.1.0')].id"
// @set 2.1.0 = "$.index[*][?(@.docs=='2.1.0')].id"
// @set 2.1.1 = "$.index[*][?(@.docs=='2.1.1')].id"
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/enums/use_glob.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Regression test for <https://github.com/rust-lang/rust/issues/104942>

#![feature(no_core)]
#![no_core]

// @set Color = "$.index[*][?(@.name == 'Color')].id"
pub enum Color {
Red,
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/enums/use_variant.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![feature(no_core)]
#![no_core]

// @set AlwaysNone = "$.index[*][?(@.name == 'AlwaysNone')].id"
pub enum AlwaysNone {
// @set None = "$.index[*][?(@.name == 'None')].id"
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/fn_pointer/generics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// ignore-tidy-linelength

#![feature(no_core)]
#![no_core]

// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1
// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][0]" '"val"'
// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][1].borrowed_ref.lifetime" \"\'c\"
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/fns/extern_c_variadic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![feature(no_core)]
#![no_core]

extern "C" {
// @is "$.index[*][?(@.name == 'not_variadic')].inner.function.decl.c_variadic" false
pub fn not_variadic(_: i32);
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/fns/generic_args.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// ignore-tidy-linelength

#![feature(no_core)]
#![no_core]

// @set foo = "$.index[*][?(@.name=='Foo')].id"
pub trait Foo {}

Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/fns/generic_returns.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// ignore-tidy-linelength

#![feature(no_core)]
#![no_core]

// @count "$.index[*][?(@.name=='generic_returns')].inner.module.items[*]" 2

// @set foo = "$.index[*][?(@.name=='Foo')].id"
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/fns/generics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// ignore-tidy-linelength

#![feature(no_core)]
#![no_core]

// @set wham_id = "$.index[*][?(@.name=='Wham')].id"
pub trait Wham {}

Expand Down
9 changes: 0 additions & 9 deletions tests/rustdoc-json/generic-associated-types/gats.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
// ignore-tidy-linelength

#![no_core]
#![feature(lang_items, no_core, arbitrary_self_types)]

#[lang = "sized"]
pub trait Sized {}

#[lang = "receiver"]
pub trait Receiver {}

pub trait Display {}

pub trait LendingIterator {
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/glob_import.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// This is a regression test for <https://github.com/rust-lang/rust/issues/98003>.

#![feature(no_core)]
#![no_std]
#![no_core]

// @has "$.index[*][?(@.name=='glob')]"
// @has "$.index[*][?(@.inner.import)].inner.import.name" \"*\"


mod m1 {
pub fn f() {}
}
Expand Down
7 changes: 1 addition & 6 deletions tests/rustdoc-json/impls/impl_item_visibility.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![feature(no_core)]
#![no_core]

pub struct Foo;

/// impl Foo priv
Expand All @@ -9,18 +6,16 @@ impl Foo {
}
// @!has '$.index[*][?(@.docs=="impl Foo priv")]'


/// impl Foo pub
impl Foo {
pub fn qux() {}
}
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'


/// impl Foo hidden
impl Foo {
#[doc(hidden)]
pub fn __quazl(){}
pub fn __quazl() {}
}
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
6 changes: 1 addition & 5 deletions tests/rustdoc-json/impls/impl_item_visibility_show_hidden.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// compile-flags: --document-hidden-items
#![feature(no_core)]
#![no_core]

pub struct Foo;

Expand All @@ -11,18 +9,16 @@ impl Foo {
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo priv")].visibility' '"default"'


/// impl Foo pub
impl Foo {
pub fn qux() {}
}
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'


/// impl Foo hidden
impl Foo {
#[doc(hidden)]
pub fn __quazl(){}
pub fn __quazl() {}
}
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// compile-flags: --document-private-items
#![feature(no_core)]
#![no_core]

pub struct Foo;

Expand All @@ -10,18 +8,16 @@ impl Foo {
}
// @is '$.index[*][?(@.docs=="impl Foo priv")].visibility' '"default"'


/// impl Foo pub
impl Foo {
pub fn qux() {}
}
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'


/// impl Foo hidden
impl Foo {
#[doc(hidden)]
pub fn __quazl(){}
pub fn __quazl() {}
}
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
14 changes: 6 additions & 8 deletions tests/rustdoc-json/impls/import_from_private.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// https://github.com/rust-lang/rust/issues/100252

#![feature(no_core)]
#![no_core]

mod bar {
// @set baz = "$.index[*][?(@.inner.struct)].id"
// @set baz = "$.index[*][?(@.name == 'Baz')].id"
pub struct Baz;
// @set impl = "$.index[*][?(@.inner.impl)].id"
// @set impl = "$.index[*][?(@.docs == 'impl')].id"
/// impl
impl Baz {
// @set doit = "$.index[*][?(@.inner.function)].id"
// @set doit = "$.index[*][?(@.name == 'doit')].id"
pub fn doit() {}
}
}
Expand All @@ -18,5 +16,5 @@ pub use bar::Baz;

// @is "$.index[*].inner.module.items[*]" $import
// @is "$.index[*].inner.import.id" $baz
// @is "$.index[*].inner.struct.impls[*]" $impl
// @is "$.index[*].inner.impl.items[*]" $doit
// @has "$.index[*][?(@.name == 'Baz')].inner.struct.impls[*]" $impl
// @is "$.index[*][?(@.docs=='impl')].inner.impl.items[*]" $doit
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(no_core)]
#![no_core]

// @count "$.index[*][?(@.inner.impl)]" 1
// @has "$.index[*][?(@.docs=='Here')]"
// @!has "$.index[*][?(@.docs=='Not Here')]"
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
// @has "$.index[*][?(@.name=='PubTrait')]"
Expand All @@ -11,5 +9,7 @@ pub trait PubTrait {}
pub struct HiddenPubStruct;
pub struct NotHiddenPubStruct;

/// Not Here
impl PubTrait for HiddenPubStruct {}
/// Here
impl PubTrait for NotHiddenPubStruct {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// compile-flags: --document-hidden-items

#![feature(no_core)]
#![no_core]

// @has "$.index[*][?(@.name == 'HiddenPubStruct')]"
// @has "$.index[*][?(@.inner.impl)]"
// @has "$.index[*][?(@.name=='PubTrait')]"
Expand Down
12 changes: 6 additions & 6 deletions tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#![feature(no_core)]
#![no_core]

// @count "$.index[*][?(@.inner.impl)]" 1
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
// @has "$.index[*][?(@.name=='PubTrait')]"
pub trait PubTrait {}

#[doc(hidden)]
pub mod hidden {
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
pub struct HiddenPubStruct;

// @!has "$.index[*][?(@.docs == 'Not Here')]"
/// Not Here
impl crate::PubTrait for HiddenPubStruct {}
}

pub mod not_hidden {
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
pub struct NotHiddenPubStruct;

// @has "$.index[*][?(@.docs == 'Here')]"
/// Here
impl crate::PubTrait for NotHiddenPubStruct {}
}
5 changes: 1 addition & 4 deletions tests/rustdoc-json/impls/local_for_local.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![feature(no_core)]
#![no_core]

// @set struct = "$.index[*][?(@.name=='Struct')].id"
pub struct Struct;
// @set trait = "$.index[*][?(@.name=='Trait')].id"
Expand All @@ -9,7 +6,7 @@ pub trait Trait {}
/// impl
impl Trait for Struct {}

// @is "$.index[*][?(@.name=='Struct')].inner.struct.impls[*]" $impl
// @has "$.index[*][?(@.name=='Struct')].inner.struct.impls[*]" $impl
// @is "$.index[*][?(@.name=='Trait')].inner.trait.implementations[*]" $impl
// @is "$.index[*][?(@.docs=='impl')].inner.impl.trait.id" $trait
// @is "$.index[*][?(@.docs=='impl')].inner.impl.for.resolved_path.id" $struct
2 changes: 0 additions & 2 deletions tests/rustdoc-json/impls/local_for_local_primitive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![feature(no_core)]
#![feature(rustc_attrs)]
#![no_core]

// @set Local = "$.index[*][?(@.name=='Local')].id"
pub trait Local {}
Expand Down
9 changes: 5 additions & 4 deletions tests/rustdoc-json/lifetime/longest.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// ignore-tidy-linelength

#![feature(no_core)]
#![no_core]

// @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": []}}'
Expand All @@ -26,5 +23,9 @@
// @is "$.index[*][?(@.name=='longest')].inner.function.decl.output.borrowed_ref.type.primitive" \"str\"

pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str {
if l.len() > r.len() { l } else { r }
if l.len() > r.len() {
l
} else {
r
}
}
3 changes: 0 additions & 3 deletions tests/rustdoc-json/lifetime/outlives.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// ignore-tidy-linelength

#![feature(no_core)]
#![no_core]

// @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\"
Expand Down
2 changes: 0 additions & 2 deletions tests/rustdoc-json/methods/abi.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// ignore-tidy-linelength

#![feature(abi_vectorcall)]
#![feature(no_core)]
#![no_core]

// @has "$.index[*][?(@.name=='Foo')]"
pub struct Foo;
Expand Down
11 changes: 1 addition & 10 deletions tests/rustdoc-json/non_lifetime_binders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
#![feature(non_lifetime_binders)]
#![allow(incomplete_features)]

#![no_core]
#![feature(lang_items, no_core)]

#[lang = "sized"]
pub trait Sized {}

pub trait Trait {}

#[lang = "phantom_data"]
struct PhantomData<T_>;

pub struct Wrapper<T_>(PhantomData<T_>);
pub struct Wrapper<T_>(std::marker::PhantomData<T_>);

// @count "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[*]" 2
// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[0].name" \"\'a\"
Expand Down
6 changes: 1 addition & 5 deletions tests/rustdoc-json/primitives/primitive_overloading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
// Regression test for <https://github.com/rust-lang/rust/issues/98006>.

#![feature(rustc_attrs)]
#![feature(no_core)]

#![no_core]

// @has "$.index[*][?(@.name=='usize')]"
// @has "$.index[*][?(@.name=='prim')]"

#[rustc_doc_primitive = "usize"]
/// This is the built-in type `usize`.
mod prim {
}
mod prim {}
3 changes: 0 additions & 3 deletions tests/rustdoc-json/reexport/export_extern_crate_as_self.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/100531>

#![feature(no_core)]
#![no_core]

#![crate_name = "export_extern_crate_as_self"]

// ignore-tidy-linelength
Expand Down
Loading

0 comments on commit 5d00a5d

Please sign in to comment.