Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #74106

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8dc1e42
libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]
ryr3 Jul 2, 2020
ec31b4e
Audit uses of `span_suggestion_short`
JohnTitor Jul 2, 2020
84282fd
Audit uses of `tool_only_span_suggestion`
JohnTitor Jul 2, 2020
1b747a0
mir: mark mir construction temporaries as internal
davidtwco Jul 2, 2020
7391bf8
Move A|Rc::as_ptr from feature(weak_into_raw)
CAD97 Jul 2, 2020
2f31426
rustdoc: Restore underline text decoration on hover for FQN in header
rye Jul 5, 2020
5fa19ad
Remove unused RUSTC_DEBUG_ASSERTIONS
tmiasko Jul 6, 2020
7d7f167
libstd: remove some mutable statics in sys::unix
euclio Jul 3, 2020
f226e6b
Add `read_exact_at` and `write_all_at` to WASI's `FileExt`
sunfishcode Jul 3, 2020
6196eaa
Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.
sunfishcode Jul 3, 2020
e46c187
Always resolve type@primitive as a primitive, not a module
jyn514 Jul 6, 2020
fdd39a3
Add rust-analyzer to the build manifest
matklad Jul 6, 2020
c6e7035
Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebank
Manishearth Jul 6, 2020
6f52496
Rollup merge of #73962 - ryr3:unsafe_tcp, r=LukasKalbertodt
Manishearth Jul 6, 2020
371d3c4
Rollup merge of #73969 - davidtwco:issue-73914-checkedadd-temp-genera…
Manishearth Jul 6, 2020
711476b
Rollup merge of #73974 - CAD97:rc-no-weak, r=dtolnay
Manishearth Jul 6, 2020
678949b
Rollup merge of #74006 - euclio:sys-unix-static-mut, r=SimonSapin
Manishearth Jul 6, 2020
01c688a
Rollup merge of #74067 - rye:rustdoc-fqn-hover-underline, r=Guillaume…
Manishearth Jul 6, 2020
5107383
Rollup merge of #74074 - sunfishcode:windows-openoptionsext-return-ty…
Manishearth Jul 6, 2020
6b5a05c
Rollup merge of #74076 - sunfishcode:wasi-fileext-newmethods, r=alexc…
Manishearth Jul 6, 2020
99eb1cb
Rollup merge of #74078 - jyn514:lut, r=Manishearth
Manishearth Jul 6, 2020
9b08c50
Rollup merge of #74089 - matklad:ship-rust-analyzer-some-more, r=piet…
Manishearth Jul 6, 2020
27fdf1c
Rollup merge of #74090 - tmiasko:rustc-debug-assertions, r=RalfJung
Manishearth Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@ impl Step for Miri {
cargo.env("MIRI", &miri);
// Debug things.
cargo.env("RUST_BACKTRACE", "1");
// Overwrite bootstrap's `rustc` wrapper overwriting our flags.
cargo.env("RUSTC_DEBUG_ASSERTIONS", "true");
// Let cargo-miri know where xargo ended up.
cargo.env("XARGO_CHECK", builder.out.join("bin").join("xargo-check"));

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ impl<T> Weak<T> {
/// ```
///
/// [`null`]: ../../std/ptr/fn.null.html
#[stable(feature = "weak_into_raw", since = "1.45.0")]
#[stable(feature = "rc_as_ptr", since = "1.45.0")]
pub fn as_ptr(&self) -> *const T {
let ptr: *mut RcBox<T> = NonNull::as_ptr(self.ptr);

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ impl<T: ?Sized> Arc<T> {
/// assert_eq!(x_ptr, Arc::as_ptr(&y));
/// assert_eq!(unsafe { &*x_ptr }, "hello");
/// ```
#[stable(feature = "weak_into_raw", since = "1.45.0")]
#[stable(feature = "rc_as_ptr", since = "1.45.0")]
pub fn as_ptr(this: &Self) -> *const T {
let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);

Expand Down
2 changes: 2 additions & 0 deletions src/librustc_builtin_macros/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ impl<'a, 'b> Context<'a, 'b> {
("x", "LowerHex"),
("X", "UpperHex"),
] {
// FIXME: rustfix (`run-rustfix`) fails to apply suggestions.
// > "Cannot replace slice of data that was already replaced"
err.tool_only_span_suggestion(
sp,
&format!("use the `{}` trait", name),
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir_build/build/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// N.B., **No cleanup is scheduled for this temporary.** You should
/// call `schedule_drop` once the temporary is initialized.
crate fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
let temp = self.local_decls.push(LocalDecl::new(ty, span));
// Mark this local as internal to avoid temporaries with types not present in the
// user's code resulting in ICEs from the generator transform.
let temp = self.local_decls.push(LocalDecl::new(ty, span).internal());
let place = Place::from(temp);
debug!("temp: created temp {:?} with type {:?}", place, self.local_decls[temp].ty);
place
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_parse/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,10 +1228,13 @@ impl<'a> Parser<'a> {
if let Some(sp) = unmatched.unclosed_span {
err.span_label(sp, "unclosed delimiter");
}
// Backticks should be removed to apply suggestions.
let mut delim = delim.to_string();
delim.retain(|c| c != '`');
err.span_suggestion_short(
self.prev_token.span.shrink_to_hi(),
&format!("{} may belong here", delim.to_string()),
delim.to_string(),
&format!("`{}` may belong here", delim),
delim,
Applicability::MaybeIncorrect,
);
if unmatched.found_delim.is_none() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ impl<'a> Parser<'a> {
// misses a separator.
expect_err
.span_suggestion_short(
sp,
self.sess.source_map().next_point(sp),
&format!("missing `{}`", token_str),
token_str,
Applicability::MaybeIncorrect,
Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ h1.fqn {
border-bottom: 1px dashed;
margin-top: 0;
}
h1.fqn > .in-band > a:hover {
text-decoration: underline;
}
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
border-bottom: 1px solid;
}
Expand Down
33 changes: 28 additions & 5 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
fn resolve(
&self,
path_str: &str,
disambiguator: Option<&str>,
ns: Namespace,
current_item: &Option<String>,
parent_id: Option<hir::HirId>,
Expand Down Expand Up @@ -203,11 +204,22 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
}
return Ok((res, Some(path_str.to_owned())));
}
other => {
debug!(
"failed to resolve {} in namespace {:?} (got {:?})",
path_str, ns, other
);
Res::Def(DefKind::Mod, _) => {
// This resolved to a module, but if we were passed `type@`,
// we want primitive types to take precedence instead.
if disambiguator == Some("type") {
if let Some(prim) = is_primitive(path_str, ns) {
if extra_fragment.is_some() {
return Err(ErrorKind::AnchorFailure(
"primitive types cannot be followed by anchors",
));
}
return Ok((prim, Some(path_str.to_owned())));
}
}
return Ok((res, extra_fragment.clone()));
}
_ => {
return Ok((res, extra_fragment.clone()));
}
};
Expand Down Expand Up @@ -566,11 +578,13 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
let mut path_str;
let (res, fragment) = {
let mut kind = None;
let mut disambiguator = None;
path_str = if let Some(prefix) = ["struct@", "enum@", "type@", "trait@", "union@"]
.iter()
.find(|p| link.starts_with(**p))
{
kind = Some(TypeNS);
disambiguator = Some(&prefix[..prefix.len() - 1]);
link.trim_start_matches(prefix)
} else if let Some(prefix) = [
"const@",
Expand All @@ -586,18 +600,23 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
.find(|p| link.starts_with(**p))
{
kind = Some(ValueNS);
disambiguator = Some(&prefix[..prefix.len() - 1]);
link.trim_start_matches(prefix)
} else if link.ends_with("()") {
kind = Some(ValueNS);
disambiguator = Some("fn");
link.trim_end_matches("()")
} else if link.starts_with("macro@") {
kind = Some(MacroNS);
disambiguator = Some("macro");
link.trim_start_matches("macro@")
} else if link.starts_with("derive@") {
kind = Some(MacroNS);
disambiguator = Some("derive");
link.trim_start_matches("derive@")
} else if link.ends_with('!') {
kind = Some(MacroNS);
disambiguator = Some("macro");
link.trim_end_matches('!')
} else {
&link[..]
Expand Down Expand Up @@ -634,6 +653,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
Some(ns @ ValueNS) => {
match self.resolve(
path_str,
disambiguator,
ns,
&current_item,
base_node,
Expand All @@ -657,6 +677,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
Some(ns @ TypeNS) => {
match self.resolve(
path_str,
disambiguator,
ns,
&current_item,
base_node,
Expand All @@ -683,6 +704,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
.map(|res| (res, extra_fragment.clone())),
type_ns: match self.resolve(
path_str,
disambiguator,
TypeNS,
&current_item,
base_node,
Expand All @@ -697,6 +719,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
},
value_ns: match self.resolve(
path_str,
disambiguator,
ValueNS,
&current_item,
base_node,
Expand Down
7 changes: 5 additions & 2 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(unsafe_op_in_unsafe_fn)]
use crate::io::prelude::*;

use crate::fmt;
Expand Down Expand Up @@ -583,7 +584,8 @@ impl Read for TcpStream {

#[inline]
unsafe fn initializer(&self) -> Initializer {
Initializer::nop()
// SAFETY: Read is guaranteed to work on uninitialized memory
unsafe { Initializer::nop() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -622,7 +624,8 @@ impl Read for &TcpStream {

#[inline]
unsafe fn initializer(&self) -> Initializer {
Initializer::nop()
// SAFETY: Read is guaranteed to work on uninitialized memory
unsafe { Initializer::nop() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
19 changes: 11 additions & 8 deletions src/libstd/sys/unix/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,20 @@ mod imp {
use crate::marker::PhantomData;
use crate::os::unix::prelude::*;
use crate::ptr;
use crate::sync::atomic::{AtomicIsize, AtomicPtr, Ordering};

use crate::sys_common::mutex::Mutex;

static mut ARGC: isize = 0;
static mut ARGV: *const *const u8 = ptr::null();
static ARGC: AtomicIsize = AtomicIsize::new(0);
static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut());
// We never call `ENV_LOCK.init()`, so it is UB to attempt to
// acquire this mutex reentrantly!
static LOCK: Mutex = Mutex::new();

unsafe fn really_init(argc: isize, argv: *const *const u8) {
let _guard = LOCK.lock();
ARGC = argc;
ARGV = argv;
ARGC.store(argc, Ordering::Relaxed);
ARGV.store(argv as *mut _, Ordering::Relaxed);
}

#[inline(always)]
Expand Down Expand Up @@ -126,8 +127,8 @@ mod imp {

pub unsafe fn cleanup() {
let _guard = LOCK.lock();
ARGC = 0;
ARGV = ptr::null();
ARGC.store(0, Ordering::Relaxed);
ARGV.store(ptr::null_mut(), Ordering::Relaxed);
}

pub fn args() -> Args {
Expand All @@ -137,9 +138,11 @@ mod imp {
fn clone() -> Vec<OsString> {
unsafe {
let _guard = LOCK.lock();
(0..ARGC)
let argc = ARGC.load(Ordering::Relaxed);
let argv = ARGV.load(Ordering::Relaxed);
(0..argc)
.map(|i| {
let cstr = CStr::from_ptr(*ARGV.offset(i) as *const libc::c_char);
let cstr = CStr::from_ptr(*argv.offset(i) as *const libc::c_char);
OsStringExt::from_vec(cstr.to_bytes().to_vec())
})
.collect()
Expand Down
13 changes: 7 additions & 6 deletions src/libstd/sys/unix/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mod imp {
use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
use libc::{MAP_ANON, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE, SIGSEGV};

use crate::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
use crate::sys::unix::os::page_size;
use crate::sys_common::thread_info;

Expand Down Expand Up @@ -113,8 +114,8 @@ mod imp {
}
}

static mut MAIN_ALTSTACK: *mut libc::c_void = ptr::null_mut();
static mut NEED_ALTSTACK: bool = false;
static MAIN_ALTSTACK: AtomicPtr<libc::c_void> = AtomicPtr::new(ptr::null_mut());
static NEED_ALTSTACK: AtomicBool = AtomicBool::new(false);

pub unsafe fn init() {
let mut action: sigaction = mem::zeroed();
Expand All @@ -125,17 +126,17 @@ mod imp {
action.sa_flags = SA_SIGINFO | SA_ONSTACK;
action.sa_sigaction = signal_handler as sighandler_t;
sigaction(signal, &action, ptr::null_mut());
NEED_ALTSTACK = true;
NEED_ALTSTACK.store(true, Ordering::Relaxed);
}
}

let handler = make_handler();
MAIN_ALTSTACK = handler._data;
MAIN_ALTSTACK.store(handler._data, Ordering::Relaxed);
mem::forget(handler);
}

pub unsafe fn cleanup() {
Handler { _data: MAIN_ALTSTACK };
Handler { _data: MAIN_ALTSTACK.load(Ordering::Relaxed) };
}

unsafe fn get_stackp() -> *mut libc::c_void {
Expand Down Expand Up @@ -176,7 +177,7 @@ mod imp {
}

pub unsafe fn make_handler() -> Handler {
if !NEED_ALTSTACK {
if !NEED_ALTSTACK.load(Ordering::Relaxed) {
return Handler::null();
}
let mut stack = mem::zeroed();
Expand Down
Loading