about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-07 06:49:55 +0000
committerbors <bors@rust-lang.org>2024-06-07 06:49:55 +0000
commit468310ea0cdec87460b83710a3a78825bcae73c5 (patch)
tree1dac4c134ac4b819b6d34f908886f94c9d2f1f46 /tests
parentb74702fbb2a2bd56b39849d66bd59a453ed8c89e (diff)
parent9436304871dc3ec411f14cbed68f418d2ed48a90 (diff)
downloadrust-468310ea0cdec87460b83710a3a78825bcae73c5.tar.gz
rust-468310ea0cdec87460b83710a3a78825bcae73c5.zip
Auto merge of #126108 - workingjubilee:rollup-g7m92b6, r=workingjubilee
Rollup of 7 pull requests

Successful merges:

 - #125606 (Size optimize int formatting)
 - #125724 (Uplift `Relate`/`TypeRelation` into `rustc_next_trait_solver`)
 - #126040 (Don't warn on fields in the `unreachable_pub` lint )
 - #126098 (Remove `same-lib-two-locations-no-panic` run-make test)
 - #126099 (Crate loader cleanups)
 - #126101 (Revert "Disallow ambiguous attributes on expressions" on nightly)
 - #126103 (Improve Docs for `hir::Impl` and `hir::ImplItem`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/pretty/ast-stmt-expr-attr.rs18
-rw-r--r--tests/pretty/stmt_expr_attributes.rs12
-rw-r--r--tests/run-make/same-lib-two-locations-no-panic/bar.rs3
-rw-r--r--tests/run-make/same-lib-two-locations-no-panic/foo.rs1
-rw-r--r--tests/run-make/same-lib-two-locations-no-panic/rmake.rs28
-rw-r--r--tests/ui/lint/unreachable_pub.rs10
-rw-r--r--tests/ui/lint/unreachable_pub.stderr32
-rw-r--r--tests/ui/lint/unused/unused-doc-comments-edge-cases.rs4
-rw-r--r--tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr14
-rw-r--r--tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed15
-rw-r--r--tests/ui/parser/attribute/attr-binary-expr-ambigous.rs15
-rw-r--r--tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr46
-rw-r--r--tests/ui/proc-macro/issue-81555.rs3
13 files changed, 45 insertions, 156 deletions
diff --git a/tests/pretty/ast-stmt-expr-attr.rs b/tests/pretty/ast-stmt-expr-attr.rs
index 899f7173f70..fd7272a1b1f 100644
--- a/tests/pretty/ast-stmt-expr-attr.rs
+++ b/tests/pretty/ast-stmt-expr-attr.rs
@@ -13,17 +13,17 @@ fn syntax() {
     let _ = #[attr] ();
     let _ = #[attr] (#[attr] 0,);
     let _ = #[attr] (#[attr] 0, 0);
-    let _ = (#[attr] 0) + #[attr] 0;
-    let _ = (#[attr] 0) / #[attr] 0;
-    let _ = (#[attr] 0) & #[attr] 0;
-    let _ = (#[attr] 0) % #[attr] 0;
+    let _ = #[attr] 0 + #[attr] 0;
+    let _ = #[attr] 0 / #[attr] 0;
+    let _ = #[attr] 0 & #[attr] 0;
+    let _ = #[attr] 0 % #[attr] 0;
     let _ = #[attr] (0 + 0);
     let _ = #[attr] !0;
     let _ = #[attr] -0;
     let _ = #[attr] false;
     let _ = #[attr] 0;
     let _ = #[attr] 'c';
-    let _ = (#[attr] x) as Y;
+    let _ = #[attr] x as Y;
     let _ = #[attr] (x as Y);
     let _ =
         #[attr] while true {
@@ -88,9 +88,9 @@ fn syntax() {
             let _ = ();
             foo
         };
-    let _ = (#[attr] x) = y;
+    let _ = #[attr] x = y;
     let _ = #[attr] (x = y);
-    let _ = (#[attr] x) += y;
+    let _ = #[attr] x += y;
     let _ = #[attr] (x += y);
     let _ = #[attr] foo.bar;
     let _ = (#[attr] foo).bar;
@@ -98,8 +98,8 @@ fn syntax() {
     let _ = (#[attr] foo).0;
     let _ = #[attr] foo[bar];
     let _ = (#[attr] foo)[bar];
-    let _ = (#[attr] 0)..#[attr] 0;
-    let _ = (#[attr] 0)..;
+    let _ = #[attr] 0..#[attr] 0;
+    let _ = #[attr] 0..;
     let _ = #[attr] (0..0);
     let _ = #[attr] (0..);
     let _ = #[attr] (..0);
diff --git a/tests/pretty/stmt_expr_attributes.rs b/tests/pretty/stmt_expr_attributes.rs
index f9041268211..e7fd4642724 100644
--- a/tests/pretty/stmt_expr_attributes.rs
+++ b/tests/pretty/stmt_expr_attributes.rs
@@ -147,13 +147,13 @@ fn _11() {
     let _ = #[rustc_dummy] (0);
     let _ = #[rustc_dummy] (0,);
     let _ = #[rustc_dummy] (0, 0);
-    let _ = (#[rustc_dummy] 0) + #[rustc_dummy] 0;
+    let _ = #[rustc_dummy] 0 + #[rustc_dummy] 0;
     let _ = #[rustc_dummy] !0;
     let _ = #[rustc_dummy] -0i32;
     let _ = #[rustc_dummy] false;
     let _ = #[rustc_dummy] 'c';
     let _ = #[rustc_dummy] 0;
-    let _ = (#[rustc_dummy] 0) as usize;
+    let _ = #[rustc_dummy] 0 as usize;
     let _ =
         #[rustc_dummy] while false {
             #![rustc_dummy]
@@ -208,8 +208,8 @@ fn _11() {
         };
     let const {} = #[rustc_dummy] const {};
     let mut x = 0;
-    let _ = (#[rustc_dummy] x) = 15;
-    let _ = (#[rustc_dummy] x) += 15;
+    let _ = #[rustc_dummy] x = 15;
+    let _ = #[rustc_dummy] x += 15;
     let s = Foo { data: () };
     let _ = #[rustc_dummy] s.data;
     let _ = (#[rustc_dummy] s).data;
@@ -219,8 +219,8 @@ fn _11() {
     let v = vec!(0);
     let _ = #[rustc_dummy] v[0];
     let _ = (#[rustc_dummy] v)[0];
-    let _ = (#[rustc_dummy] 0)..#[rustc_dummy] 0;
-    let _ = (#[rustc_dummy] 0)..;
+    let _ = #[rustc_dummy] 0..#[rustc_dummy] 0;
+    let _ = #[rustc_dummy] 0..;
     let _ = #[rustc_dummy] (0..0);
     let _ = #[rustc_dummy] (0..);
     let _ = #[rustc_dummy] (..0);
diff --git a/tests/run-make/same-lib-two-locations-no-panic/bar.rs b/tests/run-make/same-lib-two-locations-no-panic/bar.rs
deleted file mode 100644
index bb7b36c496e..00000000000
--- a/tests/run-make/same-lib-two-locations-no-panic/bar.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-extern crate foo;
-
-fn main() {}
diff --git a/tests/run-make/same-lib-two-locations-no-panic/foo.rs b/tests/run-make/same-lib-two-locations-no-panic/foo.rs
deleted file mode 100644
index 82b2dfe9fdb..00000000000
--- a/tests/run-make/same-lib-two-locations-no-panic/foo.rs
+++ /dev/null
@@ -1 +0,0 @@
-#![crate_name = "foo"]
diff --git a/tests/run-make/same-lib-two-locations-no-panic/rmake.rs b/tests/run-make/same-lib-two-locations-no-panic/rmake.rs
deleted file mode 100644
index 2900c3c8b74..00000000000
--- a/tests/run-make/same-lib-two-locations-no-panic/rmake.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-// A path which contains the same rlib or dylib in two locations
-// should not cause an assertion panic in the compiler.
-// This test tries to replicate the linked issue and checks
-// if the bugged error makes a resurgence.
-
-// See https://github.com/rust-lang/rust/issues/11908
-
-//@ ignore-cross-compile
-
-use run_make_support::{dynamic_lib, rust_lib, rustc, tmp_dir};
-use std::fs;
-
-fn main() {
-    let tmp_dir_other = tmp_dir().join("other");
-
-    fs::create_dir(&tmp_dir_other);
-    rustc().input("foo.rs").crate_type("dylib").arg("-Cprefer-dynamic").run();
-    fs::rename(dynamic_lib("foo"), &tmp_dir_other);
-    rustc().input("foo.rs").crate_type("dylib").arg("-Cprefer-dynamic").run();
-    rustc().input("bar.rs").library_search_path(&tmp_dir_other).run();
-    fs::remove_dir_all(tmp_dir());
-
-    fs::create_dir_all(&tmp_dir_other);
-    rustc().input("foo.rs").crate_type("rlib").run();
-    fs::rename(rust_lib("foo"), &tmp_dir_other);
-    rustc().input("foo.rs").crate_type("rlib").run();
-    rustc().input("bar.rs").library_search_path(tmp_dir_other).run();
-}
diff --git a/tests/ui/lint/unreachable_pub.rs b/tests/ui/lint/unreachable_pub.rs
index 22c091e112b..f21f6640342 100644
--- a/tests/ui/lint/unreachable_pub.rs
+++ b/tests/ui/lint/unreachable_pub.rs
@@ -9,12 +9,16 @@ mod private_mod {
     pub use std::env::{Args}; // braced-use has different item spans than unbraced
     //~^ WARNING unreachable_pub
 
+    // we lint on struct definition
     pub struct Hydrogen { //~ WARNING unreachable_pub
-        // `pub` struct fields, too
-        pub neutrons: usize, //~ WARNING unreachable_pub
-        // (... but not more-restricted fields)
+        // but not on fields, even if they are `pub` as putting `pub(crate)`
+        // it would clutter the source code for little value
+        pub neutrons: usize,
         pub(crate) electrons: usize
     }
+    pub(crate) struct Calcium {
+        pub neutrons: usize,
+    }
     impl Hydrogen {
         // impls, too
         pub fn count_neutrons(&self) -> usize { self.neutrons } //~ WARNING unreachable_pub
diff --git a/tests/ui/lint/unreachable_pub.stderr b/tests/ui/lint/unreachable_pub.stderr
index 762834b97b9..705a537a3f1 100644
--- a/tests/ui/lint/unreachable_pub.stderr
+++ b/tests/ui/lint/unreachable_pub.stderr
@@ -24,7 +24,7 @@ LL |     pub use std::env::{Args}; // braced-use has different item spans than u
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:12:5
+  --> $DIR/unreachable_pub.rs:13:5
    |
 LL |     pub struct Hydrogen {
    |     ---^^^^^^^^^^^^^^^^
@@ -33,16 +33,8 @@ LL |     pub struct Hydrogen {
    |
    = help: or consider exporting it for use by other crates
 
-warning: unreachable `pub` field
-  --> $DIR/unreachable_pub.rs:14:9
-   |
-LL |         pub neutrons: usize,
-   |         ---^^^^^^^^^^^^^^^^
-   |         |
-   |         help: consider restricting its visibility: `pub(crate)`
-
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:20:9
+  --> $DIR/unreachable_pub.rs:24:9
    |
 LL |         pub fn count_neutrons(&self) -> usize { self.neutrons }
    |         ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -50,7 +42,7 @@ LL |         pub fn count_neutrons(&self) -> usize { self.neutrons }
    |         help: consider restricting its visibility: `pub(crate)`
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:29:5
+  --> $DIR/unreachable_pub.rs:33:5
    |
 LL |     pub enum Helium {}
    |     ---^^^^^^^^^^^^
@@ -60,7 +52,7 @@ LL |     pub enum Helium {}
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:30:5
+  --> $DIR/unreachable_pub.rs:34:5
    |
 LL |     pub union Lithium { c1: usize, c2: u8 }
    |     ---^^^^^^^^^^^^^^
@@ -70,7 +62,7 @@ LL |     pub union Lithium { c1: usize, c2: u8 }
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:31:5
+  --> $DIR/unreachable_pub.rs:35:5
    |
 LL |     pub fn beryllium() {}
    |     ---^^^^^^^^^^^^^^^
@@ -80,7 +72,7 @@ LL |     pub fn beryllium() {}
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:32:5
+  --> $DIR/unreachable_pub.rs:36:5
    |
 LL |     pub trait Boron {}
    |     ---^^^^^^^^^^^^
@@ -90,7 +82,7 @@ LL |     pub trait Boron {}
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:33:5
+  --> $DIR/unreachable_pub.rs:37:5
    |
 LL |     pub const CARBON: usize = 1;
    |     ---^^^^^^^^^^^^^^^^^^^^
@@ -100,7 +92,7 @@ LL |     pub const CARBON: usize = 1;
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:34:5
+  --> $DIR/unreachable_pub.rs:38:5
    |
 LL |     pub static NITROGEN: usize = 2;
    |     ---^^^^^^^^^^^^^^^^^^^^^^^
@@ -110,7 +102,7 @@ LL |     pub static NITROGEN: usize = 2;
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:35:5
+  --> $DIR/unreachable_pub.rs:39:5
    |
 LL |     pub type Oxygen = bool;
    |     ---^^^^^^^^^^^^
@@ -120,7 +112,7 @@ LL |     pub type Oxygen = bool;
    = help: or consider exporting it for use by other crates
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:38:47
+  --> $DIR/unreachable_pub.rs:42:47
    |
 LL |         ($visibility: vis, $name: ident) => { $visibility struct $name {} }
    |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -135,7 +127,7 @@ LL |     define_empty_struct_with_visibility!(pub, Fluorine);
    = note: this warning originates in the macro `define_empty_struct_with_visibility` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: unreachable `pub` item
-  --> $DIR/unreachable_pub.rs:44:9
+  --> $DIR/unreachable_pub.rs:48:9
    |
 LL |         pub fn catalyze() -> bool;
    |         ---^^^^^^^^^^^^^^^^^^^^^^
@@ -144,5 +136,5 @@ LL |         pub fn catalyze() -> bool;
    |
    = help: or consider exporting it for use by other crates
 
-warning: 14 warnings emitted
+warning: 13 warnings emitted
 
diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs b/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
index 0f9eac93930..ba32fb566e8 100644
--- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
+++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
@@ -20,10 +20,10 @@ fn doc_comment_between_if_else(num: u8) -> bool {
 }
 
 fn doc_comment_on_expr(num: u8) -> bool {
-    (/// useless doc comment
+    /// useless doc comment
     //~^ ERROR: attributes on expressions are experimental
     //~| ERROR: unused doc comment
-    num) == 3
+    num == 3
 }
 
 fn doc_comment_on_expr_field() -> bool {
diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr
index 1ff5c8d8825..c0741174554 100644
--- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr
+++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr
@@ -5,10 +5,10 @@ LL |     else {
    |     ^^^^ expected expression
 
 error[E0658]: attributes on expressions are experimental
-  --> $DIR/unused-doc-comments-edge-cases.rs:23:6
+  --> $DIR/unused-doc-comments-edge-cases.rs:23:5
    |
-LL |     (/// useless doc comment
-   |      ^^^^^^^^^^^^^^^^^^^^^^^
+LL |     /// useless doc comment
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
    = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
@@ -32,12 +32,12 @@ LL | #![deny(unused_doc_comments)]
    |         ^^^^^^^^^^^^^^^^^^^
 
 error: unused doc comment
-  --> $DIR/unused-doc-comments-edge-cases.rs:23:6
+  --> $DIR/unused-doc-comments-edge-cases.rs:23:5
    |
-LL |     (/// useless doc comment
-   |      ^^^^^^^^^^^^^^^^^^^^^^^
+LL |     /// useless doc comment
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
 ...
-LL |     num) == 3
+LL |     num == 3
    |     --- rustdoc does not generate documentation for expressions
    |
    = help: use `//` for a plain comment
diff --git a/tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed b/tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed
deleted file mode 100644
index aae71ede771..00000000000
--- a/tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed
+++ /dev/null
@@ -1,15 +0,0 @@
-//@ run-rustfix
-#![feature(stmt_expr_attributes)]
-#![allow(unused_assignments, unused_attributes)]
-
-fn main() {
-    let mut x = (#[deprecated] 1) + 2; //~ ERROR ambiguous
-
-    (#[deprecated] x) = 4; //~ ERROR ambiguous
-
-    x = (#[deprecated] 5) as i32; //~ ERROR ambiguous
-
-    let _r = (#[deprecated] 1)..6; //~ ERROR ambiguous
-
-    println!("{}", x);
-}
diff --git a/tests/ui/parser/attribute/attr-binary-expr-ambigous.rs b/tests/ui/parser/attribute/attr-binary-expr-ambigous.rs
deleted file mode 100644
index 613e01d743b..00000000000
--- a/tests/ui/parser/attribute/attr-binary-expr-ambigous.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-//@ run-rustfix
-#![feature(stmt_expr_attributes)]
-#![allow(unused_assignments, unused_attributes)]
-
-fn main() {
-    let mut x = #[deprecated] 1 + 2; //~ ERROR ambiguous
-
-    #[deprecated] x = 4; //~ ERROR ambiguous
-
-    x = #[deprecated] 5 as i32; //~ ERROR ambiguous
-
-    let _r = #[deprecated] 1..6; //~ ERROR ambiguous
-
-    println!("{}", x);
-}
diff --git a/tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr b/tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr
deleted file mode 100644
index 0430570fd49..00000000000
--- a/tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr
+++ /dev/null
@@ -1,46 +0,0 @@
-error: ambiguous outer attributes
-  --> $DIR/attr-binary-expr-ambigous.rs:6:17
-   |
-LL |     let mut x = #[deprecated] 1 + 2;
-   |                 ^^^^^^^^^^^^^^^^^^^
-   |
-help: wrap the expression in parentheses
-   |
-LL |     let mut x = (#[deprecated] 1) + 2;
-   |                 +               +
-
-error: ambiguous outer attributes
-  --> $DIR/attr-binary-expr-ambigous.rs:8:5
-   |
-LL |     #[deprecated] x = 4;
-   |     ^^^^^^^^^^^^^^^^^^^
-   |
-help: wrap the expression in parentheses
-   |
-LL |     (#[deprecated] x) = 4;
-   |     +               +
-
-error: ambiguous outer attributes
-  --> $DIR/attr-binary-expr-ambigous.rs:10:9
-   |
-LL |     x = #[deprecated] 5 as i32;
-   |         ^^^^^^^^^^^^^^^^^^^^^^
-   |
-help: wrap the expression in parentheses
-   |
-LL |     x = (#[deprecated] 5) as i32;
-   |         +               +
-
-error: ambiguous outer attributes
-  --> $DIR/attr-binary-expr-ambigous.rs:12:14
-   |
-LL |     let _r = #[deprecated] 1..6;
-   |              ^^^^^^^^^^^^^^^^^^
-   |
-help: wrap the expression in parentheses
-   |
-LL |     let _r = (#[deprecated] 1)..6;
-   |              +               +
-
-error: aborting due to 4 previous errors
-
diff --git a/tests/ui/proc-macro/issue-81555.rs b/tests/ui/proc-macro/issue-81555.rs
index b337ab7ce37..7a61a31952f 100644
--- a/tests/ui/proc-macro/issue-81555.rs
+++ b/tests/ui/proc-macro/issue-81555.rs
@@ -10,5 +10,6 @@ use test_macros::identity_attr;
 fn main() {
     let _x;
     let y = ();
-    (#[identity_attr] _x) = y;
+    #[identity_attr]
+    _x = y;
 }