Skip to content

Commit

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

- Successful merges: #45470, #45588, #45682, #45714, #45751, #45764, #45778, #45782, #45784
- Failed merges:
  • Loading branch information
bors committed Nov 7, 2017
2 parents 7ade24f + 0d53ecd commit 7f6417e
Show file tree
Hide file tree
Showing 22 changed files with 479 additions and 74 deletions.
7 changes: 5 additions & 2 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ install!((self, builder, _config),
install_cargo(builder, self.stage, self.target);
};
Rls, "rls", _config.extended, only_hosts: true, {
builder.ensure(dist::Rls { stage: self.stage, target: self.target });
install_rls(builder, self.stage, self.target);
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() {
install_rls(builder, self.stage, self.target);
} else {
println!("skipping Install RLS stage{} ({})", self.stage, self.target);
}
};
Analysis, "analysis", _config.extended, only_hosts: false, {
builder.ensure(dist::Analysis {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/not_found.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Some things that might be helpful to you though:
# Reference

* [The Rust official site](https://www.rust-lang.org)
* [The Rust reference](https://doc.rust-lang.org/reference.html)
* [The Rust reference](https://doc.rust-lang.org/reference/index.html)

# Docs

Expand Down
9 changes: 9 additions & 0 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,15 @@ impl<'a> State<'a> {
Fixity::None => (prec + 1, prec + 1),
};

let left_prec = match (&lhs.node, op.node) {
// These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is
// the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead
// of `(x as i32) < ...`. We need to convince it _not_ to do that.
(&hir::ExprCast { .. }, hir::BinOp_::BiLt) |
(&hir::ExprCast { .. }, hir::BinOp_::BiShl) => parser::PREC_FORCE_PAREN,
_ => left_prec,
};

self.print_expr_maybe_paren(lhs, left_prec)?;
self.s.space()?;
self.word_space(op.node.as_str())?;
Expand Down
55 changes: 36 additions & 19 deletions src/librustc/infer/error_reporting/different_lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,42 @@ use hir::intravisit::{self, Visitor, NestedVisitorMap};
use infer::error_reporting::util::AnonymousArgInfo;

impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// This method prints the error message for lifetime errors when both the concerned regions
// are anonymous.
// Consider a case where we have
// fn foo(x: &mut Vec<&u8>, y: &u8)
// { x.push(y); }.
// The example gives
// fn foo(x: &mut Vec<&u8>, y: &u8) {
// --- --- these references are declared with different lifetimes...
// x.push(y);
// ^ ...but data from `y` flows into `x` here
// It has been extended for the case of structs too.
// Consider the example
// struct Ref<'a> { x: &'a u32 }
// fn foo(mut x: Vec<Ref>, y: Ref) {
// --- --- these structs are declared with different lifetimes...
// x.push(y);
// ^ ...but data from `y` flows into `x` here
// }
// It will later be extended to trait objects.
/// Print the error message for lifetime errors when both the concerned regions are anonymous.
///
/// Consider a case where we have
///
/// ```no_run
/// fn foo(x: &mut Vec<&u8>, y: &u8) {
/// x.push(y);
/// }
/// ```
///
/// The example gives
///
/// ```text
/// fn foo(x: &mut Vec<&u8>, y: &u8) {
/// --- --- these references are declared with different lifetimes...
/// x.push(y);
/// ^ ...but data from `y` flows into `x` here
/// ```
///
/// It has been extended for the case of structs too.
///
/// Consider the example
///
/// ```no_run
/// struct Ref<'a> { x: &'a u32 }
/// ```
///
/// ```text
/// fn foo(mut x: Vec<Ref>, y: Ref) {
/// --- --- these structs are declared with different lifetimes...
/// x.push(y);
/// ^ ...but data from `y` flows into `x` here
/// }
/// ````
///
/// It will later be extended to trait objects.
pub fn try_report_anon_anon_conflict(&self, error: &RegionResolutionError<'tcx>) -> bool {
let (span, sub, sup) = match *error {
ConcreteFailure(ref origin, sub, sup) => (origin.span(), sub, sup),
Expand Down
16 changes: 5 additions & 11 deletions src/librustc/infer/error_reporting/named_anon_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ use infer::region_inference::RegionResolutionError;
use ty;

impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// This method generates the error message for the case when
// the function arguments consist of a named region and an anonymous
// region and corresponds to `ConcreteFailure(..)`
/// When given a `ConcreteFailure` for a function with arguments containing a named region and
/// an anonymous region, emit an descriptive diagnostic error.
pub fn try_report_named_anon_conflict(&self, error: &RegionResolutionError<'tcx>) -> bool {
let (span, sub, sup) = match *error {
ConcreteFailure(ref origin, sub, sup) => (origin.span(), sub, sup),
_ => return false, // inapplicable
};

debug!("try_report_named_anon_conflict(sub={:?}, sup={:?})",
sub,
sup);
debug!("try_report_named_anon_conflict(sub={:?}, sup={:?})", sub, sup);

// Determine whether the sub and sup consist of one named region ('a)
// and one anonymous (elided) region. If so, find the parameter arg
Expand All @@ -53,10 +50,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
};

debug!("try_report_named_anon_conflict: named = {:?}", named);
debug!("try_report_named_anon_conflict: anon_arg_info = {:?}",
anon_arg_info);
debug!("try_report_named_anon_conflict: region_info = {:?}",
region_info);
debug!("try_report_named_anon_conflict: anon_arg_info = {:?}", anon_arg_info);
debug!("try_report_named_anon_conflict: region_info = {:?}", region_info);

let (arg, new_ty, br, is_first, scope_def_id, is_impl_item) = (anon_arg_info.arg,
anon_arg_info.arg_ty,
Expand Down Expand Up @@ -101,6 +96,5 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
.span_label(span, format!("lifetime `{}` required", named))
.emit();
return true;

}
}
1 change: 1 addition & 0 deletions src/librustc/infer/error_reporting/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
_ => false,
}
}
ty::ReEarlyBound(_) => true,
_ => false,
}
}
Expand Down
48 changes: 35 additions & 13 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,34 @@ impl OutputType {
}
}

fn from_shorthand(shorthand: &str) -> Option<Self> {
Some(match shorthand {
"asm" => OutputType::Assembly,
"llvm-ir" => OutputType::LlvmAssembly,
"mir" => OutputType::Mir,
"llvm-bc" => OutputType::Bitcode,
"obj" => OutputType::Object,
"metadata" => OutputType::Metadata,
"link" => OutputType::Exe,
"dep-info" => OutputType::DepInfo,
_ => return None,
})
}

fn shorthands_display() -> String {
format!(
"`{}`, `{}`, `{}`, `{}`, `{}`, `{}`, `{}`, `{}`",
OutputType::Bitcode.shorthand(),
OutputType::Assembly.shorthand(),
OutputType::LlvmAssembly.shorthand(),
OutputType::Mir.shorthand(),
OutputType::Object.shorthand(),
OutputType::Metadata.shorthand(),
OutputType::Exe.shorthand(),
OutputType::DepInfo.shorthand(),
)
}

pub fn extension(&self) -> &'static str {
match *self {
OutputType::Bitcode => "bc",
Expand Down Expand Up @@ -1488,19 +1516,13 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
for list in matches.opt_strs("emit") {
for output_type in list.split(',') {
let mut parts = output_type.splitn(2, '=');
let output_type = match parts.next().unwrap() {
"asm" => OutputType::Assembly,
"llvm-ir" => OutputType::LlvmAssembly,
"mir" => OutputType::Mir,
"llvm-bc" => OutputType::Bitcode,
"obj" => OutputType::Object,
"metadata" => OutputType::Metadata,
"link" => OutputType::Exe,
"dep-info" => OutputType::DepInfo,
part => {
early_error(error_format, &format!("unknown emission type: `{}`",
part))
}
let shorthand = parts.next().unwrap();
let output_type = match OutputType::from_shorthand(shorthand) {
Some(output_type) => output_type,
None => early_error(error_format, &format!(
"unknown emission type: `{}` - expected one of: {}",
shorthand, OutputType::shorthands_display(),
)),
};
let path = parts.next().map(PathBuf::from);
output_types.insert(output_type, path);
Expand Down
16 changes: 12 additions & 4 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,23 @@ pub fn make_test(s: &str,

let mut prog = String::new();

// First push any outer attributes from the example, assuming they
// are intended to be crate attributes.
prog.push_str(&crate_attrs);
if opts.attrs.is_empty() {
// If there aren't any attributes supplied by #![doc(test(attr(...)))], then allow some
// lints that are commonly triggered in doctests. The crate-level test attributes are
// commonly used to make tests fail in case they trigger warnings, so having this there in
// that case may cause some tests to pass when they shouldn't have.
prog.push_str("#![allow(unused)]\n");
}

// Next, any attributes for other aspects such as lints.
// Next, any attributes that came from the crate root via #![doc(test(attr(...)))].
for attr in &opts.attrs {
prog.push_str(&format!("#![{}]\n", attr));
}

// Now push any outer attributes from the example, assuming they
// are intended to be crate attributes.
prog.push_str(&crate_attrs);

// Don't inject `extern crate std` because it's already injected by the
// compiler.
if !s.contains("extern crate") && !opts.no_crate_inject && cratename != Some("std") {
Expand Down
11 changes: 8 additions & 3 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use cell::UnsafeCell;
use fmt;
use marker;
use mem;
use ops::{Deref, DerefMut};
use ptr;
Expand Down Expand Up @@ -102,7 +101,10 @@ pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized> !marker::Send for RwLockReadGuard<'a, T> {}
impl<'a, T: ?Sized> !Send for RwLockReadGuard<'a, T> {}

#[stable(feature = "rwlock_guard_sync", since = "1.23.0")]
unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockReadGuard<'a, T> {}

/// RAII structure used to release the exclusive write access of a lock when
/// dropped.
Expand All @@ -121,7 +123,10 @@ pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized> !marker::Send for RwLockWriteGuard<'a, T> {}
impl<'a, T: ?Sized> !Send for RwLockWriteGuard<'a, T> {}

#[stable(feature = "rwlock_guard_sync", since = "1.23.0")]
unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockWriteGuard<'a, T> {}

impl<T> RwLock<T> {
/// Creates a new instance of an `RwLock<T>` which is unlocked.
Expand Down
Loading

0 comments on commit 7f6417e

Please sign in to comment.