Skip to content

Commit 7f6417e

Browse files
committed
Auto merge of #45822 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests - Successful merges: #45470, #45588, #45682, #45714, #45751, #45764, #45778, #45782, #45784 - Failed merges:
2 parents 7ade24f + 0d53ecd commit 7f6417e

22 files changed

+479
-74
lines changed

src/bootstrap/install.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,11 @@ install!((self, builder, _config),
186186
install_cargo(builder, self.stage, self.target);
187187
};
188188
Rls, "rls", _config.extended, only_hosts: true, {
189-
builder.ensure(dist::Rls { stage: self.stage, target: self.target });
190-
install_rls(builder, self.stage, self.target);
189+
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() {
190+
install_rls(builder, self.stage, self.target);
191+
} else {
192+
println!("skipping Install RLS stage{} ({})", self.stage, self.target);
193+
}
191194
};
192195
Analysis, "analysis", _config.extended, only_hosts: false, {
193196
builder.ensure(dist::Analysis {

src/doc/not_found.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Some things that might be helpful to you though:
2222
# Reference
2323

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

2727
# Docs
2828

src/librustc/hir/print.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,15 @@ impl<'a> State<'a> {
12541254
Fixity::None => (prec + 1, prec + 1),
12551255
};
12561256

1257+
let left_prec = match (&lhs.node, op.node) {
1258+
// These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is
1259+
// the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead
1260+
// of `(x as i32) < ...`. We need to convince it _not_ to do that.
1261+
(&hir::ExprCast { .. }, hir::BinOp_::BiLt) |
1262+
(&hir::ExprCast { .. }, hir::BinOp_::BiShl) => parser::PREC_FORCE_PAREN,
1263+
_ => left_prec,
1264+
};
1265+
12571266
self.print_expr_maybe_paren(lhs, left_prec)?;
12581267
self.s.space()?;
12591268
self.word_space(op.node.as_str())?;

src/librustc/infer/error_reporting/different_lifetimes.rs

+36-19
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,42 @@ use hir::intravisit::{self, Visitor, NestedVisitorMap};
2121
use infer::error_reporting::util::AnonymousArgInfo;
2222

2323
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
24-
// This method prints the error message for lifetime errors when both the concerned regions
25-
// are anonymous.
26-
// Consider a case where we have
27-
// fn foo(x: &mut Vec<&u8>, y: &u8)
28-
// { x.push(y); }.
29-
// The example gives
30-
// fn foo(x: &mut Vec<&u8>, y: &u8) {
31-
// --- --- these references are declared with different lifetimes...
32-
// x.push(y);
33-
// ^ ...but data from `y` flows into `x` here
34-
// It has been extended for the case of structs too.
35-
// Consider the example
36-
// struct Ref<'a> { x: &'a u32 }
37-
// fn foo(mut x: Vec<Ref>, y: Ref) {
38-
// --- --- these structs are declared with different lifetimes...
39-
// x.push(y);
40-
// ^ ...but data from `y` flows into `x` here
41-
// }
42-
// It will later be extended to trait objects.
24+
/// Print the error message for lifetime errors when both the concerned regions are anonymous.
25+
///
26+
/// Consider a case where we have
27+
///
28+
/// ```no_run
29+
/// fn foo(x: &mut Vec<&u8>, y: &u8) {
30+
/// x.push(y);
31+
/// }
32+
/// ```
33+
///
34+
/// The example gives
35+
///
36+
/// ```text
37+
/// fn foo(x: &mut Vec<&u8>, y: &u8) {
38+
/// --- --- these references are declared with different lifetimes...
39+
/// x.push(y);
40+
/// ^ ...but data from `y` flows into `x` here
41+
/// ```
42+
///
43+
/// It has been extended for the case of structs too.
44+
///
45+
/// Consider the example
46+
///
47+
/// ```no_run
48+
/// struct Ref<'a> { x: &'a u32 }
49+
/// ```
50+
///
51+
/// ```text
52+
/// fn foo(mut x: Vec<Ref>, y: Ref) {
53+
/// --- --- these structs are declared with different lifetimes...
54+
/// x.push(y);
55+
/// ^ ...but data from `y` flows into `x` here
56+
/// }
57+
/// ````
58+
///
59+
/// It will later be extended to trait objects.
4360
pub fn try_report_anon_anon_conflict(&self, error: &RegionResolutionError<'tcx>) -> bool {
4461
let (span, sub, sup) = match *error {
4562
ConcreteFailure(ref origin, sub, sup) => (origin.span(), sub, sup),

src/librustc/infer/error_reporting/named_anon_conflict.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ use infer::region_inference::RegionResolutionError;
1616
use ty;
1717

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

28-
debug!("try_report_named_anon_conflict(sub={:?}, sup={:?})",
29-
sub,
30-
sup);
27+
debug!("try_report_named_anon_conflict(sub={:?}, sup={:?})", sub, sup);
3128

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

5552
debug!("try_report_named_anon_conflict: named = {:?}", named);
56-
debug!("try_report_named_anon_conflict: anon_arg_info = {:?}",
57-
anon_arg_info);
58-
debug!("try_report_named_anon_conflict: region_info = {:?}",
59-
region_info);
53+
debug!("try_report_named_anon_conflict: anon_arg_info = {:?}", anon_arg_info);
54+
debug!("try_report_named_anon_conflict: region_info = {:?}", region_info);
6055

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

src/librustc/infer/error_reporting/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
221221
_ => false,
222222
}
223223
}
224+
ty::ReEarlyBound(_) => true,
224225
_ => false,
225226
}
226227
}

src/librustc/session/config.rs

+35-13
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,34 @@ impl OutputType {
138138
}
139139
}
140140

141+
fn from_shorthand(shorthand: &str) -> Option<Self> {
142+
Some(match shorthand {
143+
"asm" => OutputType::Assembly,
144+
"llvm-ir" => OutputType::LlvmAssembly,
145+
"mir" => OutputType::Mir,
146+
"llvm-bc" => OutputType::Bitcode,
147+
"obj" => OutputType::Object,
148+
"metadata" => OutputType::Metadata,
149+
"link" => OutputType::Exe,
150+
"dep-info" => OutputType::DepInfo,
151+
_ => return None,
152+
})
153+
}
154+
155+
fn shorthands_display() -> String {
156+
format!(
157+
"`{}`, `{}`, `{}`, `{}`, `{}`, `{}`, `{}`, `{}`",
158+
OutputType::Bitcode.shorthand(),
159+
OutputType::Assembly.shorthand(),
160+
OutputType::LlvmAssembly.shorthand(),
161+
OutputType::Mir.shorthand(),
162+
OutputType::Object.shorthand(),
163+
OutputType::Metadata.shorthand(),
164+
OutputType::Exe.shorthand(),
165+
OutputType::DepInfo.shorthand(),
166+
)
167+
}
168+
141169
pub fn extension(&self) -> &'static str {
142170
match *self {
143171
OutputType::Bitcode => "bc",
@@ -1488,19 +1516,13 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
14881516
for list in matches.opt_strs("emit") {
14891517
for output_type in list.split(',') {
14901518
let mut parts = output_type.splitn(2, '=');
1491-
let output_type = match parts.next().unwrap() {
1492-
"asm" => OutputType::Assembly,
1493-
"llvm-ir" => OutputType::LlvmAssembly,
1494-
"mir" => OutputType::Mir,
1495-
"llvm-bc" => OutputType::Bitcode,
1496-
"obj" => OutputType::Object,
1497-
"metadata" => OutputType::Metadata,
1498-
"link" => OutputType::Exe,
1499-
"dep-info" => OutputType::DepInfo,
1500-
part => {
1501-
early_error(error_format, &format!("unknown emission type: `{}`",
1502-
part))
1503-
}
1519+
let shorthand = parts.next().unwrap();
1520+
let output_type = match OutputType::from_shorthand(shorthand) {
1521+
Some(output_type) => output_type,
1522+
None => early_error(error_format, &format!(
1523+
"unknown emission type: `{}` - expected one of: {}",
1524+
shorthand, OutputType::shorthands_display(),
1525+
)),
15041526
};
15051527
let path = parts.next().map(PathBuf::from);
15061528
output_types.insert(output_type, path);

src/librustdoc/test.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,23 @@ pub fn make_test(s: &str,
337337

338338
let mut prog = String::new();
339339

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

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

353+
// Now push any outer attributes from the example, assuming they
354+
// are intended to be crate attributes.
355+
prog.push_str(&crate_attrs);
356+
349357
// Don't inject `extern crate std` because it's already injected by the
350358
// compiler.
351359
if !s.contains("extern crate") && !opts.no_crate_inject && cratename != Some("std") {

src/libstd/sync/rwlock.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use cell::UnsafeCell;
1212
use fmt;
13-
use marker;
1413
use mem;
1514
use ops::{Deref, DerefMut};
1615
use ptr;
@@ -102,7 +101,10 @@ pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
102101
}
103102

104103
#[stable(feature = "rust1", since = "1.0.0")]
105-
impl<'a, T: ?Sized> !marker::Send for RwLockReadGuard<'a, T> {}
104+
impl<'a, T: ?Sized> !Send for RwLockReadGuard<'a, T> {}
105+
106+
#[stable(feature = "rwlock_guard_sync", since = "1.23.0")]
107+
unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockReadGuard<'a, T> {}
106108

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

123125
#[stable(feature = "rust1", since = "1.0.0")]
124-
impl<'a, T: ?Sized> !marker::Send for RwLockWriteGuard<'a, T> {}
126+
impl<'a, T: ?Sized> !Send for RwLockWriteGuard<'a, T> {}
127+
128+
#[stable(feature = "rwlock_guard_sync", since = "1.23.0")]
129+
unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockWriteGuard<'a, T> {}
125130

126131
impl<T> RwLock<T> {
127132
/// Creates a new instance of an `RwLock<T>` which is unlocked.

0 commit comments

Comments
 (0)