Skip to content

Commit 5d00a5d

Browse files
Rollup merge of #117679 - aDotInTheVoid:yes-core, r=GuillaumeGomez
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
2 parents c828371 + 434b69a commit 5d00a5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+41
-202
lines changed

tests/rustdoc-json/doc_hidden_failure.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Regression test for <https://github.com/rust-lang/rust/issues/98007>.
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
mod auto {
74
mod action_row {
85
pub struct ActionRowBuilder;

tests/rustdoc-json/enums/field_hidden.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
// Regression test for <https://github.com/rust-lang/rust/issues/100529>.
22

3-
#![no_core]
4-
#![feature(no_core, lang_items)]
5-
6-
#[lang = "sized"]
7-
trait Sized {}
8-
93
// @has "$.index[*][?(@.name=='ParseError')]"
104
// @has "$.index[*][?(@.name=='UnexpectedEndTag')]"
115
// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant.kind.tuple" [null]

tests/rustdoc-json/enums/kind.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core, lang_items)]
4-
#![no_core]
5-
6-
#[lang = "sized"]
7-
trait Sized {}
8-
93
pub enum Foo {
104
// @set Unit = "$.index[*][?(@.name=='Unit')].id"
115
// @is "$.index[*][?(@.name=='Unit')].inner.variant.kind" '"plain"'

tests/rustdoc-json/enums/tuple_fields_hidden.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#![feature(no_core, lang_items)]
2-
#![no_core]
3-
4-
#[lang = "sized"]
5-
trait Sized {}
6-
71
// @set 1.1.0 = "$.index[*][?(@.docs=='1.1.0')].id"
82
// @set 2.1.0 = "$.index[*][?(@.docs=='2.1.0')].id"
93
// @set 2.1.1 = "$.index[*][?(@.docs=='2.1.1')].id"

tests/rustdoc-json/enums/use_glob.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Regression test for <https://github.com/rust-lang/rust/issues/104942>
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @set Color = "$.index[*][?(@.name == 'Color')].id"
74
pub enum Color {
85
Red,

tests/rustdoc-json/enums/use_variant.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
41
// @set AlwaysNone = "$.index[*][?(@.name == 'AlwaysNone')].id"
52
pub enum AlwaysNone {
63
// @set None = "$.index[*][?(@.name == 'None')].id"

tests/rustdoc-json/fn_pointer/generics.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1
74
// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][0]" '"val"'
85
// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][1].borrowed_ref.lifetime" \"\'c\"

tests/rustdoc-json/fns/extern_c_variadic.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
41
extern "C" {
52
// @is "$.index[*][?(@.name == 'not_variadic')].inner.function.decl.c_variadic" false
63
pub fn not_variadic(_: i32);

tests/rustdoc-json/fns/generic_args.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @set foo = "$.index[*][?(@.name=='Foo')].id"
74
pub trait Foo {}
85

tests/rustdoc-json/fns/generic_returns.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @count "$.index[*][?(@.name=='generic_returns')].inner.module.items[*]" 2
74

85
// @set foo = "$.index[*][?(@.name=='Foo')].id"

tests/rustdoc-json/fns/generics.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @set wham_id = "$.index[*][?(@.name=='Wham')].id"
74
pub trait Wham {}
85

tests/rustdoc-json/generic-associated-types/gats.rs

-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![no_core]
4-
#![feature(lang_items, no_core, arbitrary_self_types)]
5-
6-
#[lang = "sized"]
7-
pub trait Sized {}
8-
9-
#[lang = "receiver"]
10-
pub trait Receiver {}
11-
123
pub trait Display {}
134

145
pub trait LendingIterator {

tests/rustdoc-json/glob_import.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
// This is a regression test for <https://github.com/rust-lang/rust/issues/98003>.
22

3-
#![feature(no_core)]
43
#![no_std]
5-
#![no_core]
64

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

10-
118
mod m1 {
129
pub fn f() {}
1310
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
41
pub struct Foo;
52

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

12-
139
/// impl Foo pub
1410
impl Foo {
1511
pub fn qux() {}
1612
}
1713
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'
1814

19-
2015
/// impl Foo hidden
2116
impl Foo {
2217
#[doc(hidden)]
23-
pub fn __quazl(){}
18+
pub fn __quazl() {}
2419
}
2520
// FIXME(#111564): Is this the right behaviour?
2621
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// compile-flags: --document-hidden-items
2-
#![feature(no_core)]
3-
#![no_core]
42

53
pub struct Foo;
64

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

14-
1512
/// impl Foo pub
1613
impl Foo {
1714
pub fn qux() {}
1815
}
1916
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'
2017

21-
2218
/// impl Foo hidden
2319
impl Foo {
2420
#[doc(hidden)]
25-
pub fn __quazl(){}
21+
pub fn __quazl() {}
2622
}
2723
// FIXME(#111564): Is this the right behaviour?
2824
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// compile-flags: --document-private-items
2-
#![feature(no_core)]
3-
#![no_core]
42

53
pub struct Foo;
64

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

13-
1411
/// impl Foo pub
1512
impl Foo {
1613
pub fn qux() {}
1714
}
1815
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'
1916

20-
2117
/// impl Foo hidden
2218
impl Foo {
2319
#[doc(hidden)]
24-
pub fn __quazl(){}
20+
pub fn __quazl() {}
2521
}
2622
// FIXME(#111564): Is this the right behaviour?
2723
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// https://github.com/rust-lang/rust/issues/100252
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
mod bar {
7-
// @set baz = "$.index[*][?(@.inner.struct)].id"
4+
// @set baz = "$.index[*][?(@.name == 'Baz')].id"
85
pub struct Baz;
9-
// @set impl = "$.index[*][?(@.inner.impl)].id"
6+
// @set impl = "$.index[*][?(@.docs == 'impl')].id"
7+
/// impl
108
impl Baz {
11-
// @set doit = "$.index[*][?(@.inner.function)].id"
9+
// @set doit = "$.index[*][?(@.name == 'doit')].id"
1210
pub fn doit() {}
1311
}
1412
}
@@ -18,5 +16,5 @@ pub use bar::Baz;
1816

1917
// @is "$.index[*].inner.module.items[*]" $import
2018
// @is "$.index[*].inner.import.id" $baz
21-
// @is "$.index[*].inner.struct.impls[*]" $impl
22-
// @is "$.index[*].inner.impl.items[*]" $doit
19+
// @has "$.index[*][?(@.name == 'Baz')].inner.struct.impls[*]" $impl
20+
// @is "$.index[*][?(@.docs=='impl')].inner.impl.items[*]" $doit
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
4-
// @count "$.index[*][?(@.inner.impl)]" 1
1+
// @has "$.index[*][?(@.docs=='Here')]"
2+
// @!has "$.index[*][?(@.docs=='Not Here')]"
53
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
64
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
75
// @has "$.index[*][?(@.name=='PubTrait')]"
@@ -11,5 +9,7 @@ pub trait PubTrait {}
119
pub struct HiddenPubStruct;
1210
pub struct NotHiddenPubStruct;
1311

12+
/// Not Here
1413
impl PubTrait for HiddenPubStruct {}
14+
/// Here
1515
impl PubTrait for NotHiddenPubStruct {}

tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// compile-flags: --document-hidden-items
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @has "$.index[*][?(@.name == 'HiddenPubStruct')]"
74
// @has "$.index[*][?(@.inner.impl)]"
85
// @has "$.index[*][?(@.name=='PubTrait')]"
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
4-
// @count "$.index[*][?(@.inner.impl)]" 1
5-
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
6-
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
71
// @has "$.index[*][?(@.name=='PubTrait')]"
82
pub trait PubTrait {}
93

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

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

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

18+
// @has "$.index[*][?(@.docs == 'Here')]"
19+
/// Here
2020
impl crate::PubTrait for NotHiddenPubStruct {}
2121
}
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
41
// @set struct = "$.index[*][?(@.name=='Struct')].id"
52
pub struct Struct;
63
// @set trait = "$.index[*][?(@.name=='Trait')].id"
@@ -9,7 +6,7 @@ pub trait Trait {}
96
/// impl
107
impl Trait for Struct {}
118

12-
// @is "$.index[*][?(@.name=='Struct')].inner.struct.impls[*]" $impl
9+
// @has "$.index[*][?(@.name=='Struct')].inner.struct.impls[*]" $impl
1310
// @is "$.index[*][?(@.name=='Trait')].inner.trait.implementations[*]" $impl
1411
// @is "$.index[*][?(@.docs=='impl')].inner.impl.trait.id" $trait
1512
// @is "$.index[*][?(@.docs=='impl')].inner.impl.for.resolved_path.id" $struct

tests/rustdoc-json/impls/local_for_local_primitive.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#![feature(no_core)]
21
#![feature(rustc_attrs)]
3-
#![no_core]
42

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

tests/rustdoc-json/lifetime/longest.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].name" \"\'a\"
74
// @is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].kind" '{"lifetime": {"outlives": []}}'
85
// @is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].kind" '{"lifetime": {"outlives": []}}'
@@ -26,5 +23,9 @@
2623
// @is "$.index[*][?(@.name=='longest')].inner.function.decl.output.borrowed_ref.type.primitive" \"str\"
2724

2825
pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str {
29-
if l.len() > r.len() { l } else { r }
26+
if l.len() > r.len() {
27+
l
28+
} else {
29+
r
30+
}
3031
}

tests/rustdoc-json/lifetime/outlives.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
// @count "$.index[*][?(@.name=='foo')].inner.function.generics.params[*]" 3
74
// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates" []
85
// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[0].name" \"\'a\"

tests/rustdoc-json/methods/abi.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// ignore-tidy-linelength
22

33
#![feature(abi_vectorcall)]
4-
#![feature(no_core)]
5-
#![no_core]
64

75
// @has "$.index[*][?(@.name=='Foo')]"
86
pub struct Foo;

tests/rustdoc-json/non_lifetime_binders.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
#![feature(non_lifetime_binders)]
44
#![allow(incomplete_features)]
55

6-
#![no_core]
7-
#![feature(lang_items, no_core)]
8-
9-
#[lang = "sized"]
10-
pub trait Sized {}
11-
126
pub trait Trait {}
137

14-
#[lang = "phantom_data"]
15-
struct PhantomData<T_>;
16-
17-
pub struct Wrapper<T_>(PhantomData<T_>);
8+
pub struct Wrapper<T_>(std::marker::PhantomData<T_>);
189

1910
// @count "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[*]" 2
2011
// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[0].name" \"\'a\"

tests/rustdoc-json/primitives/primitive_overloading.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
// Regression test for <https://github.com/rust-lang/rust/issues/98006>.
44

55
#![feature(rustc_attrs)]
6-
#![feature(no_core)]
7-
8-
#![no_core]
96

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

1310
#[rustc_doc_primitive = "usize"]
1411
/// This is the built-in type `usize`.
15-
mod prim {
16-
}
12+
mod prim {}

tests/rustdoc-json/reexport/export_extern_crate_as_self.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
//! Regression test for <https://github.com/rust-lang/rust/issues/100531>
22
3-
#![feature(no_core)]
4-
#![no_core]
5-
63
#![crate_name = "export_extern_crate_as_self"]
74

85
// ignore-tidy-linelength

0 commit comments

Comments
 (0)