Skip to content

Commit 744e696

Browse files
committed
Auto merge of #40446 - arielb1:rollup, r=alexcrichton
Rollup of 12 pull requests - Successful merges: #40146, #40299, #40315, #40319, #40344, #40345, #40372, #40373, #40400, #40404, #40419, #40431 - Failed merges:
2 parents 1b19284 + 6a5fd0f commit 744e696

40 files changed

+527
-232
lines changed

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ matrix:
4646
RUST_CONFIGURE_ARGS=--build=x86_64-apple-darwin
4747
SRC=.
4848
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
49+
SCCACHE_ERROR_LOG=/tmp/sccache.log
50+
RUST_LOG=sccache
4951
os: osx
5052
osx_image: xcode8.2
5153
install: &osx_install_sccache >
@@ -56,6 +58,8 @@ matrix:
5658
RUST_CONFIGURE_ARGS=--build=i686-apple-darwin
5759
SRC=.
5860
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
61+
SCCACHE_ERROR_LOG=/tmp/sccache.log
62+
RUST_LOG=sccache
5963
os: osx
6064
osx_image: xcode8.2
6165
install: *osx_install_sccache
@@ -66,6 +70,8 @@ matrix:
6670
SRC=.
6771
DEPLOY=1
6872
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
73+
SCCACHE_ERROR_LOG=/tmp/sccache.log
74+
RUST_LOG=sccache
6975
os: osx
7076
osx_image: xcode8.2
7177
install: >
@@ -77,6 +83,8 @@ matrix:
7783
SRC=.
7884
DEPLOY=1
7985
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
86+
SCCACHE_ERROR_LOG=/tmp/sccache.log
87+
RUST_LOG=sccache
8088
os: osx
8189
osx_image: xcode8.2
8290
install: *osx_install_sccache
@@ -92,6 +100,8 @@ matrix:
92100
SRC=.
93101
DEPLOY_ALT=1
94102
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
103+
SCCACHE_ERROR_LOG=/tmp/sccache.log
104+
RUST_LOG=sccache
95105
os: osx
96106
osx_image: xcode8.2
97107
install: *osx_install_sccache
@@ -133,6 +143,7 @@ after_failure:
133143
df -h;
134144
du . | sort -nr | head -n100
135145
- cat obj/tmp/sccache.log
146+
- cat /tmp/sccache.log
136147

137148
# Save tagged docker images we created and load them if they're available
138149
before_cache:

appveyor.yml

+7
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,19 @@ install:
130130
- set PATH=%PATH%;%CD%\handle
131131
- handle.exe -accepteula -help
132132

133+
# Attempt to debug sccache failures
134+
- set RUST_LOG=sccache
135+
- set SCCACHE_ERROR_LOG=%CD%/sccache.log
136+
133137
test_script:
134138
- appveyor-retry sh -c 'git submodule deinit -f . && git submodule update --init'
135139
- set SRC=.
136140
- set NO_CCACHE=1
137141
- sh src/ci/run.sh
138142

143+
on_failure:
144+
- cat %CD%/sccache.log
145+
139146
cache:
140147
- "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
141148
- "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"

src/libcore/fmt/mod.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,26 @@ pub trait Debug {
529529
#[stable(feature = "rust1", since = "1.0.0")]
530530
pub trait Display {
531531
/// Formats the value using the given formatter.
532+
///
533+
/// # Examples
534+
///
535+
/// ```
536+
/// use std::fmt;
537+
///
538+
/// struct Position {
539+
/// longitude: f32,
540+
/// latitude: f32,
541+
/// }
542+
///
543+
/// impl fmt::Display for Position {
544+
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
545+
/// write!(f, "({}, {})", self.longitude, self.latitude)
546+
/// }
547+
/// }
548+
///
549+
/// assert_eq!("(1.987, 2.983)".to_owned(),
550+
/// format!("{}", Position { longitude: 1.987, latitude: 2.983, }));
551+
/// ```
532552
#[stable(feature = "rust1", since = "1.0.0")]
533553
fn fmt(&self, f: &mut Formatter) -> Result;
534554
}
@@ -930,7 +950,6 @@ pub fn write(output: &mut Write, args: Arguments) -> Result {
930950
}
931951

932952
impl<'a> Formatter<'a> {
933-
934953
// First up is the collection of functions used to execute a format string
935954
// at runtime. This consumes all of the compile-time statics generated by
936955
// the format! syntax extension.

src/librustc/infer/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ course, it depends on the program.
152152

153153
The main case which fails today that I would like to support is:
154154

155-
```text
155+
```rust
156156
fn foo<T>(x: T, y: T) { ... }
157157

158158
fn bar() {
@@ -168,6 +168,8 @@ because the type variable `T` is merged with the type variable for
168168
`X`, and thus inherits its UB/LB of `@mut int`. This leaves no
169169
flexibility for `T` to later adjust to accommodate `@int`.
170170

171+
Note: `@` and `@mut` are replaced with `Rc<T>` and `Rc<RefCell<T>>` in current Rust.
172+
171173
### What to do when not all bounds are present
172174

173175
In the prior discussion we assumed that A.ub was not top and B.lb was

src/librustc/infer/region_inference/README.md

+59-49
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,19 @@ every expression, block, and pattern (patterns are considered to
121121
"execute" by testing the value they are applied to and creating any
122122
relevant bindings). So, for example:
123123

124-
fn foo(x: isize, y: isize) { // -+
125-
// +------------+ // |
126-
// | +-----+ // |
127-
// | +-+ +-+ +-+ // |
128-
// | | | | | | | // |
129-
// v v v v v v v // |
130-
let z = x + y; // |
131-
... // |
132-
} // -+
133-
134-
fn bar() { ... }
124+
```rust
125+
fn foo(x: isize, y: isize) { // -+
126+
// +------------+ // |
127+
// | +-----+ // |
128+
// | +-+ +-+ +-+ // |
129+
// | | | | | | | // |
130+
// v v v v v v v // |
131+
let z = x + y; // |
132+
... // |
133+
} // -+
134+
135+
fn bar() { ... }
136+
```
135137

136138
In this example, there is a region for the fn body block as a whole,
137139
and then a subregion for the declaration of the local variable.
@@ -160,28 +162,32 @@ this, we get a lot of spurious errors around nested calls, in
160162
particular when combined with `&mut` functions. For example, a call
161163
like this one
162164

163-
self.foo(self.bar())
165+
```rust
166+
self.foo(self.bar())
167+
```
164168

165169
where both `foo` and `bar` are `&mut self` functions will always yield
166170
an error.
167171

168172
Here is a more involved example (which is safe) so we can see what's
169173
going on:
170174

171-
struct Foo { f: usize, g: usize }
172-
...
173-
fn add(p: &mut usize, v: usize) {
174-
*p += v;
175-
}
176-
...
177-
fn inc(p: &mut usize) -> usize {
178-
*p += 1; *p
179-
}
180-
fn weird() {
181-
let mut x: Box<Foo> = box Foo { ... };
182-
'a: add(&mut (*x).f,
183-
'b: inc(&mut (*x).f)) // (..)
184-
}
175+
```rust
176+
struct Foo { f: usize, g: usize }
177+
// ...
178+
fn add(p: &mut usize, v: usize) {
179+
*p += v;
180+
}
181+
// ...
182+
fn inc(p: &mut usize) -> usize {
183+
*p += 1; *p
184+
}
185+
fn weird() {
186+
let mut x: Box<Foo> = box Foo { /* ... */ };
187+
'a: add(&mut (*x).f,
188+
'b: inc(&mut (*x).f)) // (..)
189+
}
190+
```
185191

186192
The important part is the line marked `(..)` which contains a call to
187193
`add()`. The first argument is a mutable borrow of the field `f`. The
@@ -197,16 +203,18 @@ can see that this error is unnecessary. Let's examine the lifetimes
197203
involved with `'a` in detail. We'll break apart all the steps involved
198204
in a call expression:
199205

200-
'a: {
201-
'a_arg1: let a_temp1: ... = add;
202-
'a_arg2: let a_temp2: &'a mut usize = &'a mut (*x).f;
203-
'a_arg3: let a_temp3: usize = {
204-
let b_temp1: ... = inc;
205-
let b_temp2: &'b = &'b mut (*x).f;
206-
'b_call: b_temp1(b_temp2)
207-
};
208-
'a_call: a_temp1(a_temp2, a_temp3) // (**)
209-
}
206+
```rust
207+
'a: {
208+
'a_arg1: let a_temp1: ... = add;
209+
'a_arg2: let a_temp2: &'a mut usize = &'a mut (*x).f;
210+
'a_arg3: let a_temp3: usize = {
211+
let b_temp1: ... = inc;
212+
let b_temp2: &'b = &'b mut (*x).f;
213+
'b_call: b_temp1(b_temp2)
214+
};
215+
'a_call: a_temp1(a_temp2, a_temp3) // (**)
216+
}
217+
```
210218

211219
Here we see that the lifetime `'a` includes a number of substatements.
212220
In particular, there is this lifetime I've called `'a_call` that
@@ -225,19 +233,21 @@ it will not be *dereferenced* during the evaluation of the second
225233
argument, it can still be *invalidated* by that evaluation. Consider
226234
this similar but unsound example:
227235

228-
struct Foo { f: usize, g: usize }
229-
...
230-
fn add(p: &mut usize, v: usize) {
231-
*p += v;
232-
}
233-
...
234-
fn consume(x: Box<Foo>) -> usize {
235-
x.f + x.g
236-
}
237-
fn weird() {
238-
let mut x: Box<Foo> = box Foo { ... };
239-
'a: add(&mut (*x).f, consume(x)) // (..)
240-
}
236+
```rust
237+
struct Foo { f: usize, g: usize }
238+
// ...
239+
fn add(p: &mut usize, v: usize) {
240+
*p += v;
241+
}
242+
// ...
243+
fn consume(x: Box<Foo>) -> usize {
244+
x.f + x.g
245+
}
246+
fn weird() {
247+
let mut x: Box<Foo> = box Foo { ... };
248+
'a: add(&mut (*x).f, consume(x)) // (..)
249+
}
250+
```
241251

242252
In this case, the second argument to `add` actually consumes `x`, thus
243253
invalidating the first argument.

src/librustc/infer/region_inference/graphviz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>(
9191
};
9292

9393
if output_template.is_empty() {
94-
bug!("empty string provided as RUST_REGION_GRAPH");
94+
panic!("empty string provided as RUST_REGION_GRAPH");
9595
}
9696

9797
if output_template.contains('%') {

src/librustc/lint/context.rs

+6
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,12 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
806806
self.tables = old_tables;
807807
}
808808

809+
fn visit_body(&mut self, body: &'tcx hir::Body) {
810+
run_lints!(self, check_body, late_passes, body);
811+
hir_visit::walk_body(self, body);
812+
run_lints!(self, check_body_post, late_passes, body);
813+
}
814+
809815
fn visit_item(&mut self, it: &'tcx hir::Item) {
810816
self.with_lint_attrs(&it.attrs, |cx| {
811817
run_lints!(cx, check_item, late_passes, it);

src/librustc/lint/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ pub trait LintPass {
133133
// FIXME: eliminate the duplication with `Visitor`. But this also
134134
// contains a few lint-specific methods with no equivalent in `Visitor`.
135135
pub trait LateLintPass<'a, 'tcx>: LintPass {
136+
fn check_body(&mut self, _: &LateContext, _: &'tcx hir::Body) { }
137+
fn check_body_post(&mut self, _: &LateContext, _: &'tcx hir::Body) { }
136138
fn check_name(&mut self, _: &LateContext, _: Span, _: ast::Name) { }
137139
fn check_crate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
138140
fn check_crate_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }

src/librustc/traits/error_reporting.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,26 @@ use super::{
2323
ObjectSafetyViolation,
2424
};
2525

26+
use errors::DiagnosticBuilder;
2627
use fmt_macros::{Parser, Piece, Position};
28+
use hir::{intravisit, Local, Pat};
29+
use hir::intravisit::{Visitor, NestedVisitorMap};
30+
use hir::map::NodeExpr;
2731
use hir::def_id::DefId;
2832
use infer::{self, InferCtxt};
2933
use infer::type_variable::TypeVariableOrigin;
3034
use rustc::lint::builtin::EXTRA_REQUIREMENT_IN_IMPL;
35+
use std::fmt;
36+
use syntax::ast;
3137
use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable};
3238
use ty::error::ExpectedFound;
3339
use ty::fast_reject;
3440
use ty::fold::TypeFolder;
3541
use ty::subst::Subst;
3642
use util::nodemap::{FxHashMap, FxHashSet};
3743

38-
use std::fmt;
39-
use syntax::ast;
40-
use hir::{intravisit, Local, Pat};
41-
use hir::intravisit::{Visitor, NestedVisitorMap};
4244
use syntax_pos::{DUMMY_SP, Span};
43-
use errors::DiagnosticBuilder;
45+
4446

4547
#[derive(Debug, PartialEq, Eq, Hash)]
4648
pub struct TraitErrorKey<'tcx> {
@@ -848,15 +850,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
848850

849851
err.span_label(cause.span, &format!("cannot infer type for `{}`", name));
850852

851-
let expr = self.tcx.hir.expect_expr(cause.body_id);
852-
853853
let mut local_visitor = FindLocalByTypeVisitor {
854854
infcx: &self,
855855
target_ty: &ty,
856856
found_pattern: None,
857857
};
858858

859-
local_visitor.visit_expr(expr);
859+
// #40294: cause.body_id can also be a fn declaration.
860+
// Currently, if it's anything other than NodeExpr, we just ignore it
861+
match self.tcx.hir.find(cause.body_id) {
862+
Some(NodeExpr(expr)) => local_visitor.visit_expr(expr),
863+
_ => ()
864+
}
860865

861866
if let Some(pattern) = local_visitor.found_pattern {
862867
let pattern_span = pattern.span;

src/librustc/traits/select.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
24612461
let new_trait = tcx.mk_dynamic(
24622462
ty::Binder(tcx.mk_existential_predicates(iter)), r_b);
24632463
let InferOk { obligations, .. } =
2464-
self.infcx.sub_types(false, &obligation.cause, new_trait, target)
2464+
self.infcx.eq_types(false, &obligation.cause, new_trait, target)
24652465
.map_err(|_| Unimplemented)?;
24662466
self.inferred_obligations.extend(obligations);
24672467

@@ -2520,7 +2520,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25202520
// [T; n] -> [T].
25212521
(&ty::TyArray(a, _), &ty::TySlice(b)) => {
25222522
let InferOk { obligations, .. } =
2523-
self.infcx.sub_types(false, &obligation.cause, a, b)
2523+
self.infcx.eq_types(false, &obligation.cause, a, b)
25242524
.map_err(|_| Unimplemented)?;
25252525
self.inferred_obligations.extend(obligations);
25262526
}
@@ -2583,7 +2583,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25832583
});
25842584
let new_struct = tcx.mk_adt(def, tcx.mk_substs(params));
25852585
let InferOk { obligations, .. } =
2586-
self.infcx.sub_types(false, &obligation.cause, new_struct, target)
2586+
self.infcx.eq_types(false, &obligation.cause, new_struct, target)
25872587
.map_err(|_| Unimplemented)?;
25882588
self.inferred_obligations.extend(obligations);
25892589

src/librustc_driver/target_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "vfp2\0", "vfp3\0", "
2525
const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bmi2\0", "sse\0",
2626
"sse2\0", "sse3\0", "sse4.1\0", "sse4.2\0",
2727
"ssse3\0", "tbm\0", "lzcnt\0", "popcnt\0",
28-
"sse4a\0", "rdrnd\0", "rdseed\0"];
28+
"sse4a\0", "rdrnd\0", "rdseed\0", "fma\0"];
2929

3030
/// Add `target_feature = "..."` cfgs for a variety of platform
3131
/// specific features (SSE, NEON etc.).

src/librustc_mir/build/expr/as_temp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
5555
(https://github.com/rust-lang/rust/issues/39283)");
5656
}
5757

58-
if temp_lifetime.is_some() {
58+
if !expr_ty.is_never() && temp_lifetime.is_some() {
5959
this.cfg.push(block, Statement {
6060
source_info: source_info,
6161
kind: StatementKind::StorageLive(temp.clone())

0 commit comments

Comments
 (0)