about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-05-15 17:37:18 +0000
committerbors <bors@rust-lang.org>2021-05-15 17:37:18 +0000
commit50f2bf6a5751751ea27a8fd5577d5bdd37236669 (patch)
treeb9e3ee4bc29f401da340848433af5f4d0765385b /src
parenteac3c7c5bd38ec38062ebde475bd2ea6317d0c09 (diff)
parent8ea8252ca5e64626e11afed535d6c4bfd83fe218 (diff)
downloadrust-50f2bf6a5751751ea27a8fd5577d5bdd37236669.tar.gz
rust-50f2bf6a5751751ea27a8fd5577d5bdd37236669.zip
Auto merge of #85335 - GuillaumeGomez:rollup-0tvc14g, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #84751 (str::is_char_boundary - slight optimization)
 - #85185 (Generate not more docs than necessary)
 - #85324 (Warn about unused `pub` fields in non-`pub` structs)
 - #85329 (fix version_str comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/doc.rs31
-rw-r--r--src/ci/docker/host-x86_64/mingw-check/Dockerfile2
-rw-r--r--src/test/ui/cast/issue-84213.fixed1
-rw-r--r--src/test/ui/cast/issue-84213.rs1
-rw-r--r--src/test/ui/cast/issue-84213.stderr4
-rw-r--r--src/test/ui/lint/dead-code/issue-85255.rs22
-rw-r--r--src/test/ui/lint/dead-code/issue-85255.stderr32
7 files changed, 81 insertions, 12 deletions
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index 326a6fdaa80..f9972ac7b9d 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -451,6 +451,22 @@ impl Step for Std {
 
             builder.run(&mut cargo.into());
         };
+
+        let paths = builder
+            .paths
+            .iter()
+            .map(components_simplified)
+            .filter_map(|path| {
+                if path.get(0) == Some(&"library") {
+                    Some(path[1].to_owned())
+                } else if !path.is_empty() {
+                    Some(path[0].to_owned())
+                } else {
+                    None
+                }
+            })
+            .collect::<Vec<_>>();
+
         // Only build the following crates. While we could just iterate over the
         // folder structure, that would also build internal crates that we do
         // not want to show in documentation. These crates will later be visited
@@ -464,20 +480,17 @@ impl Step for Std {
         let krates = ["core", "alloc", "std", "proc_macro", "test"];
         for krate in &krates {
             run_cargo_rustdoc_for(krate);
+            if paths.iter().any(|p| p == krate) {
+                // No need to document more of the libraries if we have the one we want.
+                break;
+            }
         }
         builder.cp_r(&out_dir, &out);
 
         // Look for library/std, library/core etc in the `x.py doc` arguments and
         // open the corresponding rendered docs.
-        for path in builder.paths.iter().map(components_simplified) {
-            let requested_crate = if path.get(0) == Some(&"library") {
-                &path[1]
-            } else if !path.is_empty() {
-                &path[0]
-            } else {
-                continue;
-            };
-            if krates.contains(&requested_crate) {
+        for requested_crate in paths {
+            if krates.iter().any(|k| *k == requested_crate.as_str()) {
                 let index = out.join(requested_crate).join("index.html");
                 open(builder, &index);
             }
diff --git a/src/ci/docker/host-x86_64/mingw-check/Dockerfile b/src/ci/docker/host-x86_64/mingw-check/Dockerfile
index a9398649cf0..fd6dc563a0e 100644
--- a/src/ci/docker/host-x86_64/mingw-check/Dockerfile
+++ b/src/ci/docker/host-x86_64/mingw-check/Dockerfile
@@ -34,7 +34,7 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
            python3 ../x.py build --stage 0 src/tools/build-manifest && \
            python3 ../x.py test --stage 0 src/tools/compiletest && \
            python3 ../x.py test --stage 2 src/tools/tidy && \
-           python3 ../x.py doc --stage 0 library/std && \
+           python3 ../x.py doc --stage 0 library/test && \
            /scripts/validate-toolstate.sh && \
            # Runs checks to ensure that there are no ES5 issues in our JS code.
            es-check es5 ../src/librustdoc/html/static/*.js
diff --git a/src/test/ui/cast/issue-84213.fixed b/src/test/ui/cast/issue-84213.fixed
index e1a60557a20..b5c4a775296 100644
--- a/src/test/ui/cast/issue-84213.fixed
+++ b/src/test/ui/cast/issue-84213.fixed
@@ -6,6 +6,7 @@ struct Something {
 
 fn main() {
     let mut something = Something { field: 1337 };
+    let _ = something.field;
 
     let _pointer_to_something = &something as *const Something;
     //~^ ERROR: non-primitive cast
diff --git a/src/test/ui/cast/issue-84213.rs b/src/test/ui/cast/issue-84213.rs
index 3df264bdffb..6eb81291abc 100644
--- a/src/test/ui/cast/issue-84213.rs
+++ b/src/test/ui/cast/issue-84213.rs
@@ -6,6 +6,7 @@ struct Something {
 
 fn main() {
     let mut something = Something { field: 1337 };
+    let _ = something.field;
 
     let _pointer_to_something = something as *const Something;
     //~^ ERROR: non-primitive cast
diff --git a/src/test/ui/cast/issue-84213.stderr b/src/test/ui/cast/issue-84213.stderr
index a76aac58013..1b71d4db511 100644
--- a/src/test/ui/cast/issue-84213.stderr
+++ b/src/test/ui/cast/issue-84213.stderr
@@ -1,5 +1,5 @@
 error[E0605]: non-primitive cast: `Something` as `*const Something`
-  --> $DIR/issue-84213.rs:10:33
+  --> $DIR/issue-84213.rs:11:33
    |
 LL |     let _pointer_to_something = something as *const Something;
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast
@@ -10,7 +10,7 @@ LL |     let _pointer_to_something = &something as *const Something;
    |                                 ^
 
 error[E0605]: non-primitive cast: `Something` as `*mut Something`
-  --> $DIR/issue-84213.rs:13:37
+  --> $DIR/issue-84213.rs:14:37
    |
 LL |     let _mut_pointer_to_something = something as *mut Something;
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast
diff --git a/src/test/ui/lint/dead-code/issue-85255.rs b/src/test/ui/lint/dead-code/issue-85255.rs
new file mode 100644
index 00000000000..9a4d9fbad35
--- /dev/null
+++ b/src/test/ui/lint/dead-code/issue-85255.rs
@@ -0,0 +1,22 @@
+// Unused `pub` fields in non-`pub` structs should also trigger dead code warnings.
+// check-pass
+
+#![warn(dead_code)]
+
+struct Foo {
+    a: i32, //~ WARNING: field is never read
+    pub b: i32, //~ WARNING: field is never read
+}
+
+struct Bar;
+
+impl Bar {
+    fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used
+    pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used
+}
+
+
+fn main() {
+    let _ = Foo { a: 1, b: 2 };
+    let _ = Bar;
+}
diff --git a/src/test/ui/lint/dead-code/issue-85255.stderr b/src/test/ui/lint/dead-code/issue-85255.stderr
new file mode 100644
index 00000000000..73646439295
--- /dev/null
+++ b/src/test/ui/lint/dead-code/issue-85255.stderr
@@ -0,0 +1,32 @@
+warning: field is never read: `a`
+  --> $DIR/issue-85255.rs:7:5
+   |
+LL |     a: i32,
+   |     ^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-85255.rs:4:9
+   |
+LL | #![warn(dead_code)]
+   |         ^^^^^^^^^
+
+warning: field is never read: `b`
+  --> $DIR/issue-85255.rs:8:5
+   |
+LL |     pub b: i32,
+   |     ^^^^^^^^^^
+
+warning: associated function is never used: `a`
+  --> $DIR/issue-85255.rs:14:8
+   |
+LL |     fn a(&self) -> i32 { 5 }
+   |        ^
+
+warning: associated function is never used: `b`
+  --> $DIR/issue-85255.rs:15:12
+   |
+LL |     pub fn b(&self) -> i32 { 6 }
+   |            ^
+
+warning: 4 warnings emitted
+