Update tests for rustc_doc_primitive

This commit is contained in:
Guillaume Gomez 2023-03-21 16:44:06 +01:00
parent f40aa598e9
commit 3ef8d2d607
29 changed files with 57 additions and 56 deletions

View File

@ -1,5 +1,5 @@
#![feature(no_core)]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#![no_core]
// @set Local = "$.index[*][?(@.name=='Local')].id"
@ -16,6 +16,6 @@ impl Local for bool {}
// FIXME(#101695): Test bool's `impls` include "Local for bool"
// @has "$.index[*][?(@.name=='bool')]"
#[doc(primitive = "bool")]
#[rustc_doc_primitive = "bool"]
/// Boolean docs
mod prim_bool {}

View File

@ -8,7 +8,7 @@
//! Link to [i32][prim@i32] [i64][prim@i64]
#[doc(primitive = "i32")]
#[rustc_doc_primitive = "i32"]
mod prim_i32 {}
// @set local_i32 = "$.index[*][?(@.name=='i32')].id"

View File

@ -25,7 +25,7 @@ pub trait Trait {}
impl Trait for i32 {}
/// i32
#[doc(primitive = "i32")]
#[rustc_doc_primitive = "i32"]
mod prim_i32 {}
// @set i32 = "$.index[*][?(@.docs=='i32')].id"

View File

@ -2,7 +2,7 @@
// Regression test for <https://github.com/rust-lang/rust/issues/98006>.
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#![feature(no_core)]
#![no_core]
@ -10,7 +10,7 @@
// @has "$.index[*][?(@.name=='usize')]"
// @has "$.index[*][?(@.name=='prim')]"
#[doc(primitive = "usize")]
#[rustc_doc_primitive = "usize"]
/// This is the built-in type `usize`.
mod prim {
}

View File

@ -1,8 +1,8 @@
// edition:2018
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#[doc(primitive = "usize")]
#[rustc_doc_primitive = "usize"]
mod usize {}
// @set local_crate_id = "$.index[*][?(@.name=='use_primitive')].crate_id"

View File

@ -2,12 +2,13 @@
// check-pass
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
//! the features only used in std also have entries in the table, so make sure those get pulled out
//! properly as well
/// woo, check it out, we can write our own primitive docs lol
#[doc(primitive="unit")]
#[rustc_doc_primitive = "unit"]
mod prim_unit {}
/// keywords? sure, pile them on

View File

@ -1,10 +1,10 @@
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#![crate_name = "foo"]
pub use std::fs::File;
// @has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation'
#[doc(primitive = "i16")]
#[rustc_doc_primitive = "i16"]
/// I love poneys!
mod prim {}

View File

@ -2,6 +2,7 @@
// compile-flags: -Cmetadata=aux
#![crate_type = "rlib"]
#![doc(html_root_url = "http://example.com/")]
#![feature(rustc_attrs)]
#![feature(lang_items)]
#![no_std]
@ -12,5 +13,5 @@ fn foo() {}
fn bar(_: &core::panic::PanicInfo) -> ! { loop {} }
/// dox
#[doc(primitive = "pointer")]
#[rustc_doc_primitive = "pointer"]
pub mod ptr {}

View File

@ -1,9 +1,10 @@
// compile-flags: --crate-type lib --edition 2018
#![feature(rustc_attrs)]
#![feature(no_core)]
#![no_core]
#[doc(primitive = "usize")]
#[rustc_doc_primitive = "usize"]
/// This is the built-in type `usize`.
mod usize {
}

View File

@ -2,7 +2,7 @@
// aux-build:source_code.rs
// build-aux-docs
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#![crate_name = "foo"]
@ -65,5 +65,5 @@ pub fn foo4() {
}
// @has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool'
#[doc(primitive = "bool")]
#[rustc_doc_primitive = "bool"]
mod whatever {}

View File

@ -3,7 +3,7 @@
#![rustc_coherence_is_core]
#![crate_type="rlib"]
#[doc(primitive = "char")]
#[rustc_doc_primitive = "char"]
/// Some char docs
mod char {}

View File

@ -1,4 +1,4 @@
// Crate tree without a `doc(primitive)` module for primitive type linked to by a doc link.
// Crate tree without a `rustc_doc_primitive` module for primitive type linked to by a doc link.
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(no_core, lang_items, rustc_attrs)]

View File

@ -10,7 +10,7 @@
//! A [prim@`char`] and its [`char::len_utf8`].
#[doc(primitive = "char")]
#[rustc_doc_primitive = "char"]
mod char {}
impl char {

View File

@ -25,7 +25,7 @@ impl usize {
pub type ME = usize;
}
#[doc(primitive = "usize")]
#[rustc_doc_primitive = "usize"]
/// This has some docs.
mod usize {}

View File

@ -1,7 +1,7 @@
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @has issue_15318_3/primitive.pointer.html
/// dox
#[doc(primitive = "pointer")]
#[rustc_doc_primitive = "pointer"]
pub mod ptr {}

View File

@ -3,7 +3,7 @@
#![no_std]
pub mod str {
#![doc(primitive = "str")]
#![rustc_doc_primitive = "str"]
impl str {
// @hasraw search-index.js foo

View File

@ -6,10 +6,10 @@
//!
//! [#80737]: https://github.com/rust-lang/rust/issues/80737
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#![no_std]
#[doc(primitive = "reference")]
#[rustc_doc_primitive = "reference"]
/// Some useless docs, wouhou!
///
/// We need to put this in here, because notable traits

View File

@ -5,9 +5,9 @@
//!
//! [#78160]: https://github.com/rust-lang/rust/issues/78160
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#[doc(primitive = "reference")]
#[rustc_doc_primitive = "reference"]
/// Some useless docs, wouhou!
///
/// We need to put this in here, because notable traits

View File

@ -1,6 +1,6 @@
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @has foo/index.html
// @has - '//h2[@id="primitives"]' 'Primitive Types'
@ -16,7 +16,7 @@
// @count - '//*[@class="impl"]' 1
// @has - '//*[@id="impl-Foo%3C%26A%3E-for-%26B"]/*[@class="code-header"]' \
// 'impl<A, B> Foo<&A> for &B'
#[doc(primitive = "reference")]
#[rustc_doc_primitive = "reference"]
/// this is a test!
mod reference {}

View File

@ -1,7 +1,7 @@
// compile-flags: --crate-type lib --edition 2018
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @has foo/primitive.slice.html '//a[@class="primitive"]' 'slice'
// @has - '//h1' 'Primitive Type slice'
@ -9,6 +9,6 @@
// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations'
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Send for [T]where T: Send'
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Sync for [T]where T: Sync'
#[doc(primitive = "slice")]
#[rustc_doc_primitive = "slice"]
/// this is a test!
mod slice_prim {}

View File

@ -1,7 +1,7 @@
// compile-flags: --crate-type lib --edition 2018
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @has foo/primitive.tuple.html '//a[@class="primitive"]' 'tuple'
// @has - '//h1' 'Primitive Type tuple'
@ -9,7 +9,7 @@
// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations'
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Send'
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync'
#[doc(primitive = "tuple")]
#[rustc_doc_primitive = "tuple"]
/// this is a test!
///
// Hardcoded anchor to header written in library/core/src/primitive_docs.rs

View File

@ -1,7 +1,7 @@
// compile-flags: --crate-type lib --edition 2018
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @has foo/primitive.unit.html '//a[@class="primitive"]' 'unit'
// @has - '//h1' 'Primitive Type unit'
@ -9,6 +9,6 @@
// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations'
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()'
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for ()'
#[doc(primitive = "unit")]
#[rustc_doc_primitive = "unit"]
/// this is a test!
mod unit_prim {}

View File

@ -1,8 +1,8 @@
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
#![crate_name = "foo"]
// @has foo/primitive.i32.html '//*[@id="impl-ToString-for-i32"]//h3[@class="code-header"]' 'impl<T> ToString for T'
#[doc(primitive = "i32")]
#[rustc_doc_primitive = "i32"]
/// Some useless docs, wouhou!
mod i32 {}

View File

@ -1,6 +1,6 @@
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @has foo/index.html '//h2[@id="primitives"]' 'Primitive Types'
// @has foo/index.html '//a[@href="primitive.i32.html"]' 'i32'
@ -11,11 +11,11 @@
// @has foo/primitive.i32.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
// @has foo/index.html '//a/@href' '../foo/index.html'
// @!has foo/index.html '//span' '🔒'
#[doc(primitive = "i32")]
#[rustc_doc_primitive = "i32"]
/// this is a test!
mod i32{}
// @has foo/primitive.bool.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello'
#[doc(primitive = "bool")]
#[rustc_doc_primitive = "bool"]
/// hello
mod bool {}

View File

@ -1,6 +1,6 @@
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @has 'foo/all.html'
// @has - '//*[@class="sidebar-elems"]//li' 'Structs'
@ -31,5 +31,5 @@ macro_rules! foo {
pub type Type = u8;
pub const FOO: u8 = 0;
pub static BAR: u8 = 0;
#[doc(primitive = "u8")]
#[rustc_doc_primitive = "u8"]
mod u8 {}

View File

@ -1,4 +1,5 @@
#![crate_name = "foo"]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
// tests for the html <title> element
@ -39,6 +40,6 @@ mod continue_keyword {}
// @has foo/primitive.u8.html '//head/title' 'u8 - Rust'
// @!has - '//head/title' 'foo'
#[doc(primitive = "u8")]
#[rustc_doc_primitive = "u8"]
/// `u8` docs
mod u8 {}

View File

@ -1,5 +1,5 @@
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
#![feature(rustc_attrs)]
// @matches 'foo/index.html' '//h1' 'Crate foo'
// @matches 'foo/index.html' '//h2[@class="location"]' 'Crate foo'
@ -41,7 +41,7 @@ macro_rules! foo_macro {
}
// @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool'
#[doc(primitive = "bool")]
#[rustc_doc_primitive = "bool"]
mod bool {}
// @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC'

View File

@ -1,7 +1,5 @@
// check-pass
#[doc(primitive = "usize")]
//~^ WARNING `doc(primitive)` should never have been stable
//~| WARNING hard error in a future release
#[rustc_doc_primitive = "usize"]
//~^ ERROR `rustc_doc_primitive` is a rustc internal attribute
/// Some docs
mod usize {}

View File

@ -1,12 +1,11 @@
warning: `doc(primitive)` should never have been stable
--> $DIR/feature-gate-doc_primitive.rs:2:7
error[E0658]: `rustc_doc_primitive` is a rustc internal attribute
--> $DIR/feature-gate-doc_primitive.rs:1:1
|
LL | #[doc(primitive = "usize")]
| ^^^^^^^^^^^^^^^^^^^
LL | #[rustc_doc_primitive = "usize"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
= note: `#[warn(invalid_doc_attributes)]` on by default
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
warning: 1 warning emitted
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.