Skip to content

Rollup of 10 pull requests #52655

New issue

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

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

Already on GitHub? # to your account

Merged
merged 21 commits into from
Jul 24, 2018
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
53ae366
Remove obsolete flags in the i586_musl Dockerfile
ljedrz Jul 19, 2018
8b80c9f
Cursor: update docs to clarify Cursor only works with in-memory buffers
tko Jul 19, 2018
9369b52
Do not suggest using `to_owned()` on `&str += &str`
estebank Jul 22, 2018
bf2fc77
Fix color detection for Windows msys terminals.
ehuss Jul 22, 2018
59a435b
Use MultiSpan in E0707 and E709
Jul 22, 2018
814e6e6
Compile rustc before building tests for rustdoc
Mark-Simulacrum Jul 21, 2018
33b8f62
Don't use NonNull::dangling as sentinel value
RalfJung Jul 23, 2018
a303741
typos
RalfJung Jul 23, 2018
89495f3
Forget Waker when cloning LocalWaker
Thomasdezeeuw Jul 23, 2018
d89ac4c
Simplify 2 functions in rustc_mir/dataflow
ljedrz Jul 23, 2018
fe588d8
Replace a few expect+format combos with unwrap_or_else+panic
ljedrz Jul 23, 2018
cf995d6
Rollup merge of #52538 - ljedrz:old_musl_i586_flags, r=kennytm
kennytm Jul 24, 2018
a98c19e
Rollup merge of #52548 - tko:cursor-doc, r=sfackler
kennytm Jul 24, 2018
5b7e3a1
Rollup merge of #52605 - estebank:str-plus-eq, r=oli-obk
kennytm Jul 24, 2018
85bb13c
Rollup merge of #52621 - ehuss:atty-fix, r=alexcrichton
kennytm Jul 24, 2018
291a620
Rollup merge of #52622 - estebank:lifetime-multispan, r=nikomatsakis
kennytm Jul 24, 2018
4084f0e
Rollup merge of #52627 - Mark-Simulacrum:rustdoc-test-correct, r=alex…
kennytm Jul 24, 2018
3af372a
Rollup merge of #52637 - RalfJung:rc, r=joshtriplett
kennytm Jul 24, 2018
b3c9fe2
Rollup merge of #52640 - Thomasdezeeuw:fix-localwaker-clone, r=cramertj
kennytm Jul 24, 2018
378ef99
Rollup merge of #52641 - ljedrz:mir_dataflow_misc, r=cramertj
kennytm Jul 24, 2018
3efc612
Rollup merge of #52642 - ljedrz:expect_fun_call, r=Mark-Simulacrum
kennytm Jul 24, 2018
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
14 changes: 7 additions & 7 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ dependencies = [

[[package]]
name = "atty"
version = "0.2.10"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -187,7 +187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "cargo"
version = "0.30.0"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -303,7 +303,7 @@ version = "2.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -622,7 +622,7 @@ name = "env_logger"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1844,7 +1844,7 @@ name = "rustc-ap-rustc_errors"
version = "182.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-rustc_data_structures 182.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-serialize 182.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-syntax_pos 182.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2097,7 +2097,7 @@ dependencies = [
name = "rustc_errors"
version = "0.0.0"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_data_structures 0.0.0",
"serialize 0.0.0",
"syntax_pos 0.0.0",
@@ -3056,7 +3056,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
"checksum assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98589b0e465a6c510d95fceebd365bb79bedece7f6e18a480897f2015f85ec51"
"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
"checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
4 changes: 2 additions & 2 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
@@ -326,7 +326,7 @@ fn main() {
let start = Instant::now();
let status = cmd
.status()
.expect(&format!("\n\n failed to run {:?}", cmd));
.unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd));
let dur = start.elapsed();

let is_test = args.iter().any(|a| a == "--test");
@@ -346,7 +346,7 @@ fn main() {
}
}

let code = exec_cmd(&mut cmd).expect(&format!("\n\n failed to run {:?}", cmd));
let code = exec_cmd(&mut cmd).unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd));
std::process::exit(code);
}

2 changes: 1 addition & 1 deletion src/bootstrap/install.rs
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ fn install_sh(
let libdir_default = PathBuf::from("lib");
let mandir_default = datadir_default.join("man");
let prefix = builder.config.prefix.as_ref().map_or(prefix_default, |p| {
fs::canonicalize(p).expect(&format!("could not canonicalize {}", p.display()))
fs::canonicalize(p).unwrap_or_else(|_| panic!("could not canonicalize {}", p.display()))
});
let sysconfdir = builder.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
let datadir = builder.config.datadir.as_ref().unwrap_or(&datadir_default);
1 change: 1 addition & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
@@ -1732,6 +1732,7 @@ impl Step for CrateRustdoc {

let compiler = builder.compiler(builder.top_stage, self.host);
let target = compiler.host;
builder.ensure(compile::Rustc { compiler, target });

let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
4 changes: 1 addition & 3 deletions src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -42,9 +42,7 @@ ENV RUST_CONFIGURE_ARGS \
# See: https://github.com/rust-lang/rust/issues/34978
ENV CFLAGS_i686_unknown_linux_musl=-Wa,-mrelax-relocations=no
ENV CFLAGS_i586_unknown_linux_gnu=-Wa,-mrelax-relocations=no
# FIXME remove -Wl,-melf_i386 after cc is updated to include
# https://github.com/alexcrichton/cc-rs/pull/281
ENV CFLAGS_i586_unknown_linux_musl="-Wa,-mrelax-relocations=no -Wl,-melf_i386"
ENV CFLAGS_i586_unknown_linux_musl=-Wa,-mrelax-relocations=no

ENV TARGETS=i586-unknown-linux-gnu,i686-unknown-linux-musl

13 changes: 8 additions & 5 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
@@ -258,6 +258,7 @@ use core::ops::Deref;
use core::ops::CoerceUnsized;
use core::ptr::{self, NonNull};
use core::convert::From;
use core::usize;

use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
use string::String;
@@ -449,6 +450,8 @@ impl<T: ?Sized> Rc<T> {
#[stable(feature = "rc_weak", since = "1.4.0")]
pub fn downgrade(this: &Self) -> Weak<T> {
this.inc_weak();
// Make sure we do not create a dangling Weak
debug_assert!(!is_dangling(this.ptr));
Weak { ptr: this.ptr }
}

@@ -1154,8 +1157,9 @@ impl<T> From<Vec<T>> for Rc<[T]> {
pub struct Weak<T: ?Sized> {
// This is a `NonNull` to allow optimizing the size of this type in enums,
// but it is not necessarily a valid pointer.
// `Weak::new` sets this to a dangling pointer so that it doesn’t need
// to allocate space on the heap.
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
// to allocate space on the heap. That's not a value a real pointer
// will ever have because RcBox has alignment at least 2.
ptr: NonNull<RcBox<T>>,
}

@@ -1185,15 +1189,14 @@ impl<T> Weak<T> {
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak<T> {
Weak {
ptr: NonNull::dangling(),
ptr: NonNull::new(usize::MAX as *mut RcBox<T>).expect("MAX is not 0"),
}
}
}

pub(crate) fn is_dangling<T: ?Sized>(ptr: NonNull<T>) -> bool {
let address = ptr.as_ptr() as *mut () as usize;
let align = align_of_val(unsafe { ptr.as_ref() });
address == align
address == usize::MAX
}

impl<T: ?Sized> Weak<T> {
13 changes: 9 additions & 4 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
@@ -238,8 +238,9 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
pub struct Weak<T: ?Sized> {
// This is a `NonNull` to allow optimizing the size of this type in enums,
// but it is not necessarily a valid pointer.
// `Weak::new` sets this to a dangling pointer so that it doesn’t need
// to allocate space on the heap.
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
// to allocate space on the heap. That's not a value a real pointer
// will ever have because RcBox has alignment at least 2.
ptr: NonNull<ArcInner<T>>,
}

@@ -442,7 +443,11 @@ impl<T: ?Sized> Arc<T> {
// synchronize with the write coming from `is_unique`, so that the
// events prior to that write happen before this read.
match this.inner().weak.compare_exchange_weak(cur, cur + 1, Acquire, Relaxed) {
Ok(_) => return Weak { ptr: this.ptr },
Ok(_) => {
// Make sure we do not create a dangling Weak
debug_assert!(!is_dangling(this.ptr));
return Weak { ptr: this.ptr };
}
Err(old) => cur = old,
}
}
@@ -1033,7 +1038,7 @@ impl<T> Weak<T> {
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak<T> {
Weak {
ptr: NonNull::dangling(),
ptr: NonNull::new(usize::MAX as *mut ArcInner<T>).expect("MAX is not 0"),
}
}
}
9 changes: 5 additions & 4 deletions src/libcore/task/wake.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
reason = "futures in libcore are unstable",
issue = "50547")]

use fmt;
use {fmt, mem};
use marker::Unpin;
use ptr::NonNull;

@@ -166,9 +166,10 @@ impl From<LocalWaker> for Waker {
impl Clone for LocalWaker {
#[inline]
fn clone(&self) -> Self {
unsafe {
LocalWaker { inner: self.inner.as_ref().clone_raw().inner }
}
let waker = unsafe { self.inner.as_ref().clone_raw() };
let inner = waker.inner;
mem::forget(waker);
LocalWaker { inner }
}
}

6 changes: 3 additions & 3 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ use syntax::tokenstream::{Delimited, TokenStream, TokenTree};
use syntax::parse::token::Token;
use syntax::util::small_vector::SmallVector;
use syntax::visit::{self, Visitor};
use syntax_pos::Span;
use syntax_pos::{Span, MultiSpan};

const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;

@@ -2071,7 +2071,7 @@ impl<'a> LoweringContext<'a> {
if current_lt_name != name {
struct_span_err!(
self.context.sess,
current_lt_span.between(lifetime.span),
MultiSpan::from_spans(vec![current_lt_span, lifetime.span]),
E0709,
"multiple different lifetimes used in arguments of `async fn`",
)
@@ -2083,7 +2083,7 @@ impl<'a> LoweringContext<'a> {
} else if current_lt_name.is_elided() && name.is_elided() {
struct_span_err!(
self.context.sess,
current_lt_span.between(lifetime.span),
MultiSpan::from_spans(vec![current_lt_span, lifetime.span]),
E0707,
"multiple elided lifetimes used in arguments of `async fn`",
)
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/rpath.rs
Original file line number Diff line number Diff line change
@@ -114,8 +114,8 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String
let mut output = cwd.join(&config.out_filename);
output.pop();
let output = fs::canonicalize(&output).unwrap_or(output);
let relative = path_relative_from(&lib, &output)
.expect(&format!("couldn't create relative path from {:?} to {:?}", output, lib));
let relative = path_relative_from(&lib, &output).unwrap_or_else(||
panic!("couldn't create relative path from {:?} to {:?}", output, lib));
// FIXME (#9639): This needs to handle non-utf8 paths
format!("{}/{}", prefix,
relative.to_str().expect("non-utf8 component in path"))
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/base.rs
Original file line number Diff line number Diff line change
@@ -1277,7 +1277,7 @@ pub fn provide(providers: &mut Providers) {
all.iter()
.find(|cgu| *cgu.name() == name)
.cloned()
.expect(&format!("failed to find cgu with name {:?}", name))
.unwrap_or_else(|| panic!("failed to find cgu with name {:?}", name))
};
providers.compile_codegen_unit = compile_codegen_unit;

4 changes: 2 additions & 2 deletions src/librustc_mir/dataflow/graphviz.rs
Original file line number Diff line number Diff line change
@@ -73,8 +73,8 @@ pub type Node = BasicBlock;
pub struct Edge { source: BasicBlock, index: usize }

fn outgoing(mir: &Mir, bb: BasicBlock) -> Vec<Edge> {
mir[bb].terminator().successors().enumerate()
.map(|(index, _)| Edge { source: bb, index: index}).collect()
(0..mir[bb].terminator().successors().count())
.map(|index| Edge { source: bb, index: index}).collect()
}

impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P>
11 changes: 1 addition & 10 deletions src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
@@ -441,23 +441,14 @@ pub struct DataflowState<O: BitDenotation>
}

impl<O: BitDenotation> DataflowState<O> {
pub fn each_bit<F>(&self, words: &IdxSet<O::Idx>, f: F) where F: FnMut(O::Idx)
{
words.iter().for_each(f)
}

pub(crate) fn interpret_set<'c, P>(&self,
o: &'c O,
words: &IdxSet<O::Idx>,
render_idx: &P)
-> Vec<DebugFormatted>
where P: Fn(&O, O::Idx) -> DebugFormatted
{
let mut v = Vec::new();
self.each_bit(words, |i| {
v.push(render_idx(o, i));
});
v
words.iter().map(|i| render_idx(o, i)).collect()
}
}

67 changes: 36 additions & 31 deletions src/librustc_typeck/check/op.rs
Original file line number Diff line number Diff line change
@@ -307,9 +307,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let Some(missing_trait) = missing_trait {
if op.node == hir::BinOpKind::Add &&
self.check_str_addition(expr, lhs_expr, rhs_expr, lhs_ty,
rhs_ty, &mut err) {
rhs_ty, &mut err, true) {
// This has nothing here because it means we did string
// concatenation (e.g. "Hello " + "World!"). This means
// concatenation (e.g. "Hello " += "World!"). This means
// we don't want the note in the else clause to be emitted
} else if let ty::TyParam(_) = lhs_ty.sty {
// FIXME: point to span of param
@@ -381,7 +381,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let Some(missing_trait) = missing_trait {
if op.node == hir::BinOpKind::Add &&
self.check_str_addition(expr, lhs_expr, rhs_expr, lhs_ty,
rhs_ty, &mut err) {
rhs_ty, &mut err, false) {
// This has nothing here because it means we did string
// concatenation (e.g. "Hello " + "World!"). This means
// we don't want the note in the else clause to be emitted
@@ -410,13 +410,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
(lhs_ty, rhs_ty, return_ty)
}

fn check_str_addition(&self,
expr: &'gcx hir::Expr,
lhs_expr: &'gcx hir::Expr,
rhs_expr: &'gcx hir::Expr,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>,
err: &mut errors::DiagnosticBuilder) -> bool {
fn check_str_addition(
&self,
expr: &'gcx hir::Expr,
lhs_expr: &'gcx hir::Expr,
rhs_expr: &'gcx hir::Expr,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>,
err: &mut errors::DiagnosticBuilder,
is_assign: bool,
) -> bool {
let codemap = self.tcx.sess.codemap();
let msg = "`to_owned()` can be used to create an owned `String` \
from a string reference. String concatenation \
@@ -428,34 +431,36 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
match (&lhs_ty.sty, &rhs_ty.sty) {
(&TyRef(_, l_ty, _), &TyRef(_, r_ty, _))
if l_ty.sty == TyStr && r_ty.sty == TyStr => {
err.span_label(expr.span,
"`+` can't be used to concatenate two `&str` strings");
match codemap.span_to_snippet(lhs_expr.span) {
Ok(lstring) => err.span_suggestion(lhs_expr.span,
msg,
format!("{}.to_owned()", lstring)),
_ => err.help(msg),
};
if !is_assign {
err.span_label(expr.span,
"`+` can't be used to concatenate two `&str` strings");
match codemap.span_to_snippet(lhs_expr.span) {
Ok(lstring) => err.span_suggestion(lhs_expr.span,
msg,
format!("{}.to_owned()", lstring)),
_ => err.help(msg),
};
}
true
}
(&TyRef(_, l_ty, _), &TyAdt(..))
if l_ty.sty == TyStr && &format!("{:?}", rhs_ty) == "std::string::String" => {
err.span_label(expr.span,
"`+` can't be used to concatenate a `&str` with a `String`");
match codemap.span_to_snippet(lhs_expr.span) {
Ok(lstring) => err.span_suggestion(lhs_expr.span,
msg,
format!("{}.to_owned()", lstring)),
_ => err.help(msg),
};
match codemap.span_to_snippet(rhs_expr.span) {
Ok(rstring) => {
err.span_suggestion(rhs_expr.span,
"you also need to borrow the `String` on the right to \
get a `&str`",
format!("&{}", rstring));
match (
codemap.span_to_snippet(lhs_expr.span),
codemap.span_to_snippet(rhs_expr.span),
is_assign,
) {
(Ok(l), Ok(r), false) => {
err.multipart_suggestion(msg, vec![
(lhs_expr.span, format!("{}.to_owned()", l)),
(rhs_expr.span, format!("&{}", r)),
]);
}
_ => {
err.help(msg);
}
_ => {}
};
true
}
Loading