Skip to content

Commit 46880f4

Browse files
committed
Auto merge of #55095 - Manishearth:rollup, r=Manishearth
Rollup of 11 pull requests Successful merges: - #54820 (Closes #54538: `unused_patterns` lint) - #54963 (Cleanup rustc/session) - #54991 (add test for #23189) - #55025 (Add missing lifetime fragment specifier to error message.) - #55047 (doc: make core::fmt::Error example more simple) - #55048 (Don't collect to vectors where unnecessary) - #55060 (clarify pointer add/sub function safety concerns) - #55062 (Make EvalContext::step public again) - #55066 (Fix incorrect link in println! documentation) - #55081 (Deduplicate tests) - #55088 (Update rustc documentation link) Failed merges: r? @ghost
2 parents 5a52983 + 562625d commit 46880f4

27 files changed

+326
-374
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ are:
646646
* Don't be afraid to ask! The Rust community is friendly and helpful.
647647

648648
[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html
649-
[gdfrustc]: http://manishearth.github.io/rust-internals-docs/rustc/
649+
[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
650650
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
651651
[rif]: http://internals.rust-lang.org
652652
[rr]: https://doc.rust-lang.org/book/README.html

src/libcore/fmt/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ pub type Result = result::Result<(), Error>;
9696
/// use std::fmt::{self, write};
9797
///
9898
/// let mut output = String::new();
99-
/// match write(&mut output, format_args!("Hello {}!", "world")) {
100-
/// Err(fmt::Error) => panic!("An error occurred"),
101-
/// _ => (),
99+
/// if let Err(fmt::Error) = write(&mut output, format_args!("Hello {}!", "world")) {
100+
/// panic!("An error occurred");
102101
/// }
103102
/// ```
104103
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ impl<T: ?Sized> *const T {
10371037
/// Behavior:
10381038
///
10391039
/// * Both the starting and resulting pointer must be either in bounds or one
1040-
/// byte past the end of *the same* allocated object.
1040+
/// byte past the end of the same allocated object.
10411041
///
10421042
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
10431043
///
@@ -1255,7 +1255,7 @@ impl<T: ?Sized> *const T {
12551255
/// Behavior:
12561256
///
12571257
/// * Both the starting and resulting pointer must be either in bounds or one
1258-
/// byte past the end of an allocated object.
1258+
/// byte past the end of the same allocated object.
12591259
///
12601260
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
12611261
///
@@ -1312,7 +1312,7 @@ impl<T: ?Sized> *const T {
13121312
/// Behavior:
13131313
///
13141314
/// * Both the starting and resulting pointer must be either in bounds or one
1315-
/// byte past the end of an allocated object.
1315+
/// byte past the end of the same allocated object.
13161316
///
13171317
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
13181318
///
@@ -1657,7 +1657,7 @@ impl<T: ?Sized> *mut T {
16571657
/// Behavior:
16581658
///
16591659
/// * Both the starting and resulting pointer must be either in bounds or one
1660-
/// byte past the end of *the same* allocated object.
1660+
/// byte past the end of the same allocated object.
16611661
///
16621662
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
16631663
///
@@ -1893,7 +1893,7 @@ impl<T: ?Sized> *mut T {
18931893
/// Behavior:
18941894
///
18951895
/// * Both the starting and resulting pointer must be either in bounds or one
1896-
/// byte past the end of an allocated object.
1896+
/// byte past the end of the same allocated object.
18971897
///
18981898
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
18991899
///
@@ -1950,7 +1950,7 @@ impl<T: ?Sized> *mut T {
19501950
/// Behavior:
19511951
///
19521952
/// * Both the starting and resulting pointer must be either in bounds or one
1953-
/// byte past the end of an allocated object.
1953+
/// byte past the end of the same allocated object.
19541954
///
19551955
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
19561956
///

src/librustc/hir/lowering.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ use util::nodemap::{DefIdMap, NodeMap};
6060

6161
use std::collections::BTreeMap;
6262
use std::fmt::Debug;
63-
use std::iter;
6463
use std::mem;
6564
use smallvec::SmallVec;
6665
use syntax::attr;
@@ -3888,9 +3887,7 @@ impl<'a> LoweringContext<'a> {
38883887
.collect::<P<[hir::Field]>>();
38893888

38903889
let is_unit = fields.is_empty();
3891-
let struct_path = iter::once("ops")
3892-
.chain(iter::once(path))
3893-
.collect::<Vec<_>>();
3890+
let struct_path = ["ops", path];
38943891
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
38953892
let struct_path = hir::QPath::Resolved(None, P(struct_path));
38963893

src/librustc/session/config.rs

+99-115
Large diffs are not rendered by default.

src/librustc/session/filesearch.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a> FileSearch<'a> {
4141
F: FnMut(&Path, PathKind)
4242
{
4343
let mut visited_dirs = FxHashSet::default();
44-
44+
visited_dirs.reserve(self.search_paths.paths.len() + 1);
4545
for (path, kind) in self.search_paths.iter(self.kind) {
4646
f(path, kind);
4747
visited_dirs.insert(path.to_path_buf());
@@ -160,7 +160,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
160160
match env::current_exe() {
161161
Ok(exe) => {
162162
match canonicalize(Some(exe)) {
163-
Some(mut p) => { p.pop(); p.pop(); return p; },
163+
Some(mut p) => { p.pop(); p.pop(); p },
164164
None => bug!("can't determine value for sysroot")
165165
}
166166
}
@@ -175,25 +175,25 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
175175
// to lib64/lib32. This would be more foolproof by basing the sysroot off
176176
// of the directory where librustc is located, rather than where the rustc
177177
// binary is.
178-
//If --libdir is set during configuration to the value other than
178+
// If --libdir is set during configuration to the value other than
179179
// "lib" (i.e. non-default), this value is used (see issue #16552).
180180

181-
match option_env!("CFG_LIBDIR_RELATIVE") {
182-
Some(libdir) if libdir != "lib" => return libdir.into(),
183-
_ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
184-
return PRIMARY_LIB_DIR.into();
185-
} else {
186-
return SECONDARY_LIB_DIR.into();
187-
}
188-
}
189-
190181
#[cfg(target_pointer_width = "64")]
191182
const PRIMARY_LIB_DIR: &'static str = "lib64";
192183

193184
#[cfg(target_pointer_width = "32")]
194185
const PRIMARY_LIB_DIR: &'static str = "lib32";
195186

196187
const SECONDARY_LIB_DIR: &'static str = "lib";
188+
189+
match option_env!("CFG_LIBDIR_RELATIVE") {
190+
Some(libdir) if libdir != "lib" => libdir.into(),
191+
_ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
192+
PRIMARY_LIB_DIR.into()
193+
} else {
194+
SECONDARY_LIB_DIR.into()
195+
}
196+
}
197197
}
198198

199199
// The name of rustc's own place to organize libraries.

src/librustc/session/mod.rs

+19-31
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@ impl Session {
703703
match self.opts.maybe_sysroot {
704704
Some(ref sysroot) => sysroot,
705705
None => self.default_sysroot
706-
.as_ref()
707-
.expect("missing sysroot and default_sysroot in Session"),
706+
.as_ref()
707+
.expect("missing sysroot and default_sysroot in Session"),
708708
}
709709
}
710710
pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> {
@@ -727,14 +727,8 @@ impl Session {
727727
pub fn set_incr_session_load_dep_graph(&self, load: bool) {
728728
let mut incr_comp_session = self.incr_comp_session.borrow_mut();
729729

730-
match *incr_comp_session {
731-
IncrCompSession::Active {
732-
ref mut load_dep_graph,
733-
..
734-
} => {
735-
*load_dep_graph = load;
736-
}
737-
_ => {}
730+
if let IncrCompSession::Active { ref mut load_dep_graph, .. } = *incr_comp_session {
731+
*load_dep_graph = load;
738732
}
739733
}
740734

@@ -872,9 +866,9 @@ impl Session {
872866
/// This expends fuel if applicable, and records fuel if applicable.
873867
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
874868
let mut ret = true;
875-
match self.optimization_fuel_crate {
876-
Some(ref c) if c == crate_name => {
877-
assert!(self.query_threads() == 1);
869+
if let Some(ref c) = self.optimization_fuel_crate {
870+
if c == crate_name {
871+
assert_eq!(self.query_threads(), 1);
878872
let fuel = self.optimization_fuel_limit.get();
879873
ret = fuel != 0;
880874
if fuel == 0 && !self.out_of_fuel.get() {
@@ -884,14 +878,12 @@ impl Session {
884878
self.optimization_fuel_limit.set(fuel - 1);
885879
}
886880
}
887-
_ => {}
888881
}
889-
match self.print_fuel_crate {
890-
Some(ref c) if c == crate_name => {
891-
assert!(self.query_threads() == 1);
882+
if let Some(ref c) = self.print_fuel_crate {
883+
if c == crate_name {
884+
assert_eq!(self.query_threads(), 1);
892885
self.print_fuel.set(self.print_fuel.get() + 1);
893886
}
894-
_ => {}
895887
}
896888
ret
897889
}
@@ -1108,14 +1100,11 @@ pub fn build_session_(
11081100
source_map: Lrc<source_map::SourceMap>,
11091101
) -> Session {
11101102
let host_triple = TargetTriple::from_triple(config::host_triple());
1111-
let host = match Target::search(&host_triple) {
1112-
Ok(t) => t,
1113-
Err(e) => {
1114-
span_diagnostic
1115-
.fatal(&format!("Error loading host specification: {}", e))
1116-
.raise();
1117-
}
1118-
};
1103+
let host = Target::search(&host_triple).unwrap_or_else(|e|
1104+
span_diagnostic
1105+
.fatal(&format!("Error loading host specification: {}", e))
1106+
.raise()
1107+
);
11191108
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
11201109

11211110
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map);
@@ -1135,12 +1124,11 @@ pub fn build_session_(
11351124
let print_fuel_crate = sopts.debugging_opts.print_fuel.clone();
11361125
let print_fuel = LockCell::new(0);
11371126

1138-
let working_dir = match env::current_dir() {
1139-
Ok(dir) => dir,
1140-
Err(e) => p_s.span_diagnostic
1127+
let working_dir = env::current_dir().unwrap_or_else(|e|
1128+
p_s.span_diagnostic
11411129
.fatal(&format!("Current directory is invalid: {}", e))
1142-
.raise(),
1143-
};
1130+
.raise()
1131+
);
11441132
let working_dir = file_path_mapping.map_prefix(working_dir);
11451133

11461134
let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {

src/librustc/session/search_paths.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use session::{early_error, config};
1414

1515
#[derive(Clone, Debug)]
1616
pub struct SearchPaths {
17-
paths: Vec<(PathKind, PathBuf)>,
17+
crate paths: Vec<(PathKind, PathBuf)>,
1818
}
1919

2020
pub struct Iter<'a> {

src/librustc_driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ pub fn build_output_filenames(
16571657
.crate_name
16581658
.clone()
16591659
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
1660-
.unwrap_or_else(|| input.filestem());
1660+
.unwrap_or_else(|| input.filestem().to_owned());
16611661

16621662
OutputFilenames {
16631663
out_directory: dirpath,

0 commit comments

Comments
 (0)