Skip to content

Commit 744e696

Browse files
committedMar 12, 2017
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())

‎src/librustc_save_analysis/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
395395
}
396396
}
397397
None => {
398-
span_bug!(span, "Could not find container for method {}", id);
398+
debug!("Could not find container for method {} at {:?}", id, span);
399+
// This is not necessarily a bug, if there was a compilation error, the tables
400+
// we need might not exist.
401+
return None;
399402
}
400403
},
401404
};

‎src/librustc_typeck/check/autoderef.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use astconv::AstConv;
1212

1313
use super::FnCtxt;
1414

15+
use rustc::infer::InferOk;
1516
use rustc::traits;
1617
use rustc::ty::{self, Ty, TraitRef};
1718
use rustc::ty::{ToPredicate, TypeFoldable};
@@ -149,6 +150,14 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
149150

150151
pub fn finalize<'b, I>(self, pref: LvaluePreference, exprs: I)
151152
where I: IntoIterator<Item = &'b hir::Expr>
153+
{
154+
let fcx = self.fcx;
155+
fcx.register_infer_ok_obligations(self.finalize_as_infer_ok(pref, exprs));
156+
}
157+
158+
pub fn finalize_as_infer_ok<'b, I>(self, pref: LvaluePreference, exprs: I)
159+
-> InferOk<'tcx, ()>
160+
where I: IntoIterator<Item = &'b hir::Expr>
152161
{
153162
let methods: Vec<_> = self.steps
154163
.iter()
@@ -176,8 +185,9 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
176185
}
177186
}
178187

179-
for obligation in self.obligations {
180-
self.fcx.register_predicate(obligation);
188+
InferOk {
189+
value: (),
190+
obligations: self.obligations
181191
}
182192
}
183193
}

‎src/librustc_typeck/check/coercion.rs

+102-112
Large diffs are not rendered by default.

‎src/librustdoc/html/format.rs

+47-19
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
442442
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
443443
/// rendering function with the necessary arguments for linking to a local path.
444444
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
445-
print_all: bool, use_absolute: bool) -> fmt::Result {
445+
print_all: bool, use_absolute: bool, is_not_debug: bool) -> fmt::Result {
446446
let last = path.segments.last().unwrap();
447447
let rel_root = match &*path.segments[0].name {
448448
"self" => Some("./".to_string()),
@@ -459,10 +459,14 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
459459
} else {
460460
root.push_str(&seg.name);
461461
root.push_str("/");
462-
write!(w, "<a class=\"mod\"
463-
href=\"{}index.html\">{}</a>::",
464-
root,
465-
seg.name)?;
462+
if is_not_debug {
463+
write!(w, "<a class=\"mod\"
464+
href=\"{}index.html\">{}</a>::",
465+
root,
466+
seg.name)?;
467+
} else {
468+
write!(w, "{}::", seg.name)?;
469+
}
466470
}
467471
}
468472
}
@@ -474,19 +478,37 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
474478
}
475479
}
476480
if w.alternate() {
477-
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
481+
if is_not_debug {
482+
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
483+
} else {
484+
write!(w, "{:?}{:?}", HRef::new(did, &last.name), last.params)?;
485+
}
478486
} else {
479-
let path = if use_absolute {
480-
match href(did) {
481-
Some((_, _, fqp)) => format!("{}::{}",
482-
fqp[..fqp.len()-1].join("::"),
483-
HRef::new(did, fqp.last().unwrap())),
484-
None => format!("{}", HRef::new(did, &last.name)),
485-
}
487+
if is_not_debug {
488+
let path = if use_absolute {
489+
match href(did) {
490+
Some((_, _, fqp)) => format!("{}::{}",
491+
fqp[..fqp.len()-1].join("::"),
492+
HRef::new(did, fqp.last().unwrap())),
493+
None => format!("{}", HRef::new(did, &last.name)),
494+
}
495+
} else {
496+
format!("{}", HRef::new(did, &last.name))
497+
};
498+
write!(w, "{}{}", path, last.params)?;
486499
} else {
487-
format!("{}", HRef::new(did, &last.name))
488-
};
489-
write!(w, "{}{}", path, last.params)?;
500+
let path = if use_absolute {
501+
match href(did) {
502+
Some((_, _, fqp)) => format!("{:?}::{:?}",
503+
fqp[..fqp.len()-1].join("::"),
504+
HRef::new(did, fqp.last().unwrap())),
505+
None => format!("{:?}", HRef::new(did, &last.name)),
506+
}
507+
} else {
508+
format!("{:?}", HRef::new(did, &last.name))
509+
};
510+
write!(w, "{}{:?}", path, last.params)?;
511+
}
490512
}
491513
Ok(())
492514
}
@@ -570,6 +592,12 @@ impl<'a> fmt::Display for HRef<'a> {
570592
}
571593
}
572594

595+
impl<'a> fmt::Debug for HRef<'a> {
596+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
597+
write!(f, "{}", self.text)
598+
}
599+
}
600+
573601
fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
574602
is_not_debug: bool) -> fmt::Result {
575603
match *t {
@@ -578,7 +606,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
578606
}
579607
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
580608
// Paths like T::Output and Self::Output should be rendered with all segments
581-
resolved_path(f, did, path, is_generic, use_absolute)?;
609+
resolved_path(f, did, path, is_generic, use_absolute, is_not_debug)?;
582610
tybounds(f, typarams)
583611
}
584612
clean::Infer => write!(f, "_"),
@@ -767,7 +795,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
767795
write!(f, "{}::", self_type)?;
768796
}
769797
let path = clean::Path::singleton(name.clone());
770-
resolved_path(f, did, &path, true, use_absolute)?;
798+
resolved_path(f, did, &path, true, use_absolute, is_not_debug)?;
771799

772800
// FIXME: `typarams` are not rendered, and this seems bad?
773801
drop(typarams);
@@ -1051,7 +1079,7 @@ impl fmt::Display for clean::Import {
10511079
impl fmt::Display for clean::ImportSource {
10521080
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10531081
match self.did {
1054-
Some(did) => resolved_path(f, did, &self.path, true, false),
1082+
Some(did) => resolved_path(f, did, &self.path, true, false, true),
10551083
_ => {
10561084
for (i, seg) in self.path.segments.iter().enumerate() {
10571085
if i > 0 {
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn prove_static<T: 'static + ?Sized>(_: &'static T) {}
12+
13+
fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
14+
let mut out = [x];
15+
//~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
16+
{
17+
let slice: &mut [_] = &mut out;
18+
slice[0] = y;
19+
}
20+
out[0]
21+
}
22+
23+
struct Struct<T, U: ?Sized> {
24+
head: T,
25+
_tail: U
26+
}
27+
28+
fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
29+
let mut out = Struct { head: x, _tail: [()] };
30+
//~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
31+
{
32+
let dst: &mut Struct<_, [()]> = &mut out;
33+
dst.head = y;
34+
}
35+
out.head
36+
}
37+
38+
fn main() {
39+
prove_static(lifetime_transmute_slice("", &String::from("foo")));
40+
prove_static(lifetime_transmute_struct("", &String::from("bar")));
41+
}

‎src/test/compile-fail/issue-40288.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn save_ref<'a>(refr: &'a i32, to: &mut [&'a i32]) {
12+
for val in &mut *to {
13+
*val = refr;
14+
}
15+
}
16+
17+
fn main() {
18+
let ref init = 0i32;
19+
let ref mut refr = 1i32;
20+
21+
let mut out = [init];
22+
23+
save_ref(&*refr, &mut out);
24+
25+
// This shouldn't be allowed as `refr` is borrowed
26+
*refr = 3; //~ ERROR cannot assign to `*refr` because it is borrowed
27+
28+
// Prints 3?!
29+
println!("{:?}", out[0]);
30+
}

‎src/test/compile-fail/object-lifetime-default-elision.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait {
7979
// which fails to type check.
8080

8181
ss
82-
//~^ ERROR lifetime bound not satisfied
82+
//~^ ERROR cannot infer
8383
//~| ERROR cannot infer
8484
}
8585

‎src/test/compile-fail/object-lifetime-default-from-box-error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn load(ss: &mut SomeStruct) -> Box<SomeTrait> {
2525
// `Box<SomeTrait>` defaults to a `'static` bound, so this return
2626
// is illegal.
2727

28-
ss.r //~ ERROR lifetime bound not satisfied
28+
ss.r //~ ERROR cannot infer an appropriate lifetime
2929
}
3030

3131
fn store(ss: &mut SomeStruct, b: Box<SomeTrait>) {
@@ -38,7 +38,7 @@ fn store(ss: &mut SomeStruct, b: Box<SomeTrait>) {
3838
fn store1<'b>(ss: &mut SomeStruct, b: Box<SomeTrait+'b>) {
3939
// Here we override the lifetimes explicitly, and so naturally we get an error.
4040

41-
ss.r = b; //~ ERROR lifetime bound not satisfied
41+
ss.r = b; //~ ERROR cannot infer an appropriate lifetime
4242
}
4343

4444
fn main() {

‎src/test/compile-fail/regions-close-over-type-parameter-multiple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'b> {
2727

2828
fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'c> {
2929
// A outlives 'a AND 'b...but not 'c.
30-
box v as Box<SomeTrait+'a> //~ ERROR lifetime bound not satisfied
30+
box v as Box<SomeTrait+'a> //~ ERROR cannot infer an appropriate lifetime
3131
}
3232

3333
fn main() {

‎src/test/compile-fail/regions-proc-bound-capture.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn borrowed_proc<'a>(x: &'a isize) -> Box<FnMut()->(isize) + 'a> {
1616

1717
fn static_proc(x: &isize) -> Box<FnMut()->(isize) + 'static> {
1818
// This is illegal, because the region bound on `proc` is 'static.
19-
Box::new(move|| { *x }) //~ ERROR does not fulfill the required lifetime
19+
Box::new(move|| { *x }) //~ ERROR cannot infer an appropriate lifetime
2020
}
2121

2222
fn main() { }

‎src/test/compile-fail/regions-trait-object-subtyping.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ fn foo2<'a:'b,'b>(x: &'b mut (Dummy+'a)) -> &'b mut (Dummy+'b) {
2222

2323
fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy {
2424
// Without knowing 'a:'b, we can't coerce
25-
x //~ ERROR lifetime bound not satisfied
26-
//~^ ERROR cannot infer
25+
x //~ ERROR cannot infer an appropriate lifetime
26+
//~^ ERROR cannot infer an appropriate lifetime
2727
}
2828

2929
struct Wrapper<T>(T);

‎src/test/compile-fail/variance-contravariant-arg-object.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>)
2121
-> Box<Get<&'min i32>>
2222
where 'max : 'min
2323
{
24-
v //~ ERROR mismatched types
24+
v //~ ERROR cannot infer an appropriate lifetime
2525
}
2626

2727
fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>)
2828
-> Box<Get<&'max i32>>
2929
where 'max : 'min
3030
{
3131
// Previously OK:
32-
v //~ ERROR mismatched types
32+
v //~ ERROR cannot infer an appropriate lifetime
3333
}
3434

3535
fn main() { }

‎src/test/compile-fail/variance-covariant-arg-object.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>)
2222
where 'max : 'min
2323
{
2424
// Previously OK, now an error as traits are invariant.
25-
v //~ ERROR mismatched types
25+
v //~ ERROR cannot infer an appropriate lifetime
2626
}
2727

2828
fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>)
2929
-> Box<Get<&'max i32>>
3030
where 'max : 'min
3131
{
32-
v //~ ERROR mismatched types
32+
v //~ ERROR cannot infer an appropriate lifetime
3333
}
3434

3535
fn main() { }

‎src/test/compile-fail/variance-invariant-arg-object.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>)
1818
-> Box<Get<&'min i32>>
1919
where 'max : 'min
2020
{
21-
v //~ ERROR mismatched types
21+
v //~ ERROR cannot infer an appropriate lifetime
2222
}
2323

2424
fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>)
2525
-> Box<Get<&'max i32>>
2626
where 'max : 'min
2727
{
28-
v //~ ERROR mismatched types
28+
v //~ ERROR cannot infer an appropriate lifetime
2929
}
3030

3131
fn main() { }

‎src/test/debuginfo/c-style-enum.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,38 @@
1515

1616
// === GDB TESTS ===================================================================================
1717

18-
// gdb-command:print 'c_style_enum::SINGLE_VARIANT'
18+
// gdbg-command:print 'c_style_enum::SINGLE_VARIANT'
19+
// gdbr-command:print c_style_enum::SINGLE_VARIANT
1920
// gdbg-check:$1 = TheOnlyVariant
2021
// gdbr-check:$1 = c_style_enum::SingleVariant::TheOnlyVariant
2122

22-
// gdb-command:print 'c_style_enum::AUTO_ONE'
23+
// gdbg-command:print 'c_style_enum::AUTO_ONE'
24+
// gdbr-command:print c_style_enum::AUTO_ONE
2325
// gdbg-check:$2 = One
2426
// gdbr-check:$2 = c_style_enum::AutoDiscriminant::One
2527

26-
// gdb-command:print 'c_style_enum::AUTO_TWO'
28+
// gdbg-command:print 'c_style_enum::AUTO_TWO'
29+
// gdbr-command:print c_style_enum::AUTO_TWO
2730
// gdbg-check:$3 = One
2831
// gdbr-check:$3 = c_style_enum::AutoDiscriminant::One
2932

30-
// gdb-command:print 'c_style_enum::AUTO_THREE'
33+
// gdbg-command:print 'c_style_enum::AUTO_THREE'
34+
// gdbr-command:print c_style_enum::AUTO_THREE
3135
// gdbg-check:$4 = One
3236
// gdbr-check:$4 = c_style_enum::AutoDiscriminant::One
3337

34-
// gdb-command:print 'c_style_enum::MANUAL_ONE'
38+
// gdbg-command:print 'c_style_enum::MANUAL_ONE'
39+
// gdbr-command:print c_style_enum::MANUAL_ONE
3540
// gdbg-check:$5 = OneHundred
3641
// gdbr-check:$5 = c_style_enum::ManualDiscriminant::OneHundred
3742

38-
// gdb-command:print 'c_style_enum::MANUAL_TWO'
43+
// gdbg-command:print 'c_style_enum::MANUAL_TWO'
44+
// gdbr-command:print c_style_enum::MANUAL_TWO
3945
// gdbg-check:$6 = OneHundred
4046
// gdbr-check:$6 = c_style_enum::ManualDiscriminant::OneHundred
4147

42-
// gdb-command:print 'c_style_enum::MANUAL_THREE'
48+
// gdbg-command:print 'c_style_enum::MANUAL_THREE'
49+
// gdbr-command:print c_style_enum::MANUAL_THREE
4350
// gdbg-check:$7 = OneHundred
4451
// gdbr-check:$7 = c_style_enum::ManualDiscriminant::OneHundred
4552

‎src/test/debuginfo/limited-debuginfo.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515

1616
// Make sure functions have proper names
1717
// gdb-command:info functions
18-
// gdb-check:[...]void[...]main([...]);
19-
// gdb-check:[...]void[...]some_function([...]);
20-
// gdb-check:[...]void[...]some_other_function([...]);
21-
// gdb-check:[...]void[...]zzz([...]);
18+
// gdbg-check:[...]void[...]main([...]);
19+
// gdbr-check:fn limited_debuginfo::main();
20+
// gdbg-check:[...]void[...]some_function([...]);
21+
// gdbr-check:fn limited_debuginfo::some_function();
22+
// gdbg-check:[...]void[...]some_other_function([...]);
23+
// gdbr-check:fn limited_debuginfo::some_other_function();
24+
// gdbg-check:[...]void[...]zzz([...]);
25+
// gdbr-check:fn limited_debuginfo::zzz();
2226

2327
// gdb-command:run
2428

‎src/test/debuginfo/simple-struct.rs

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
// === GDB TESTS ===================================================================================
1616

17-
// there's no frame yet for gdb to reliably detect the language, set it explicitly
18-
// gdbr-command:set language rust
19-
2017
// gdbg-command:print 'simple_struct::NO_PADDING_16'
2118
// gdbr-command:print simple_struct::NO_PADDING_16
2219
// gdbg-check:$1 = {x = 1000, y = -1001}

‎src/test/debuginfo/simple-tuple.rs

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
// === GDB TESTS ===================================================================================
1616

17-
// there's no frame yet for gdb to reliably detect the language, set it explicitly
18-
// gdbr-command:set language rust
19-
2017
// gdbg-command:print/d 'simple_tuple::NO_PADDING_8'
2118
// gdbr-command:print simple_tuple::NO_PADDING_8
2219
// gdbg-check:$1 = {__0 = -50, __1 = 50}

‎src/test/mir-opt/issue-38669.rs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ fn main() {
3535
// }
3636
//
3737
// bb2: {
38-
// StorageLive(_6);
3938
// _0 = ();
4039
// StorageDead(_4);
4140
// StorageDead(_1);

‎src/test/run-make/extern-fn-with-packed-struct/test.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,36 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::fmt;
12+
1113
#[repr(packed)]
12-
#[derive(Copy, Clone, PartialEq, Debug)]
14+
#[derive(Copy, Clone)]
1315
struct Foo {
1416
a: i8,
1517
b: i16,
1618
c: i8
1719
}
1820

21+
impl PartialEq for Foo {
22+
fn eq(&self, other: &Foo) -> bool {
23+
self.a == other.a && self.b == other.b && self.c == other.c
24+
}
25+
}
26+
27+
impl fmt::Debug for Foo {
28+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29+
let a = self.a;
30+
let b = self.b;
31+
let c = self.c;
32+
33+
f.debug_struct("Foo")
34+
.field("a", &a)
35+
.field("b", &b)
36+
.field("c", &c)
37+
.finish()
38+
}
39+
}
40+
1941
#[link(name = "test", kind = "static")]
2042
extern {
2143
fn foo(f: Foo) -> Foo;
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// pretty-expanded FIXME #23616
12+
13+
use std::rc::Rc;
14+
15+
fn lub_short<'a, T>(_: &[&'a T], _: &[&'a T]) {}
16+
17+
// The two arguments are a subtype of their LUB, after coercion.
18+
fn long_and_short<'a, T>(xs: &[&'static T; 1], ys: &[&'a T; 1]) {
19+
lub_short(xs, ys);
20+
}
21+
22+
// The argument coerces to a subtype of the return type.
23+
fn long_to_short<'a, 'b, T>(xs: &'b [&'static T; 1]) -> &'b [&'a T] {
24+
xs
25+
}
26+
27+
// Rc<T> is covariant over T just like &T.
28+
fn long_to_short_rc<'a, T>(xs: Rc<[&'static T; 1]>) -> Rc<[&'a T]> {
29+
xs
30+
}
31+
32+
// LUB-coercion (if-else/match/array) coerces `xs: &'b [&'static T: N]`
33+
// to a subtype of the LUB of `xs` and `ys` (i.e. `&'b [&'a T]`),
34+
// regardless of the order they appear (in if-else/match/array).
35+
fn long_and_short_lub1<'a, 'b, T>(xs: &'b [&'static T; 1], ys: &'b [&'a T]) {
36+
let _order1 = [xs, ys];
37+
let _order2 = [ys, xs];
38+
}
39+
40+
// LUB-coercion should also have the exact same effect when `&'b [&'a T; N]`
41+
// needs to be coerced, i.e. the resulting type is not &'b [&'static T], but
42+
// rather the `&'b [&'a T]` LUB.
43+
fn long_and_short_lub2<'a, 'b, T>(xs: &'b [&'static T], ys: &'b [&'a T; 1]) {
44+
let _order1 = [xs, ys];
45+
let _order2 = [ys, xs];
46+
}
47+
48+
fn main() {}

‎src/test/run-pass/packed-struct-vec.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,34 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::fmt;
1112
use std::mem;
1213

1314
#[repr(packed)]
14-
#[derive(Copy, Clone, PartialEq, Debug)]
15+
#[derive(Copy, Clone)]
1516
struct Foo {
1617
bar: u8,
1718
baz: u64
1819
}
1920

21+
impl PartialEq for Foo {
22+
fn eq(&self, other: &Foo) -> bool {
23+
self.bar == other.bar && self.baz == other.baz
24+
}
25+
}
26+
27+
impl fmt::Debug for Foo {
28+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29+
let bar = self.bar;
30+
let baz = self.baz;
31+
32+
f.debug_struct("Foo")
33+
.field("bar", &bar)
34+
.field("baz", &baz)
35+
.finish()
36+
}
37+
}
38+
2039
pub fn main() {
2140
let foos = [Foo { bar: 1, baz: 2 }; 10];
2241

‎src/test/ui/type-check/issue-40294.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo: Sized {
12+
fn foo(self);
13+
}
14+
15+
fn foo<'a,'b,T>(x: &'a T, y: &'b T)
16+
where &'a T : Foo,
17+
&'b T : Foo
18+
{
19+
x.foo();
20+
y.foo();
21+
}
22+
23+
fn main() { }
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/issue-40294.rs:15:1
3+
|
4+
15 | fn foo<'a,'b,T>(x: &'a T, y: &'b T)
5+
| _^ starting here...
6+
16 | | where &'a T : Foo,
7+
17 | | &'b T : Foo
8+
18 | | {
9+
19 | | x.foo();
10+
20 | | y.foo();
11+
21 | | }
12+
| |_^ ...ending here: cannot infer type for `&'a T`
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)
Please sign in to comment.