diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/codegen/tune-cpu-on-functions.rs | 21 | ||||
| -rw-r--r-- | src/test/incremental/thinlto/cgu_invalidated_via_import.rs | 4 | ||||
| -rw-r--r-- | src/test/incremental/thinlto/cgu_keeps_identical_fn.rs | 47 | ||||
| -rw-r--r-- | src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/allow_missing_docs.rs | 41 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/allow_missing_docs.stderr | 20 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/allow_missing_docs.stdout | 7 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/intra-links-ambiguity.rs | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/intra-links-ambiguity.stderr | 17 | ||||
| -rw-r--r-- | src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs | 6 | ||||
| -rw-r--r-- | src/test/rustdoc/auxiliary/reexport-check.rs | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/intra-link-reexport-additional-docs.rs | 9 | ||||
| -rw-r--r-- | src/test/rustdoc/primitive-link.rs | 3 | ||||
| -rw-r--r-- | src/test/rustdoc/reexport-check.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/lto-opt-level-s.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/lto-opt-level-z.rs | 7 |
16 files changed, 200 insertions, 7 deletions
diff --git a/src/test/codegen/tune-cpu-on-functions.rs b/src/test/codegen/tune-cpu-on-functions.rs new file mode 100644 index 00000000000..9121799cdbf --- /dev/null +++ b/src/test/codegen/tune-cpu-on-functions.rs @@ -0,0 +1,21 @@ +// This test makes sure that functions get annotated with the proper +// "tune-cpu" attribute in LLVM. + +// no-prefer-dynamic +// ignore-tidy-linelength +// compile-flags: -C no-prepopulate-passes -C panic=abort -C linker-plugin-lto -Cpasses=name-anon-globals -Z tune-cpu=generic + +#![crate_type = "staticlib"] + +// CHECK-LABEL: define {{.*}} @exported() {{.*}} #0 +#[no_mangle] +pub extern fn exported() { + not_exported(); +} + +// CHECK-LABEL: ; tune_cpu_on_functions::not_exported +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define {{.*}}() {{.*}} #0 +fn not_exported() {} + +// CHECK: attributes #0 = {{.*}} "tune-cpu"="{{.*}}" diff --git a/src/test/incremental/thinlto/cgu_invalidated_via_import.rs b/src/test/incremental/thinlto/cgu_invalidated_via_import.rs index 8160f8f3a99..5fe435d796f 100644 --- a/src/test/incremental/thinlto/cgu_invalidated_via_import.rs +++ b/src/test/incremental/thinlto/cgu_invalidated_via_import.rs @@ -33,7 +33,9 @@ mod foo { #[cfg(not(cfail1))] pub fn inlined_fn() -> u32 { - 1234 + // See `cgu_keeps_identical_fn.rs` for why this is different + // from the other version of this function. + 12345 } } diff --git a/src/test/incremental/thinlto/cgu_keeps_identical_fn.rs b/src/test/incremental/thinlto/cgu_keeps_identical_fn.rs new file mode 100644 index 00000000000..0fd5abee118 --- /dev/null +++ b/src/test/incremental/thinlto/cgu_keeps_identical_fn.rs @@ -0,0 +1,47 @@ +// This test is almost identical to `cgu_invalided_via_import`, except that +// the two versions of `inline_fn` are identical. Neither version of `inlined_fn` +// ends up with any spans in its LLVM bitecode, so LLVM is able to skip +// re-building any modules which import 'inlined_fn' + +// revisions: cfail1 cfail2 cfail3 +// compile-flags: -Z query-dep-graph -O +// build-pass (FIXME(62277): could be check-pass?) + +#![feature(rustc_attrs)] +#![crate_type="rlib"] + +#![rustc_expected_cgu_reuse(module="cgu_keeps_identical_fn-foo", + cfg="cfail2", + kind="no")] +#![rustc_expected_cgu_reuse(module="cgu_keeps_identical_fn-foo", + cfg="cfail3", + kind="post-lto")] + +#![rustc_expected_cgu_reuse(module="cgu_keeps_identical_fn-bar", + cfg="cfail2", + kind="post-lto")] +#![rustc_expected_cgu_reuse(module="cgu_keeps_identical_fn-bar", + cfg="cfail3", + kind="post-lto")] + +mod foo { + + // Trivial functions like this one are imported very reliably by ThinLTO. + #[cfg(cfail1)] + pub fn inlined_fn() -> u32 { + 1234 + } + + #[cfg(not(cfail1))] + pub fn inlined_fn() -> u32 { + 1234 + } +} + +pub mod bar { + use foo::inlined_fn; + + pub fn caller() -> u32 { + inlined_fn() + } +} diff --git a/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs b/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs index 24e5d2438bd..045f2011958 100644 --- a/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs +++ b/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs @@ -37,7 +37,9 @@ mod foo { #[cfg(not(cfail1))] pub fn inlined_fn() -> u32 { - 1234 + // See `cgu_keeps_identical_fn.rs` for why this is different + // from the other version of this function. + 12345 } } diff --git a/src/test/rustdoc-ui/coverage/allow_missing_docs.rs b/src/test/rustdoc-ui/coverage/allow_missing_docs.rs new file mode 100644 index 00000000000..c077be31b20 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/allow_missing_docs.rs @@ -0,0 +1,41 @@ +// compile-flags:-Z unstable-options --show-coverage +// check-pass + +//! Make sure to have some docs on your crate root + +#[allow(missing_docs)] +pub mod mod_foo { + pub struct Bar; +} + +/// This is a struct with a `#[allow(missing_docs)]` +pub struct AllowTheMissingDocs { + #[allow(missing_docs)] + pub empty_str: String, + + /// This has + #[allow(missing_docs)] + /// but also has documentation comments + pub hello: usize, + + /// The doc id just to create a boilerplate comment + pub doc_id: Vec<u8>, +} + +/// A function that has a documentation +pub fn this_is_func() {} + +#[allow(missing_docs)] +pub struct DemoStruct { + something: usize, +} + +#[allow(missing_docs)] +pub mod bar { + #[warn(missing_docs)] + pub struct Bar { //~ WARN + pub f: u32, //~ WARN + } + + pub struct NeedsNoDocs; +} diff --git a/src/test/rustdoc-ui/coverage/allow_missing_docs.stderr b/src/test/rustdoc-ui/coverage/allow_missing_docs.stderr new file mode 100644 index 00000000000..3d5b512d14d --- /dev/null +++ b/src/test/rustdoc-ui/coverage/allow_missing_docs.stderr @@ -0,0 +1,20 @@ +warning: missing documentation for a struct + --> $DIR/allow_missing_docs.rs:36:5 + | +LL | pub struct Bar { + | ^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/allow_missing_docs.rs:35:12 + | +LL | #[warn(missing_docs)] + | ^^^^^^^^^^^^ + +warning: missing documentation for a struct field + --> $DIR/allow_missing_docs.rs:37:9 + | +LL | pub f: u32, + | ^^^^^^^^^^ + +warning: 2 warnings emitted + diff --git a/src/test/rustdoc-ui/coverage/allow_missing_docs.stdout b/src/test/rustdoc-ui/coverage/allow_missing_docs.stdout new file mode 100644 index 00000000000..17e8ee9e23d --- /dev/null +++ b/src/test/rustdoc-ui/coverage/allow_missing_docs.stdout @@ -0,0 +1,7 @@ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ +| ...i/coverage/allow_missing_docs.rs | 5 | 71.4% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ +| Total | 5 | 71.4% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.rs b/src/test/rustdoc-ui/intra-links-ambiguity.rs index d1597cdca66..f63435337cf 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.rs +++ b/src/test/rustdoc-ui/intra-links-ambiguity.rs @@ -34,3 +34,7 @@ pub mod foo { /// /// Ambiguous non-implied shortcut link [`foo::bar`]. //~ERROR `foo::bar` pub struct Docs {} + +/// [true] //~ ERROR `true` is both a module and a builtin type +/// [primitive@true] +pub mod r#true {} diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.stderr b/src/test/rustdoc-ui/intra-links-ambiguity.stderr index 17891ca05ef..21b92a96737 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.stderr +++ b/src/test/rustdoc-ui/intra-links-ambiguity.stderr @@ -82,5 +82,20 @@ help: to link to the function, add parentheses LL | /// Ambiguous non-implied shortcut link [`foo::bar()`]. | ^^^^^^^^^^^^ -error: aborting due to 5 previous errors +error: `true` is both a module and a builtin type + --> $DIR/intra-links-ambiguity.rs:38:6 + | +LL | /// [true] + | ^^^^ ambiguous link + | +help: to link to the module, prefix with `mod@` + | +LL | /// [mod@true] + | ^^^^^^^^ +help: to link to the builtin type, prefix with `prim@` + | +LL | /// [prim@true] + | ^^^^^^^^^ + +error: aborting due to 6 previous errors diff --git a/src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs b/src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs new file mode 100644 index 00000000000..fc51995a94e --- /dev/null +++ b/src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs @@ -0,0 +1,6 @@ +#![crate_name = "inner"] + +/// Links to [f()] +pub struct Inner; + +pub fn f() {} diff --git a/src/test/rustdoc/auxiliary/reexport-check.rs b/src/test/rustdoc/auxiliary/reexport-check.rs new file mode 100644 index 00000000000..672ccb1cf0e --- /dev/null +++ b/src/test/rustdoc/auxiliary/reexport-check.rs @@ -0,0 +1,2 @@ +/// Docs in original +pub struct S; diff --git a/src/test/rustdoc/intra-link-reexport-additional-docs.rs b/src/test/rustdoc/intra-link-reexport-additional-docs.rs index adb072a7ed5..96f3580f305 100644 --- a/src/test/rustdoc/intra-link-reexport-additional-docs.rs +++ b/src/test/rustdoc/intra-link-reexport-additional-docs.rs @@ -1,6 +1,9 @@ +// aux-build:intra-link-reexport-additional-docs.rs +// build-aux-docs #![crate_name = "foo"] +extern crate inner; -// @has foo/struct.JoinPathsError.html '//a[@href="../foo/fn.with_code.html"]' 'crate::with_code' +// @has foo/struct.Inner.html '//a[@href="../foo/fn.with_code.html"]' 'crate::with_code' /// [crate::with_code] // @has - '//a[@href="../foo/fn.with_code.html"]' 'different text' /// [different text][with_code] @@ -11,7 +14,9 @@ #[doc = "has an attr in the way"] /// /// [reference link]: me_three -pub use std::env::JoinPathsError; +// Should still resolve links from the original module in that scope +// @has - '//a[@href="../inner/fn.f.html"]' 'f()' +pub use inner::Inner; pub fn with_code() {} pub fn me_too() {} diff --git a/src/test/rustdoc/primitive-link.rs b/src/test/rustdoc/primitive-link.rs index 8f69b894a22..3041ff77684 100644 --- a/src/test/rustdoc/primitive-link.rs +++ b/src/test/rustdoc/primitive-link.rs @@ -7,8 +7,7 @@ // @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html"]' 'std::primitive::i32' // @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html"]' 'std::primitive::str' -// FIXME: this doesn't resolve -// @ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html#associatedconstant.MAX"]' 'std::primitive::i32::MAX' +// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html#associatedconstant.MAX"]' 'std::primitive::i32::MAX' /// It contains [`u32`] and [i64]. /// It also links to [std::primitive::i32], [std::primitive::str], diff --git a/src/test/rustdoc/reexport-check.rs b/src/test/rustdoc/reexport-check.rs index dea72b81a57..066b0cfe5e8 100644 --- a/src/test/rustdoc/reexport-check.rs +++ b/src/test/rustdoc/reexport-check.rs @@ -1,5 +1,8 @@ +// aux-build:reexport-check.rs #![crate_name = "foo"] +extern crate reexport_check; + // @!has 'foo/index.html' '//code' 'pub use self::i32;' // @has 'foo/index.html' '//tr[@class="module-item"]' 'i32' // @has 'foo/i32/index.html' @@ -7,3 +10,8 @@ pub use std::i32; // @!has 'foo/index.html' '//code' 'pub use self::string::String;' // @has 'foo/index.html' '//tr[@class="module-item"]' 'String' pub use std::string::String; + +// @has 'foo/index.html' '//td[@class="docblock-short"]' 'Docs in original' +// this is a no-op, but shows what happens if there's an attribute that isn't a doc-comment +#[doc(inline)] +pub use reexport_check::S; diff --git a/src/test/ui/lto-opt-level-s.rs b/src/test/ui/lto-opt-level-s.rs new file mode 100644 index 00000000000..a7d9d5024d3 --- /dev/null +++ b/src/test/ui/lto-opt-level-s.rs @@ -0,0 +1,7 @@ +// compile-flags: -Clinker-plugin-lto -Copt-level=s +// build-pass +// no-prefer-dynamic + +#![crate_type = "rlib"] + +pub fn foo() {} diff --git a/src/test/ui/lto-opt-level-z.rs b/src/test/ui/lto-opt-level-z.rs new file mode 100644 index 00000000000..bf1f5e2b263 --- /dev/null +++ b/src/test/ui/lto-opt-level-z.rs @@ -0,0 +1,7 @@ +// compile-flags: -Clinker-plugin-lto -Copt-level=z +// build-pass +// no-prefer-dynamic + +#![crate_type = "rlib"] + +pub fn foo() {} |
