Skip to content

Commit

Permalink
Auto merge of #67903 - Dylan-DPC:rollup-k9djyrf, r=Dylan-DPC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jan 5, 2020
2 parents b69f6e6 + b9160fb commit bc1571c
Show file tree
Hide file tree
Showing 70 changed files with 228 additions and 299 deletions.
3 changes: 3 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,9 @@ $EndFeature, "
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn abs(self) -> Self {
// Note that the #[inline] above means that the overflow
// semantics of the subtraction depend on the crate we're being
// inlined into.
if self.is_negative() {
-self
} else {
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
},
ObligationCauseCode::IfExpression(box IfExpressionCause { then, outer, semicolon }) => {
err.span_label(then, "expected because of this");
outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
outer.map(|sp| err.span_label(sp, "`if` and `else` have incompatible types"));
if let Some(sp) = semicolon {
err.span_suggestion_short(
sp,
Expand Down Expand Up @@ -1883,13 +1883,13 @@ impl<'tcx> ObligationCause<'tcx> {
hir::MatchSource::TryDesugar => {
"try expression alternatives have incompatible types"
}
_ => "match arms have incompatible types",
_ => "`match` arms have incompatible types",
})
}
IfExpression { .. } => Error0308("if and else have incompatible types"),
IfExpressionWithNoElse => Error0317("if may be missing an else clause"),
MainFunctionType => Error0580("main function has wrong type"),
StartFunctionType => Error0308("start function has wrong type"),
IfExpression { .. } => Error0308("`if` and `else` have incompatible types"),
IfExpressionWithNoElse => Error0317("`if` may be missing an `else` clause"),
MainFunctionType => Error0580("`main` function has wrong type"),
StartFunctionType => Error0308("`#[start]` function has wrong type"),
IntrinsicType => Error0308("intrinsic has wrong type"),
MethodReceiver => Error0308("mismatched `self` parameter type"),

Expand Down Expand Up @@ -1917,12 +1917,12 @@ impl<'tcx> ObligationCause<'tcx> {
ExprAssignable => "expression is assignable",
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
_ => "match arms have compatible types",
_ => "`match` arms have compatible types",
},
IfExpression { .. } => "if and else have incompatible types",
IfExpressionWithNoElse => "if missing an else returns ()",
IfExpression { .. } => "`if` and `else` have incompatible types",
IfExpressionWithNoElse => "`if` missing an `else` returns `()`",
MainFunctionType => "`main` function has the correct type",
StartFunctionType => "`start` function has the correct type",
StartFunctionType => "`#[start]` function has the correct type",
IntrinsicType => "intrinsic has the correct type",
MethodReceiver => "method receiver has the correct type",
_ => "types are compatible",
Expand Down
121 changes: 15 additions & 106 deletions src/librustc_data_structures/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,96 +13,9 @@ use std::path::Path;
cfg_if! {
if #[cfg(unix)] {
use std::ffi::{CString, OsStr};
use std::mem;
use std::os::unix::prelude::*;

#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
#[repr(C)]
pub struct flock {
pub l_type: libc::c_short,
pub l_whence: libc::c_short,
pub l_start: libc::off_t,
pub l_len: libc::off_t,
pub l_pid: libc::pid_t,

// not actually here, but brings in line with freebsd
pub l_sysid: libc::c_int,
}
}

#[cfg(target_os = "freebsd")]
mod os {
#[repr(C)]
pub struct flock {
pub l_start: libc::off_t,
pub l_len: libc::off_t,
pub l_pid: libc::pid_t,
pub l_type: libc::c_short,
pub l_whence: libc::c_short,
pub l_sysid: libc::c_int,
}
}

#[cfg(any(target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"))]
mod os {
#[repr(C)]
pub struct flock {
pub l_start: libc::off_t,
pub l_len: libc::off_t,
pub l_pid: libc::pid_t,
pub l_type: libc::c_short,
pub l_whence: libc::c_short,

// not actually here, but brings in line with freebsd
pub l_sysid: libc::c_int,
}
}

#[cfg(target_os = "haiku")]
mod os {
#[repr(C)]
pub struct flock {
pub l_type: libc::c_short,
pub l_whence: libc::c_short,
pub l_start: libc::off_t,
pub l_len: libc::off_t,
pub l_pid: libc::pid_t,

// not actually here, but brings in line with freebsd
pub l_sysid: libc::c_int,
}
}

#[cfg(any(target_os = "macos", target_os = "ios"))]
mod os {
#[repr(C)]
pub struct flock {
pub l_start: libc::off_t,
pub l_len: libc::off_t,
pub l_pid: libc::pid_t,
pub l_type: libc::c_short,
pub l_whence: libc::c_short,

// not actually here, but brings in line with freebsd
pub l_sysid: libc::c_int,
}
}

#[cfg(target_os = "solaris")]
mod os {
#[repr(C)]
pub struct flock {
pub l_type: libc::c_short,
pub l_whence: libc::c_short,
pub l_start: libc::off_t,
pub l_len: libc::off_t,
pub l_sysid: libc::c_int,
pub l_pid: libc::pid_t,
}
}

#[derive(Debug)]
pub struct Lock {
fd: libc::c_int,
Expand Down Expand Up @@ -132,19 +45,17 @@ cfg_if! {
}

let lock_type = if exclusive {
libc::F_WRLCK as libc::c_short
libc::F_WRLCK
} else {
libc::F_RDLCK as libc::c_short
libc::F_RDLCK
};

let flock = os::flock {
l_start: 0,
l_len: 0,
l_pid: 0,
l_whence: libc::SEEK_SET as libc::c_short,
l_type: lock_type,
l_sysid: 0,
};
let mut flock: libc::flock = unsafe { mem::zeroed() };
flock.l_type = lock_type as libc::c_short;
flock.l_whence = libc::SEEK_SET as libc::c_short;
flock.l_start = 0;
flock.l_len = 0;

let cmd = if wait { libc::F_SETLKW } else { libc::F_SETLK };
let ret = unsafe {
libc::fcntl(fd, cmd, &flock)
Expand All @@ -161,14 +72,12 @@ cfg_if! {

impl Drop for Lock {
fn drop(&mut self) {
let flock = os::flock {
l_start: 0,
l_len: 0,
l_pid: 0,
l_whence: libc::SEEK_SET as libc::c_short,
l_type: libc::F_UNLCK as libc::c_short,
l_sysid: 0,
};
let mut flock: libc::flock = unsafe { mem::zeroed() };
flock.l_type = libc::F_UNLCK as libc::c_short;
flock.l_whence = libc::SEEK_SET as libc::c_short;
flock.l_start = 0;
flock.l_len = 0;

unsafe {
libc::fcntl(self.fd, libc::F_SETLK, &flock);
libc::close(self.fd);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
ctxt.start_fn = Some((item.hir_id, item.span));
} else {
struct_span_err!(ctxt.session, item.span, E0138, "multiple `start` functions")
.span_label(ctxt.start_fn.unwrap().1, "previous `start` function here")
.span_label(ctxt.start_fn.unwrap().1, "previous `#[start]` function here")
.span_label(item.span, "multiple `start` functions")
.emit();
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/spec/wasm32_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn options() -> TargetOptions {
dynamic_linking: true,
only_cdylib: true,

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

// relatively self-explanatory!
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// LL || 10u32
// || ^^^^^ expected `i32`, found `u32`
// LL || };
// ||_____- if and else have incompatible types
// ||_____- `if` and `else` have incompatible types
// ```
Some(span)
} else {
Expand Down Expand Up @@ -340,7 +340,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// by not pointing at the entire expression:
// ```
// 2 | let x = if true {
// | ------- if and else have incompatible types
// | ------- `if` and `else` have incompatible types
// 3 | 3
// | - expected because of this
// 4 | } else {
Expand Down
Loading

0 comments on commit bc1571c

Please sign in to comment.