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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 20 additions & 7 deletions
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

Lines changed: 27 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 10 additions & 1 deletion
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
}

0 commit comments

Comments
 (0)