Skip to content

Commit

Permalink
Auto merge of #55095 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 15, 2018
2 parents 5a52983 + 562625d commit 46880f4
Show file tree
Hide file tree
Showing 27 changed files with 326 additions and 374 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ are:
* Don't be afraid to ask! The Rust community is friendly and helpful.

[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html
[gdfrustc]: http://manishearth.github.io/rust-internals-docs/rustc/
[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
[rif]: http://internals.rust-lang.org
[rr]: https://doc.rust-lang.org/book/README.html
Expand Down
5 changes: 2 additions & 3 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ pub type Result = result::Result<(), Error>;
/// use std::fmt::{self, write};
///
/// let mut output = String::new();
/// match write(&mut output, format_args!("Hello {}!", "world")) {
/// Err(fmt::Error) => panic!("An error occurred"),
/// _ => (),
/// if let Err(fmt::Error) = write(&mut output, format_args!("Hello {}!", "world")) {
/// panic!("An error occurred");
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of *the same* allocated object.
/// byte past the end of the same allocated object.
///
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
///
Expand Down Expand Up @@ -1255,7 +1255,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of the same allocated object.
///
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
///
Expand Down Expand Up @@ -1312,7 +1312,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of the same allocated object.
///
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
///
Expand Down Expand Up @@ -1657,7 +1657,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of *the same* allocated object.
/// byte past the end of the same allocated object.
///
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
///
Expand Down Expand Up @@ -1893,7 +1893,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of the same allocated object.
///
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
///
Expand Down Expand Up @@ -1950,7 +1950,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of the same allocated object.
///
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
///
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ use util::nodemap::{DefIdMap, NodeMap};

use std::collections::BTreeMap;
use std::fmt::Debug;
use std::iter;
use std::mem;
use smallvec::SmallVec;
use syntax::attr;
Expand Down Expand Up @@ -3888,9 +3887,7 @@ impl<'a> LoweringContext<'a> {
.collect::<P<[hir::Field]>>();

let is_unit = fields.is_empty();
let struct_path = iter::once("ops")
.chain(iter::once(path))
.collect::<Vec<_>>();
let struct_path = ["ops", path];
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
let struct_path = hir::QPath::Resolved(None, P(struct_path));

Expand Down
214 changes: 99 additions & 115 deletions src/librustc/session/config.rs

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/librustc/session/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a> FileSearch<'a> {
F: FnMut(&Path, PathKind)
{
let mut visited_dirs = FxHashSet::default();

visited_dirs.reserve(self.search_paths.paths.len() + 1);
for (path, kind) in self.search_paths.iter(self.kind) {
f(path, kind);
visited_dirs.insert(path.to_path_buf());
Expand Down Expand Up @@ -160,7 +160,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
match env::current_exe() {
Ok(exe) => {
match canonicalize(Some(exe)) {
Some(mut p) => { p.pop(); p.pop(); return p; },
Some(mut p) => { p.pop(); p.pop(); p },
None => bug!("can't determine value for sysroot")
}
}
Expand All @@ -175,25 +175,25 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
// to lib64/lib32. This would be more foolproof by basing the sysroot off
// of the directory where librustc is located, rather than where the rustc
// binary is.
//If --libdir is set during configuration to the value other than
// If --libdir is set during configuration to the value other than
// "lib" (i.e. non-default), this value is used (see issue #16552).

match option_env!("CFG_LIBDIR_RELATIVE") {
Some(libdir) if libdir != "lib" => return libdir.into(),
_ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
return PRIMARY_LIB_DIR.into();
} else {
return SECONDARY_LIB_DIR.into();
}
}

#[cfg(target_pointer_width = "64")]
const PRIMARY_LIB_DIR: &'static str = "lib64";

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

const SECONDARY_LIB_DIR: &'static str = "lib";

match option_env!("CFG_LIBDIR_RELATIVE") {
Some(libdir) if libdir != "lib" => libdir.into(),
_ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
PRIMARY_LIB_DIR.into()
} else {
SECONDARY_LIB_DIR.into()
}
}
}

// The name of rustc's own place to organize libraries.
Expand Down
50 changes: 19 additions & 31 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ impl Session {
match self.opts.maybe_sysroot {
Some(ref sysroot) => sysroot,
None => self.default_sysroot
.as_ref()
.expect("missing sysroot and default_sysroot in Session"),
.as_ref()
.expect("missing sysroot and default_sysroot in Session"),
}
}
pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> {
Expand All @@ -727,14 +727,8 @@ impl Session {
pub fn set_incr_session_load_dep_graph(&self, load: bool) {
let mut incr_comp_session = self.incr_comp_session.borrow_mut();

match *incr_comp_session {
IncrCompSession::Active {
ref mut load_dep_graph,
..
} => {
*load_dep_graph = load;
}
_ => {}
if let IncrCompSession::Active { ref mut load_dep_graph, .. } = *incr_comp_session {
*load_dep_graph = load;
}
}

Expand Down Expand Up @@ -872,9 +866,9 @@ impl Session {
/// This expends fuel if applicable, and records fuel if applicable.
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
let mut ret = true;
match self.optimization_fuel_crate {
Some(ref c) if c == crate_name => {
assert!(self.query_threads() == 1);
if let Some(ref c) = self.optimization_fuel_crate {
if c == crate_name {
assert_eq!(self.query_threads(), 1);
let fuel = self.optimization_fuel_limit.get();
ret = fuel != 0;
if fuel == 0 && !self.out_of_fuel.get() {
Expand All @@ -884,14 +878,12 @@ impl Session {
self.optimization_fuel_limit.set(fuel - 1);
}
}
_ => {}
}
match self.print_fuel_crate {
Some(ref c) if c == crate_name => {
assert!(self.query_threads() == 1);
if let Some(ref c) = self.print_fuel_crate {
if c == crate_name {
assert_eq!(self.query_threads(), 1);
self.print_fuel.set(self.print_fuel.get() + 1);
}
_ => {}
}
ret
}
Expand Down Expand Up @@ -1108,14 +1100,11 @@ pub fn build_session_(
source_map: Lrc<source_map::SourceMap>,
) -> Session {
let host_triple = TargetTriple::from_triple(config::host_triple());
let host = match Target::search(&host_triple) {
Ok(t) => t,
Err(e) => {
span_diagnostic
.fatal(&format!("Error loading host specification: {}", e))
.raise();
}
};
let host = Target::search(&host_triple).unwrap_or_else(|e|
span_diagnostic
.fatal(&format!("Error loading host specification: {}", e))
.raise()
);
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);

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

let working_dir = match env::current_dir() {
Ok(dir) => dir,
Err(e) => p_s.span_diagnostic
let working_dir = env::current_dir().unwrap_or_else(|e|
p_s.span_diagnostic
.fatal(&format!("Current directory is invalid: {}", e))
.raise(),
};
.raise()
);
let working_dir = file_path_mapping.map_prefix(working_dir);

let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/search_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use session::{early_error, config};

#[derive(Clone, Debug)]
pub struct SearchPaths {
paths: Vec<(PathKind, PathBuf)>,
crate paths: Vec<(PathKind, PathBuf)>,
}

pub struct Iter<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ pub fn build_output_filenames(
.crate_name
.clone()
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
.unwrap_or_else(|| input.filestem());
.unwrap_or_else(|| input.filestem().to_owned());

OutputFilenames {
out_directory: dirpath,
Expand Down
Loading

0 comments on commit 46880f4

Please sign in to comment.