Skip to content

Commit bc1571c

Browse files
committed
Auto merge of #67903 - Dylan-DPC:rollup-k9djyrf, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #67818 (rustdoc: Avoid panic when parsing codeblocks for playground links) - #67845 (Also remove const-hack for abs) - #67879 (Remove negative number check from float sqrt) - #67881 (Add backticks to various diagnostics) - #67882 (remove bespoke flock bindings) Failed merges: r? @ghost
2 parents b69f6e6 + b9160fb commit bc1571c

File tree

70 files changed

+228
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+228
-299
lines changed

src/libcore/num/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,9 @@ $EndFeature, "
20012001
#[inline]
20022002
#[rustc_inherit_overflow_checks]
20032003
pub const fn abs(self) -> Self {
2004+
// Note that the #[inline] above means that the overflow
2005+
// semantics of the subtraction depend on the crate we're being
2006+
// inlined into.
20042007
if self.is_negative() {
20052008
-self
20062009
} else {

src/librustc/infer/error_reporting/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
661661
},
662662
ObligationCauseCode::IfExpression(box IfExpressionCause { then, outer, semicolon }) => {
663663
err.span_label(then, "expected because of this");
664-
outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
664+
outer.map(|sp| err.span_label(sp, "`if` and `else` have incompatible types"));
665665
if let Some(sp) = semicolon {
666666
err.span_suggestion_short(
667667
sp,
@@ -1883,13 +1883,13 @@ impl<'tcx> ObligationCause<'tcx> {
18831883
hir::MatchSource::TryDesugar => {
18841884
"try expression alternatives have incompatible types"
18851885
}
1886-
_ => "match arms have incompatible types",
1886+
_ => "`match` arms have incompatible types",
18871887
})
18881888
}
1889-
IfExpression { .. } => Error0308("if and else have incompatible types"),
1890-
IfExpressionWithNoElse => Error0317("if may be missing an else clause"),
1891-
MainFunctionType => Error0580("main function has wrong type"),
1892-
StartFunctionType => Error0308("start function has wrong type"),
1889+
IfExpression { .. } => Error0308("`if` and `else` have incompatible types"),
1890+
IfExpressionWithNoElse => Error0317("`if` may be missing an `else` clause"),
1891+
MainFunctionType => Error0580("`main` function has wrong type"),
1892+
StartFunctionType => Error0308("`#[start]` function has wrong type"),
18931893
IntrinsicType => Error0308("intrinsic has wrong type"),
18941894
MethodReceiver => Error0308("mismatched `self` parameter type"),
18951895

@@ -1917,12 +1917,12 @@ impl<'tcx> ObligationCause<'tcx> {
19171917
ExprAssignable => "expression is assignable",
19181918
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
19191919
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
1920-
_ => "match arms have compatible types",
1920+
_ => "`match` arms have compatible types",
19211921
},
1922-
IfExpression { .. } => "if and else have incompatible types",
1923-
IfExpressionWithNoElse => "if missing an else returns ()",
1922+
IfExpression { .. } => "`if` and `else` have incompatible types",
1923+
IfExpressionWithNoElse => "`if` missing an `else` returns `()`",
19241924
MainFunctionType => "`main` function has the correct type",
1925-
StartFunctionType => "`start` function has the correct type",
1925+
StartFunctionType => "`#[start]` function has the correct type",
19261926
IntrinsicType => "intrinsic has the correct type",
19271927
MethodReceiver => "method receiver has the correct type",
19281928
_ => "types are compatible",

src/librustc_data_structures/flock.rs

+15-106
Original file line numberDiff line numberDiff line change
@@ -13,96 +13,9 @@ use std::path::Path;
1313
cfg_if! {
1414
if #[cfg(unix)] {
1515
use std::ffi::{CString, OsStr};
16+
use std::mem;
1617
use std::os::unix::prelude::*;
1718

18-
#[cfg(any(target_os = "linux", target_os = "android"))]
19-
mod os {
20-
#[repr(C)]
21-
pub struct flock {
22-
pub l_type: libc::c_short,
23-
pub l_whence: libc::c_short,
24-
pub l_start: libc::off_t,
25-
pub l_len: libc::off_t,
26-
pub l_pid: libc::pid_t,
27-
28-
// not actually here, but brings in line with freebsd
29-
pub l_sysid: libc::c_int,
30-
}
31-
}
32-
33-
#[cfg(target_os = "freebsd")]
34-
mod os {
35-
#[repr(C)]
36-
pub struct flock {
37-
pub l_start: libc::off_t,
38-
pub l_len: libc::off_t,
39-
pub l_pid: libc::pid_t,
40-
pub l_type: libc::c_short,
41-
pub l_whence: libc::c_short,
42-
pub l_sysid: libc::c_int,
43-
}
44-
}
45-
46-
#[cfg(any(target_os = "dragonfly",
47-
target_os = "netbsd",
48-
target_os = "openbsd"))]
49-
mod os {
50-
#[repr(C)]
51-
pub struct flock {
52-
pub l_start: libc::off_t,
53-
pub l_len: libc::off_t,
54-
pub l_pid: libc::pid_t,
55-
pub l_type: libc::c_short,
56-
pub l_whence: libc::c_short,
57-
58-
// not actually here, but brings in line with freebsd
59-
pub l_sysid: libc::c_int,
60-
}
61-
}
62-
63-
#[cfg(target_os = "haiku")]
64-
mod os {
65-
#[repr(C)]
66-
pub struct flock {
67-
pub l_type: libc::c_short,
68-
pub l_whence: libc::c_short,
69-
pub l_start: libc::off_t,
70-
pub l_len: libc::off_t,
71-
pub l_pid: libc::pid_t,
72-
73-
// not actually here, but brings in line with freebsd
74-
pub l_sysid: libc::c_int,
75-
}
76-
}
77-
78-
#[cfg(any(target_os = "macos", target_os = "ios"))]
79-
mod os {
80-
#[repr(C)]
81-
pub struct flock {
82-
pub l_start: libc::off_t,
83-
pub l_len: libc::off_t,
84-
pub l_pid: libc::pid_t,
85-
pub l_type: libc::c_short,
86-
pub l_whence: libc::c_short,
87-
88-
// not actually here, but brings in line with freebsd
89-
pub l_sysid: libc::c_int,
90-
}
91-
}
92-
93-
#[cfg(target_os = "solaris")]
94-
mod os {
95-
#[repr(C)]
96-
pub struct flock {
97-
pub l_type: libc::c_short,
98-
pub l_whence: libc::c_short,
99-
pub l_start: libc::off_t,
100-
pub l_len: libc::off_t,
101-
pub l_sysid: libc::c_int,
102-
pub l_pid: libc::pid_t,
103-
}
104-
}
105-
10619
#[derive(Debug)]
10720
pub struct Lock {
10821
fd: libc::c_int,
@@ -132,19 +45,17 @@ cfg_if! {
13245
}
13346

13447
let lock_type = if exclusive {
135-
libc::F_WRLCK as libc::c_short
48+
libc::F_WRLCK
13649
} else {
137-
libc::F_RDLCK as libc::c_short
50+
libc::F_RDLCK
13851
};
13952

140-
let flock = os::flock {
141-
l_start: 0,
142-
l_len: 0,
143-
l_pid: 0,
144-
l_whence: libc::SEEK_SET as libc::c_short,
145-
l_type: lock_type,
146-
l_sysid: 0,
147-
};
53+
let mut flock: libc::flock = unsafe { mem::zeroed() };
54+
flock.l_type = lock_type as libc::c_short;
55+
flock.l_whence = libc::SEEK_SET as libc::c_short;
56+
flock.l_start = 0;
57+
flock.l_len = 0;
58+
14859
let cmd = if wait { libc::F_SETLKW } else { libc::F_SETLK };
14960
let ret = unsafe {
15061
libc::fcntl(fd, cmd, &flock)
@@ -161,14 +72,12 @@ cfg_if! {
16172

16273
impl Drop for Lock {
16374
fn drop(&mut self) {
164-
let flock = os::flock {
165-
l_start: 0,
166-
l_len: 0,
167-
l_pid: 0,
168-
l_whence: libc::SEEK_SET as libc::c_short,
169-
l_type: libc::F_UNLCK as libc::c_short,
170-
l_sysid: 0,
171-
};
75+
let mut flock: libc::flock = unsafe { mem::zeroed() };
76+
flock.l_type = libc::F_UNLCK as libc::c_short;
77+
flock.l_whence = libc::SEEK_SET as libc::c_short;
78+
flock.l_start = 0;
79+
flock.l_len = 0;
80+
17281
unsafe {
17382
libc::fcntl(self.fd, libc::F_SETLK, &flock);
17483
libc::close(self.fd);

src/librustc_passes/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
134134
ctxt.start_fn = Some((item.hir_id, item.span));
135135
} else {
136136
struct_span_err!(ctxt.session, item.span, E0138, "multiple `start` functions")
137-
.span_label(ctxt.start_fn.unwrap().1, "previous `start` function here")
137+
.span_label(ctxt.start_fn.unwrap().1, "previous `#[start]` function here")
138138
.span_label(item.span, "multiple `start` functions")
139139
.emit();
140140
}

src/librustc_target/spec/wasm32_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn options() -> TargetOptions {
8181
dynamic_linking: true,
8282
only_cdylib: true,
8383

84-
// This means we'll just embed a `start` function in the wasm module
84+
// This means we'll just embed a `#[start]` function in the wasm module
8585
executables: true,
8686

8787
// relatively self-explanatory!

src/librustc_typeck/check/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
298298
// LL || 10u32
299299
// || ^^^^^ expected `i32`, found `u32`
300300
// LL || };
301-
// ||_____- if and else have incompatible types
301+
// ||_____- `if` and `else` have incompatible types
302302
// ```
303303
Some(span)
304304
} else {
@@ -340,7 +340,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
340340
// by not pointing at the entire expression:
341341
// ```
342342
// 2 | let x = if true {
343-
// | ------- if and else have incompatible types
343+
// | ------- `if` and `else` have incompatible types
344344
// 3 | 3
345345
// | - expected because of this
346346
// 4 | } else {

0 commit comments

Comments
 (0)