Skip to content

Commit 629d891

Browse files
committed
Auto merge of #52486 - kennytm:rollup, r=kennytm
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
2 parents 166795d + ae9c550 commit 629d891

File tree

24 files changed

+153
-42
lines changed

24 files changed

+153
-42
lines changed

src/bootstrap/bin/rustdoc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() {
3535
};
3636

3737
let mut dylib_path = bootstrap::util::dylib_path();
38-
dylib_path.insert(0, PathBuf::from(libdir));
38+
dylib_path.insert(0, PathBuf::from(libdir.clone()));
3939

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

7070
if verbose > 1 {
7171
eprintln!("rustdoc command: {:?}", cmd);
72+
eprintln!("libdir: {:?}", libdir);
7273
}
7374

7475
std::process::exit(match cmd.status() {

src/bootstrap/builder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ impl<'a> Builder<'a> {
459459
dist::Cargo,
460460
dist::Rls,
461461
dist::Rustfmt,
462+
dist::Clippy,
462463
dist::LlvmTools,
463464
dist::Extended,
464465
dist::HashSign
@@ -469,6 +470,7 @@ impl<'a> Builder<'a> {
469470
install::Cargo,
470471
install::Rls,
471472
install::Rustfmt,
473+
install::Clippy,
472474
install::Analysis,
473475
install::Src,
474476
install::Rustc
@@ -825,7 +827,7 @@ impl<'a> Builder<'a> {
825827
cargo.env("RUSTC_ERROR_FORMAT", error_format);
826828
}
827829
if cmd != "build" && cmd != "check" && want_rustdoc {
828-
cargo.env("RUSTDOC_LIBDIR", &libdir);
830+
cargo.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build));
829831
}
830832

831833
if mode.is_tool() {

src/build_helper/lib.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::path::{Path, PathBuf};
1515
use std::process::{Command, Stdio};
1616
use std::time::{SystemTime, UNIX_EPOCH};
1717
use std::{env, fs};
18+
use std::thread;
1819

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

182183
impl Drop for NativeLibBoilerplate {
183184
fn drop(&mut self) {
184-
t!(File::create(self.out_dir.join("rustbuild.timestamp")));
185+
if !thread::panicking() {
186+
t!(File::create(self.out_dir.join("rustbuild.timestamp")));
187+
}
185188
}
186189
}
187190

@@ -225,24 +228,34 @@ pub fn native_lib_boilerplate(
225228
}
226229
}
227230

228-
pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<NativeLibBoilerplate, ()> {
229-
let (link_name, search_path) = match &*env::var("TARGET").unwrap() {
231+
pub fn sanitizer_lib_boilerplate(sanitizer_name: &str)
232+
-> Result<(NativeLibBoilerplate, String), ()>
233+
{
234+
let (link_name, search_path, dynamic) = match &*env::var("TARGET").unwrap() {
230235
"x86_64-unknown-linux-gnu" => (
231236
format!("clang_rt.{}-x86_64", sanitizer_name),
232237
"build/lib/linux",
238+
false,
233239
),
234240
"x86_64-apple-darwin" => (
235-
format!("dylib=clang_rt.{}_osx_dynamic", sanitizer_name),
241+
format!("clang_rt.{}_osx_dynamic", sanitizer_name),
236242
"build/lib/darwin",
243+
true,
237244
),
238245
_ => return Err(()),
239246
};
240-
native_lib_boilerplate(
247+
let to_link = if dynamic {
248+
format!("dylib={}", link_name)
249+
} else {
250+
format!("static={}", link_name)
251+
};
252+
let lib = native_lib_boilerplate(
241253
"libcompiler_builtins/compiler-rt",
242254
sanitizer_name,
243-
&link_name,
255+
&to_link,
244256
search_path,
245-
)
257+
)?;
258+
Ok((lib, link_name))
246259
}
247260

248261
fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {

src/liballoc/str.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
4545
use core::mem;
4646
use core::ptr;
4747
use core::iter::FusedIterator;
48+
use core::unicode::conversions;
4849

4950
use borrow::{Borrow, ToOwned};
5051
use boxed::Box;
@@ -369,7 +370,18 @@ impl str {
369370
// See https://github.com/rust-lang/rust/issues/26035
370371
map_uppercase_sigma(self, i, &mut s)
371372
} else {
372-
s.extend(c.to_lowercase());
373+
match conversions::to_lower(c) {
374+
[a, '\0', _] => s.push(a),
375+
[a, b, '\0'] => {
376+
s.push(a);
377+
s.push(b);
378+
}
379+
[a, b, c] => {
380+
s.push(a);
381+
s.push(b);
382+
s.push(c);
383+
}
384+
}
373385
}
374386
}
375387
return s;
@@ -423,7 +435,20 @@ impl str {
423435
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
424436
pub fn to_uppercase(&self) -> String {
425437
let mut s = String::with_capacity(self.len());
426-
s.extend(self.chars().flat_map(|c| c.to_uppercase()));
438+
for c in self[..].chars() {
439+
match conversions::to_upper(c) {
440+
[a, '\0', _] => s.push(a),
441+
[a, b, '\0'] => {
442+
s.push(a);
443+
s.push(b);
444+
}
445+
[a, b, c] => {
446+
s.push(a);
447+
s.push(b);
448+
s.push(c);
449+
}
450+
}
451+
}
427452
return s;
428453
}
429454

src/libcore/iter/iterator.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ pub trait Iterator {
384384
///
385385
/// In other words, it zips two iterators together, into a single one.
386386
///
387-
/// If either iterator returns [`None`], [`next`] will return [`None`].
387+
/// If either iterator returns [`None`], [`next`] from the zipped iterator
388+
/// will return [`None`]. If the first iterator returns [`None`], `zip` will
389+
/// short-circuit and `next` will not be called on the second iterator.
388390
///
389391
/// # Examples
390392
///

src/libcore/option.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -833,12 +833,14 @@ impl<T> Option<T> {
833833
///
834834
/// ```
835835
/// let mut x = Some(2);
836-
/// x.take();
836+
/// let y = x.take();
837837
/// assert_eq!(x, None);
838+
/// assert_eq!(y, Some(2));
838839
///
839840
/// let mut x: Option<u32> = None;
840-
/// x.take();
841+
/// let y = x.take();
841842
/// assert_eq!(x, None);
843+
/// assert_eq!(y, None);
842844
/// ```
843845
#[inline]
844846
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/unicode/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ pub(crate) mod version;
2020
pub mod derived_property {
2121
pub use unicode::tables::derived_property::{Case_Ignorable, Cased};
2222
}
23+
pub mod conversions {
24+
pub use unicode::tables::conversions::{to_lower, to_upper};
25+
}
2326

2427
// For use in libsyntax
2528
pub mod property {

src/librustc/hir/lowering.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4011,8 +4011,12 @@ impl<'a> LoweringContext<'a> {
40114011
let iter = self.str_to_ident("iter");
40124012

40134013
let next_ident = self.str_to_ident("__next");
4014+
let next_sp = self.allow_internal_unstable(
4015+
CompilerDesugaringKind::ForLoop,
4016+
head_sp,
4017+
);
40144018
let next_pat = self.pat_ident_binding_mode(
4015-
pat.span,
4019+
next_sp,
40164020
next_ident,
40174021
hir::BindingAnnotation::Mutable,
40184022
);

src/librustc/ich/impls_syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ impl_stable_hash_for!(enum ::syntax_pos::hygiene::CompilerDesugaringKind {
412412
DotFill,
413413
QuestionMark,
414414
ExistentialReturnType,
415+
ForLoop,
415416
Catch
416417
});
417418

src/librustc/infer/error_reporting/need_type_info.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use hir::intravisit::{self, Visitor, NestedVisitorMap};
1313
use infer::InferCtxt;
1414
use infer::type_variable::TypeVariableOrigin;
1515
use ty::{self, Ty, TyInfer, TyVar};
16+
use syntax::codemap::CompilerDesugaringKind;
1617
use syntax_pos::Span;
1718
use errors::DiagnosticBuilder;
1819

@@ -132,7 +133,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
132133
labels.push((pattern.span, format!("consider giving this closure parameter a type")));
133134
} else if let Some(pattern) = local_visitor.found_local_pattern {
134135
if let Some(simple_ident) = pattern.simple_ident() {
135-
labels.push((pattern.span, format!("consider giving `{}` a type", simple_ident)));
136+
match pattern.span.compiler_desugaring_kind() {
137+
None => labels.push((pattern.span,
138+
format!("consider giving `{}` a type", simple_ident))),
139+
Some(CompilerDesugaringKind::ForLoop) => labels.push((
140+
pattern.span,
141+
"the element type for this iterator is not specified".to_string(),
142+
)),
143+
_ => {}
144+
}
136145
} else {
137146
labels.push((pattern.span, format!("consider giving the pattern a type")));
138147
}

src/librustc_asan/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cmake::Config;
1818

1919
fn main() {
2020
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
21-
let native = match sanitizer_lib_boilerplate("asan") {
21+
let (native, target) = match sanitizer_lib_boilerplate("asan") {
2222
Ok(native) => native,
2323
_ => return,
2424
};
@@ -29,7 +29,7 @@ fn main() {
2929
.define("COMPILER_RT_BUILD_XRAY", "OFF")
3030
.define("LLVM_CONFIG_PATH", llvm_config)
3131
.out_dir(&native.out_dir)
32-
.build_target("asan")
32+
.build_target(&target)
3333
.build();
3434
}
3535
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");

src/librustc_lsan/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cmake::Config;
1818

1919
fn main() {
2020
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
21-
let native = match sanitizer_lib_boilerplate("lsan") {
21+
let (native, target) = match sanitizer_lib_boilerplate("lsan") {
2222
Ok(native) => native,
2323
_ => return,
2424
};
@@ -29,7 +29,7 @@ fn main() {
2929
.define("COMPILER_RT_BUILD_XRAY", "OFF")
3030
.define("LLVM_CONFIG_PATH", llvm_config)
3131
.out_dir(&native.out_dir)
32-
.build_target("lsan")
32+
.build_target(&target)
3333
.build();
3434
}
3535
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");

src/librustc_msan/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cmake::Config;
1818

1919
fn main() {
2020
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
21-
let native = match sanitizer_lib_boilerplate("msan") {
21+
let (native, target) = match sanitizer_lib_boilerplate("msan") {
2222
Ok(native) => native,
2323
_ => return,
2424
};
@@ -29,7 +29,7 @@ fn main() {
2929
.define("COMPILER_RT_BUILD_XRAY", "OFF")
3030
.define("LLVM_CONFIG_PATH", llvm_config)
3131
.out_dir(&native.out_dir)
32-
.build_target("msan")
32+
.build_target(&target)
3333
.build();
3434
}
3535
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4521,7 +4521,7 @@ impl<'a> Resolver<'a> {
45214521
attr::mark_known(attr);
45224522

45234523
let msg = "attribute procedural macros are experimental";
4524-
let feature = "proc_macro";
4524+
let feature = "use_extern_macros";
45254525

45264526
feature_err(&self.session.parse_sess, feature,
45274527
attr.span, GateIssue::Language, msg)

src/librustc_tsan/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cmake::Config;
1818

1919
fn main() {
2020
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
21-
let native = match sanitizer_lib_boilerplate("tsan") {
21+
let (native, target) = match sanitizer_lib_boilerplate("tsan") {
2222
Ok(native) => native,
2323
_ => return,
2424
};
@@ -29,7 +29,7 @@ fn main() {
2929
.define("COMPILER_RT_BUILD_XRAY", "OFF")
3030
.define("LLVM_CONFIG_PATH", llvm_config)
3131
.out_dir(&native.out_dir)
32-
.build_target("tsan")
32+
.build_target(&target)
3333
.build();
3434
}
3535
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");

src/librustdoc/html/render.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,6 @@ impl Context {
19681968

19691969
// If the item is a macro, redirect from the old macro URL (with !)
19701970
// to the new one (without).
1971-
// FIXME(#35705) remove this redirect.
19721971
if item_type == ItemType::Macro {
19731972
let redir_name = format!("{}.{}!.html", item_type, name);
19741973
let redir_dst = self.dst.join(redir_name);

src/libstd/io/buffered.rs

+23-10
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ impl<W> fmt::Display for IntoInnerError<W> {
738738
/// reducing the number of actual writes to the file.
739739
///
740740
/// ```no_run
741-
/// use std::fs::File;
741+
/// use std::fs::{self, File};
742742
/// use std::io::prelude::*;
743743
/// use std::io::LineWriter;
744744
///
@@ -752,17 +752,30 @@ impl<W> fmt::Display for IntoInnerError<W> {
752752
/// let file = File::create("poem.txt")?;
753753
/// let mut file = LineWriter::new(file);
754754
///
755-
/// for &byte in road_not_taken.iter() {
756-
/// file.write(&[byte]).unwrap();
757-
/// }
755+
/// file.write_all(b"I shall be telling this with a sigh")?;
756+
///
757+
/// // No bytes are written until a newline is encountered (or
758+
/// // the internal buffer is filled).
759+
/// assert_eq!(fs::read_to_string("poem.txt")?, "");
760+
/// file.write_all(b"\n")?;
761+
/// assert_eq!(
762+
/// fs::read_to_string("poem.txt")?,
763+
/// "I shall be telling this with a sigh\n",
764+
/// );
758765
///
759-
/// // let's check we did the right thing.
760-
/// let mut file = File::open("poem.txt")?;
761-
/// let mut contents = String::new();
766+
/// // Write the rest of the poem.
767+
/// file.write_all(b"Somewhere ages and ages hence:
768+
/// Two roads diverged in a wood, and I -
769+
/// I took the one less traveled by,
770+
/// And that has made all the difference.")?;
762771
///
763-
/// file.read_to_string(&mut contents)?;
772+
/// // The last line of the poem doesn't end in a newline, so
773+
/// // we have to flush or drop the `LineWriter` to finish
774+
/// // writing.
775+
/// file.flush()?;
764776
///
765-
/// assert_eq!(contents.as_bytes(), &road_not_taken[..]);
777+
/// // Confirm the whole poem was written.
778+
/// assert_eq!(fs::read("poem.txt")?, &road_not_taken[..]);
766779
/// Ok(())
767780
/// }
768781
/// ```
@@ -862,7 +875,7 @@ impl<W: Write> LineWriter<W> {
862875
///
863876
/// The internal buffer is written out before returning the writer.
864877
///
865-
// # Errors
878+
/// # Errors
866879
///
867880
/// An `Err` will be returned if an error occurs while flushing the buffer.
868881
///

src/libstd/net/tcp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub struct TcpStream(net_imp::TcpStream);
8181
/// }
8282
///
8383
/// fn main() -> io::Result<()> {
84-
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
84+
/// let listener = TcpListener::bind("127.0.0.1:80")?;
8585
///
8686
/// // accept connections and process them serially
8787
/// for stream in listener.incoming() {

0 commit comments

Comments
 (0)