Skip to content

Commit a7cef0b

Browse files
committed
Auto merge of #60007 - Centril:rollup-gdh1er4, r=Centril
Rollup of 6 pull requests Successful merges: - #59717 (improve docs for std::hint::unreachable_unchecked()) - #59903 (Continue evaluating after missing main) - #59973 (Fix rustdoc sidebar z-index) - #59992 (rustdoc: use --static-root-path for settings.js) - #59993 (include mode in unused binding suggestion span) - #60000 (Add repo-specific triagebot configuration) Failed merges: r? @ghost
2 parents 7cb933a + 67ff8cf commit a7cef0b

13 files changed

+191
-14
lines changed

src/libcore/hint.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ use intrinsics;
2121
/// difficult-to-debug problems.
2222
///
2323
/// Use this function only when you can prove that the code will never call it.
24+
/// Otherwise, consider using the [`unreachable!`] macro, which does not allow
25+
/// optimizations but will panic when executed.
2426
///
25-
/// The [`unreachable!()`] macro is the safe counterpart of this function, which
26-
/// will panic instead when executed.
27-
///
28-
/// [`unreachable!()`]: ../macro.unreachable.html
27+
/// [`unreachable!`]: ../macro.unreachable.html
2928
///
3029
/// # Example
3130
///

src/librustc/middle/entry.rs

-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ fn configure_main(
163163
err.span_note(span, "here is a function named 'main'");
164164
}
165165
err.emit();
166-
tcx.sess.abort_if_errors();
167166
} else {
168167
if let Some(ref filename) = tcx.sess.local_crate_source_file {
169168
err.note(&format!("consider adding a `main` function to `{}`", filename.display()));

src/librustc/middle/liveness.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -1626,11 +1626,18 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
16261626
);
16271627

16281628
if self.ir.variable_is_shorthand(var) {
1629-
err.multipart_suggestion(
1630-
"try ignoring the field",
1631-
spans.iter().map(|span| (*span, format!("{}: _", name))).collect(),
1632-
Applicability::MachineApplicable
1633-
);
1629+
if let Node::Binding(pat) = self.ir.tcx.hir().get_by_hir_id(hir_id) {
1630+
// Handle `ref` and `ref mut`.
1631+
let spans = spans.iter()
1632+
.map(|_span| (pat.span, format!("{}: _", name)))
1633+
.collect();
1634+
1635+
err.multipart_suggestion(
1636+
"try ignoring the field",
1637+
spans,
1638+
Applicability::MachineApplicable,
1639+
);
1640+
}
16341641
} else {
16351642
err.multipart_suggestion(
16361643
"consider prefixing with an underscore",

src/librustc_interface/passes.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,11 @@ fn analysis<'tcx>(
886886
assert_eq!(cnum, LOCAL_CRATE);
887887

888888
let sess = tcx.sess;
889+
let mut entry_point = None;
889890

890891
time(sess, "misc checking 1", || {
891892
parallel!({
892-
time(sess, "looking for entry point", || {
893+
entry_point = time(sess, "looking for entry point", || {
893894
middle::entry::find_entry_point(tcx)
894895
});
895896

@@ -937,7 +938,10 @@ fn analysis<'tcx>(
937938

938939
// Abort so we don't try to construct MIR with liveness errors.
939940
// We also won't want to continue with errors from rvalue promotion
940-
tcx.sess.abort_if_errors();
941+
// We only do so if the only error found so far *isn't* a missing `fn main()`
942+
if !(entry_point.is_none() && sess.err_count() == 1) {
943+
tcx.sess.abort_if_errors();
944+
}
941945

942946
time(sess, "borrow checking", || {
943947
if tcx.use_ast_borrowck() {

src/librustdoc/html/render.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,8 @@ impl Context {
21132113
&final_file);
21142114

21152115
// Generating settings page.
2116-
let settings = Settings::new("./", &self.shared.resource_suffix);
2116+
let settings = Settings::new(self.shared.static_root_path.deref().unwrap_or("./"),
2117+
&self.shared.resource_suffix);
21172118
page.title = "Rustdoc settings";
21182119
page.description = "Settings of Rustdoc";
21192120
page.root_path = "./";

src/librustdoc/html/static/rustdoc.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ nav.sub {
166166
top: 0;
167167
height: 100vh;
168168
overflow: auto;
169+
z-index: 1;
169170
}
170171

171172
.sidebar .block > ul > li {
@@ -345,7 +346,7 @@ nav.sub {
345346
margin: 0;
346347
}
347348
.docblock-short code {
348-
white-space: nowrap;
349+
white-space: pre-wrap;
349350
}
350351

351352
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {

src/test/rustdoc/static-root-path.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ pub struct SomeStruct;
1212
// @!matches - '"\.\./\.\./source-script\.js"'
1313
// @matches - '"\.\./\.\./source-files.js"'
1414
// @!matches - '"/cache/source-files\.js"'
15+
16+
// @has settings.html
17+
// @matches - '/cache/settings\.js'
18+
// @!matches - '\./settings\.js'
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![allow(dead_code)]
2+
3+
// error-pattern:`main` function not found in crate
4+
5+
struct Tableau<'a, MP> {
6+
provider: &'a MP,
7+
}
8+
9+
impl<'adapted_matrix_provider, 'original_data, MP>
10+
Tableau<'adapted_matrix_provider, AdaptedMatrixProvider<'original_data, MP>>
11+
{
12+
fn provider(&self) -> &'adapted_matrix_provider AdaptedMatrixProvider</*'original_data,*/ MP> {
13+
self.provider
14+
}
15+
}
16+
17+
struct AdaptedMatrixProvider<'a, T> {
18+
original_problem: &'a T,
19+
}
20+
21+
impl<'a, T> AdaptedMatrixProvider<'a, T> {
22+
fn clone_with_extra_bound(&self) -> Self {
23+
AdaptedMatrixProvider { original_problem: self.original_problem }
24+
}
25+
}
26+
27+
fn create_and_solve_subproblems<'data_provider, 'original_data, MP>(
28+
tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>,
29+
) {
30+
let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound();
31+
//~^ ERROR lifetime mismatch
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0601]: `main` function not found in crate `continue_after_missing_main`
2+
|
3+
= note: consider adding a `main` function to `$DIR/continue-after-missing-main.rs`
4+
5+
error[E0623]: lifetime mismatch
6+
--> $DIR/continue-after-missing-main.rs:30:56
7+
|
8+
LL | tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>,
9+
| ------------------------------------------------------------------ these two types are declared with different lifetimes...
10+
LL | ) {
11+
LL | let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound();
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...but data from `tableau` flows into `tableau` here
13+
14+
error: aborting due to 2 previous errors
15+
16+
Some errors occurred: E0601, E0623.
17+
For more information about an error, try `rustc --explain E0601`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// run-rustfix
2+
3+
#![deny(unused)]
4+
5+
pub struct S {
6+
pub f1: i32,
7+
}
8+
9+
pub struct Point {
10+
pub x: i32,
11+
pub y: i32,
12+
}
13+
14+
pub enum E {
15+
Variant { field: String }
16+
}
17+
18+
pub fn foo(arg: &E) {
19+
match arg {
20+
E::Variant { field: _ } => (), //~ ERROR unused variable
21+
}
22+
}
23+
24+
fn main() {
25+
let s = S { f1: 123 };
26+
let S { f1: _ } = s; //~ ERROR unused variable
27+
28+
let points = vec![Point { x: 1, y: 2 }];
29+
let _: i32 = points.iter().map(|Point { x: _, y }| y).sum(); //~ ERROR unused variable
30+
31+
match (Point { x: 1, y: 2 }) {
32+
Point { y, x: _ } => y, //~ ERROR unused variable
33+
};
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// run-rustfix
2+
3+
#![deny(unused)]
4+
5+
pub struct S {
6+
pub f1: i32,
7+
}
8+
9+
pub struct Point {
10+
pub x: i32,
11+
pub y: i32,
12+
}
13+
14+
pub enum E {
15+
Variant { field: String }
16+
}
17+
18+
pub fn foo(arg: &E) {
19+
match arg {
20+
E::Variant { ref field } => (), //~ ERROR unused variable
21+
}
22+
}
23+
24+
fn main() {
25+
let s = S { f1: 123 };
26+
let S { ref f1 } = s; //~ ERROR unused variable
27+
28+
let points = vec![Point { x: 1, y: 2 }];
29+
let _: i32 = points.iter().map(|Point { x, y }| y).sum(); //~ ERROR unused variable
30+
31+
match (Point { x: 1, y: 2 }) {
32+
Point { y, ref mut x } => y, //~ ERROR unused variable
33+
};
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error: unused variable: `field`
2+
--> $DIR/issue-54180-unused-ref-field.rs:20:26
3+
|
4+
LL | E::Variant { ref field } => (),
5+
| ----^^^^^
6+
| |
7+
| help: try ignoring the field: `field: _`
8+
|
9+
note: lint level defined here
10+
--> $DIR/issue-54180-unused-ref-field.rs:3:9
11+
|
12+
LL | #![deny(unused)]
13+
| ^^^^^^
14+
= note: #[deny(unused_variables)] implied by #[deny(unused)]
15+
16+
error: unused variable: `x`
17+
--> $DIR/issue-54180-unused-ref-field.rs:29:45
18+
|
19+
LL | let _: i32 = points.iter().map(|Point { x, y }| y).sum();
20+
| ^ help: try ignoring the field: `x: _`
21+
22+
error: unused variable: `f1`
23+
--> $DIR/issue-54180-unused-ref-field.rs:26:17
24+
|
25+
LL | let S { ref f1 } = s;
26+
| ----^^
27+
| |
28+
| help: try ignoring the field: `f1: _`
29+
30+
error: unused variable: `x`
31+
--> $DIR/issue-54180-unused-ref-field.rs:32:28
32+
|
33+
LL | Point { y, ref mut x } => y,
34+
| --------^
35+
| |
36+
| help: try ignoring the field: `x: _`
37+
38+
error: aborting due to 4 previous errors
39+

triagebot.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[relabel]
2+
allow-unauthenticated = [
3+
"C-*", "A-*", "E-*", "NLL-*", "O-*", "S-*", "T-*", "WG-*",
4+
# I-* without I-nominated
5+
"I-compilemem", "I-compiletime", "I-crash", "I-hang", "I-ICE", "I-slow",
6+
]

0 commit comments

Comments
 (0)