Skip to content

Commit

Permalink
Auto merge of #52486 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 13 pull requests

Successful merges:

 - #51628 (use checked write in `LineWriter` example)
 - #52116 (Handle array manually in str case conversion methods)
 - #52218 (Amend option.take examples)
 - #52418 (Do not use desugared ident when suggesting adding a type)
 - #52439 (Revert some changes from #51917 to fix custom libdir)
 - #52455 (Fix doc comment: use `?` instead of `.unwrap()`)
 - #52458 (rustc: Fix a suggestion for the `proc_macro` feature)
 - #52464 (Allow clippy to be installed with make install)
 - #52472 (rustc: Enable `use_extern_macros` in 2018 edition)
 - #52477 (Clarify short-circuiting behvaior of Iterator::zip.)
 - #52480 (Cleanup #24958)
 - #52487 (Don't build twice the sanitizers on Linux)
 - #52510 (rustdoc: remove FIXME about macro redirects)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jul 19, 2018
2 parents 166795d + ae9c550 commit 629d891
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 42 deletions.
3 changes: 2 additions & 1 deletion src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {
};

let mut dylib_path = bootstrap::util::dylib_path();
dylib_path.insert(0, PathBuf::from(libdir));
dylib_path.insert(0, PathBuf::from(libdir.clone()));

let mut cmd = Command::new(rustdoc);
cmd.args(&args)
Expand Down Expand Up @@ -69,6 +69,7 @@ fn main() {

if verbose > 1 {
eprintln!("rustdoc command: {:?}", cmd);
eprintln!("libdir: {:?}", libdir);
}

std::process::exit(match cmd.status() {
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ impl<'a> Builder<'a> {
dist::Cargo,
dist::Rls,
dist::Rustfmt,
dist::Clippy,
dist::LlvmTools,
dist::Extended,
dist::HashSign
Expand All @@ -469,6 +470,7 @@ impl<'a> Builder<'a> {
install::Cargo,
install::Rls,
install::Rustfmt,
install::Clippy,
install::Analysis,
install::Src,
install::Rustc
Expand Down Expand Up @@ -825,7 +827,7 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_ERROR_FORMAT", error_format);
}
if cmd != "build" && cmd != "check" && want_rustdoc {
cargo.env("RUSTDOC_LIBDIR", &libdir);
cargo.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build));
}

if mode.is_tool() {
Expand Down
27 changes: 20 additions & 7 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::time::{SystemTime, UNIX_EPOCH};
use std::{env, fs};
use std::thread;

/// A helper macro to `unwrap` a result except also print out details like:
///
Expand Down Expand Up @@ -181,7 +182,9 @@ pub struct NativeLibBoilerplate {

impl Drop for NativeLibBoilerplate {
fn drop(&mut self) {
t!(File::create(self.out_dir.join("rustbuild.timestamp")));
if !thread::panicking() {
t!(File::create(self.out_dir.join("rustbuild.timestamp")));
}
}
}

Expand Down Expand Up @@ -225,24 +228,34 @@ pub fn native_lib_boilerplate(
}
}

pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<NativeLibBoilerplate, ()> {
let (link_name, search_path) = match &*env::var("TARGET").unwrap() {
pub fn sanitizer_lib_boilerplate(sanitizer_name: &str)
-> Result<(NativeLibBoilerplate, String), ()>
{
let (link_name, search_path, dynamic) = match &*env::var("TARGET").unwrap() {
"x86_64-unknown-linux-gnu" => (
format!("clang_rt.{}-x86_64", sanitizer_name),
"build/lib/linux",
false,
),
"x86_64-apple-darwin" => (
format!("dylib=clang_rt.{}_osx_dynamic", sanitizer_name),
format!("clang_rt.{}_osx_dynamic", sanitizer_name),
"build/lib/darwin",
true,
),
_ => return Err(()),
};
native_lib_boilerplate(
let to_link = if dynamic {
format!("dylib={}", link_name)
} else {
format!("static={}", link_name)
};
let lib = native_lib_boilerplate(
"libcompiler_builtins/compiler-rt",
sanitizer_name,
&link_name,
&to_link,
search_path,
)
)?;
Ok((lib, link_name))
}

fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
Expand Down
29 changes: 27 additions & 2 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
use core::mem;
use core::ptr;
use core::iter::FusedIterator;
use core::unicode::conversions;

use borrow::{Borrow, ToOwned};
use boxed::Box;
Expand Down Expand Up @@ -369,7 +370,18 @@ impl str {
// See https://github.com/rust-lang/rust/issues/26035
map_uppercase_sigma(self, i, &mut s)
} else {
s.extend(c.to_lowercase());
match conversions::to_lower(c) {
[a, '\0', _] => s.push(a),
[a, b, '\0'] => {
s.push(a);
s.push(b);
}
[a, b, c] => {
s.push(a);
s.push(b);
s.push(c);
}
}
}
}
return s;
Expand Down Expand Up @@ -423,7 +435,20 @@ impl str {
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
pub fn to_uppercase(&self) -> String {
let mut s = String::with_capacity(self.len());
s.extend(self.chars().flat_map(|c| c.to_uppercase()));
for c in self[..].chars() {
match conversions::to_upper(c) {
[a, '\0', _] => s.push(a),
[a, b, '\0'] => {
s.push(a);
s.push(b);
}
[a, b, c] => {
s.push(a);
s.push(b);
s.push(c);
}
}
}
return s;
}

Expand Down
4 changes: 3 additions & 1 deletion src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ pub trait Iterator {
///
/// In other words, it zips two iterators together, into a single one.
///
/// If either iterator returns [`None`], [`next`] will return [`None`].
/// If either iterator returns [`None`], [`next`] from the zipped iterator
/// will return [`None`]. If the first iterator returns [`None`], `zip` will
/// short-circuit and `next` will not be called on the second iterator.
///
/// # Examples
///
Expand Down
6 changes: 4 additions & 2 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,12 +833,14 @@ impl<T> Option<T> {
///
/// ```
/// let mut x = Some(2);
/// x.take();
/// let y = x.take();
/// assert_eq!(x, None);
/// assert_eq!(y, Some(2));
///
/// let mut x: Option<u32> = None;
/// x.take();
/// let y = x.take();
/// assert_eq!(x, None);
/// assert_eq!(y, None);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/unicode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub(crate) mod version;
pub mod derived_property {
pub use unicode::tables::derived_property::{Case_Ignorable, Cased};
}
pub mod conversions {
pub use unicode::tables::conversions::{to_lower, to_upper};
}

// For use in libsyntax
pub mod property {
Expand Down
6 changes: 5 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4011,8 +4011,12 @@ impl<'a> LoweringContext<'a> {
let iter = self.str_to_ident("iter");

let next_ident = self.str_to_ident("__next");
let next_sp = self.allow_internal_unstable(
CompilerDesugaringKind::ForLoop,
head_sp,
);
let next_pat = self.pat_ident_binding_mode(
pat.span,
next_sp,
next_ident,
hir::BindingAnnotation::Mutable,
);
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ impl_stable_hash_for!(enum ::syntax_pos::hygiene::CompilerDesugaringKind {
DotFill,
QuestionMark,
ExistentialReturnType,
ForLoop,
Catch
});

Expand Down
11 changes: 10 additions & 1 deletion src/librustc/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use hir::intravisit::{self, Visitor, NestedVisitorMap};
use infer::InferCtxt;
use infer::type_variable::TypeVariableOrigin;
use ty::{self, Ty, TyInfer, TyVar};
use syntax::codemap::CompilerDesugaringKind;
use syntax_pos::Span;
use errors::DiagnosticBuilder;

Expand Down Expand Up @@ -132,7 +133,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
labels.push((pattern.span, format!("consider giving this closure parameter a type")));
} else if let Some(pattern) = local_visitor.found_local_pattern {
if let Some(simple_ident) = pattern.simple_ident() {
labels.push((pattern.span, format!("consider giving `{}` a type", simple_ident)));
match pattern.span.compiler_desugaring_kind() {
None => labels.push((pattern.span,
format!("consider giving `{}` a type", simple_ident))),
Some(CompilerDesugaringKind::ForLoop) => labels.push((
pattern.span,
"the element type for this iterator is not specified".to_string(),
)),
_ => {}
}
} else {
labels.push((pattern.span, format!("consider giving the pattern a type")));
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_asan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use cmake::Config;

fn main() {
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
let native = match sanitizer_lib_boilerplate("asan") {
let (native, target) = match sanitizer_lib_boilerplate("asan") {
Ok(native) => native,
_ => return,
};
Expand All @@ -29,7 +29,7 @@ fn main() {
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target("asan")
.build_target(&target)
.build();
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lsan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use cmake::Config;

fn main() {
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
let native = match sanitizer_lib_boilerplate("lsan") {
let (native, target) = match sanitizer_lib_boilerplate("lsan") {
Ok(native) => native,
_ => return,
};
Expand All @@ -29,7 +29,7 @@ fn main() {
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target("lsan")
.build_target(&target)
.build();
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_msan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use cmake::Config;

fn main() {
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
let native = match sanitizer_lib_boilerplate("msan") {
let (native, target) = match sanitizer_lib_boilerplate("msan") {
Ok(native) => native,
_ => return,
};
Expand All @@ -29,7 +29,7 @@ fn main() {
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target("msan")
.build_target(&target)
.build();
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4521,7 +4521,7 @@ impl<'a> Resolver<'a> {
attr::mark_known(attr);

let msg = "attribute procedural macros are experimental";
let feature = "proc_macro";
let feature = "use_extern_macros";

feature_err(&self.session.parse_sess, feature,
attr.span, GateIssue::Language, msg)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_tsan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use cmake::Config;

fn main() {
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
let native = match sanitizer_lib_boilerplate("tsan") {
let (native, target) = match sanitizer_lib_boilerplate("tsan") {
Ok(native) => native,
_ => return,
};
Expand All @@ -29,7 +29,7 @@ fn main() {
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target("tsan")
.build_target(&target)
.build();
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,6 @@ impl Context {

// If the item is a macro, redirect from the old macro URL (with !)
// to the new one (without).
// FIXME(#35705) remove this redirect.
if item_type == ItemType::Macro {
let redir_name = format!("{}.{}!.html", item_type, name);
let redir_dst = self.dst.join(redir_name);
Expand Down
33 changes: 23 additions & 10 deletions src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ impl<W> fmt::Display for IntoInnerError<W> {
/// reducing the number of actual writes to the file.
///
/// ```no_run
/// use std::fs::File;
/// use std::fs::{self, File};
/// use std::io::prelude::*;
/// use std::io::LineWriter;
///
Expand All @@ -752,17 +752,30 @@ impl<W> fmt::Display for IntoInnerError<W> {
/// let file = File::create("poem.txt")?;
/// let mut file = LineWriter::new(file);
///
/// for &byte in road_not_taken.iter() {
/// file.write(&[byte]).unwrap();
/// }
/// file.write_all(b"I shall be telling this with a sigh")?;
///
/// // No bytes are written until a newline is encountered (or
/// // the internal buffer is filled).
/// assert_eq!(fs::read_to_string("poem.txt")?, "");
/// file.write_all(b"\n")?;
/// assert_eq!(
/// fs::read_to_string("poem.txt")?,
/// "I shall be telling this with a sigh\n",
/// );
///
/// // let's check we did the right thing.
/// let mut file = File::open("poem.txt")?;
/// let mut contents = String::new();
/// // Write the rest of the poem.
/// file.write_all(b"Somewhere ages and ages hence:
/// Two roads diverged in a wood, and I -
/// I took the one less traveled by,
/// And that has made all the difference.")?;
///
/// file.read_to_string(&mut contents)?;
/// // The last line of the poem doesn't end in a newline, so
/// // we have to flush or drop the `LineWriter` to finish
/// // writing.
/// file.flush()?;
///
/// assert_eq!(contents.as_bytes(), &road_not_taken[..]);
/// // Confirm the whole poem was written.
/// assert_eq!(fs::read("poem.txt")?, &road_not_taken[..]);
/// Ok(())
/// }
/// ```
Expand Down Expand Up @@ -862,7 +875,7 @@ impl<W: Write> LineWriter<W> {
///
/// The internal buffer is written out before returning the writer.
///
// # Errors
/// # Errors
///
/// An `Err` will be returned if an error occurs while flushing the buffer.
///
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub struct TcpStream(net_imp::TcpStream);
/// }
///
/// fn main() -> io::Result<()> {
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
/// let listener = TcpListener::bind("127.0.0.1:80")?;
///
/// // accept connections and process them serially
/// for stream in listener.incoming() {
Expand Down
Loading

0 comments on commit 629d891

Please sign in to comment.