Skip to content

Commit 43446fc

Browse files
authored
Auto merge of #35397 - jonathandturner:rollup, r=jonathandturner
Rollup of 18 pull requests - Successful merges: #34916, #35287, #35288, #35331, #35353, #35356, #35363, #35364, #35366, #35368, #35370, #35372, #35373, #35374, #35375, #35376, #35380, #35394 - Failed merges: #35395
2 parents b30eff7 + 9154cc9 commit 43446fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+536
-90
lines changed

man/rustc.1

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH RUSTC "1" "August 2015" "rustc 1.2.0" "User Commands"
1+
.TH RUSTC "1" "August 2016" "rustc 1.12.0" "User Commands"
22
.SH NAME
33
rustc \- The Rust compiler
44
.SH SYNOPSIS
@@ -299,7 +299,7 @@ To build an executable with debug info:
299299
See https://github.com/rust\-lang/rust/issues for issues.
300300

301301
.SH "AUTHOR"
302-
See \fIAUTHORS.txt\fR in the Rust source distribution.
302+
See https://github.com/rust\-lang/rust/graphs/contributors or use `git log --all --format='%cN <%cE>' | sort -u` in the rust source distribution.
303303

304304
.SH "COPYRIGHT"
305305
This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms.

man/rustdoc.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH RUSTDOC "1" "August 2015" "rustdoc 1.2.0" "User Commands"
1+
.TH RUSTDOC "1" "August 2016" "rustdoc 1.12.0" "User Commands"
22
.SH NAME
33
rustdoc \- generate documentation from Rust source code
44
.SH SYNOPSIS

src/librustc/middle/astconv_util.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
4747

4848
pub fn prohibit_projection(self, span: Span)
4949
{
50-
span_err!(self.sess, span, E0229,
51-
"associated type bindings are not allowed here");
50+
let mut err = struct_span_err!(self.sess, span, E0229,
51+
"associated type bindings are not allowed here");
52+
err.span_label(span, &format!("associate type not allowed here")).emit();
5253
}
5354

5455
pub fn prim_ty_to_ty(self,

src/librustc/traits/error_reporting.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
870870

871871

872872
fn need_type_info(&self, span: Span, ty: Ty<'tcx>) {
873-
span_err!(self.tcx.sess, span, E0282,
874-
"unable to infer enough type information about `{}`; \
875-
type annotations or generic parameter binding required",
876-
ty);
873+
let mut err = struct_span_err!(self.tcx.sess, span, E0282,
874+
"unable to infer enough type information about `{}`",
875+
ty);
876+
err.note("type annotations or generic parameter binding required");
877+
err.span_label(span, &format!("cannot infer type for `{}`", ty));
878+
err.emit()
877879
}
878880

879881
fn note_obligation_cause<T>(&self,

src/librustc_borrowck/borrowck/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
942942
but it borrows {}, \
943943
which is owned by the current function",
944944
cmt_path_or_string)
945-
.span_note(capture_span,
945+
.span_label(capture_span,
946946
&format!("{} is borrowed here",
947947
cmt_path_or_string))
948+
.span_label(err.span,
949+
&format!("may outlive borrowed value {}",
950+
cmt_path_or_string))
948951
.span_suggestion(err.span,
949952
&format!("to force the closure to take ownership of {} \
950953
(and any other referenced variables), \

src/librustc_const_eval/check_match.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,15 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
424424
format!("`{}` and {} more", head.join("`, `"), tail.len())
425425
}
426426
};
427-
span_err!(cx.tcx.sess, sp, E0004,
427+
428+
let label_text = match pattern_strings.len(){
429+
1 => format!("pattern {} not covered", joined_patterns),
430+
_ => format!("patterns {} not covered", joined_patterns)
431+
};
432+
struct_span_err!(cx.tcx.sess, sp, E0004,
428433
"non-exhaustive patterns: {} not covered",
429434
joined_patterns
430-
);
435+
).span_label(sp, &label_text).emit();
431436
},
432437
}
433438
}

src/librustc_const_eval/eval.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1337,10 +1337,13 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
13371337
Ok(val as usize)
13381338
},
13391339
Ok(const_val) => {
1340-
span_err!(tcx.sess, count_expr.span, E0306,
1341-
"expected usize for {}, found {}",
1342-
reason,
1343-
const_val.description());
1340+
struct_span_err!(tcx.sess, count_expr.span, E0306,
1341+
"expected `usize` for {}, found {}",
1342+
reason,
1343+
const_val.description())
1344+
.span_label(count_expr.span, &format!("expected `usize`"))
1345+
.emit();
1346+
13441347
Err(ErrorReported)
13451348
}
13461349
Err(err) => {

src/librustc_passes/ast_validation.rs

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ impl<'a> Visitor for AstValidator<'a> {
169169
self.check_decl_no_pat(decl, |span, is_recent| {
170170
let mut err = struct_span_err!(self.session, span, E0130,
171171
"patterns aren't allowed in foreign function declarations");
172+
err.span_label(span, &format!("pattern not allowed in foreign function"));
173+
172174
if is_recent {
173175
err.span_note(span, "this is a recent error, see \
174176
issue #35203 for more details");

src/librustc_passes/diagnostics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ All statics and constants need to resolve to a value in an acyclic manner.
121121
122122
For example, neither of the following can be sensibly compiled:
123123
124-
```compile_fail
124+
```compile_fail,E0265
125125
const X: u32 = X;
126126
```
127127
128-
```compile_fail
128+
```compile_fail,E0265
129129
const X: u32 = Y;
130130
const Y: u32 = X;
131131
```
@@ -135,7 +135,7 @@ E0267: r##"
135135
This error indicates the use of a loop keyword (`break` or `continue`) inside a
136136
closure but outside of any loop. Erroneous code example:
137137
138-
```compile_fail
138+
```compile_fail,E0267
139139
let w = || { break; }; // error: `break` inside of a closure
140140
```
141141
@@ -159,7 +159,7 @@ This error indicates the use of a loop keyword (`break` or `continue`) outside
159159
of a loop. Without a loop to break out of or continue in, no sensible action can
160160
be taken. Erroneous code example:
161161
162-
```compile_fail
162+
```compile_fail,E0268
163163
fn some_func() {
164164
break; // error: `break` outside of loop
165165
}

src/librustc_resolve/diagnostics.rs

+40-1
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,53 @@ mod foo {
146146
}
147147
148148
use foo::MyTrait::do_something;
149+
// error: `do_something` is not directly importable
149150
150151
fn main() {}
151152
```
152153
153154
It's invalid to directly import methods belonging to a trait or concrete type.
154155
"##,
155156

157+
E0254: r##"
158+
Attempt was made to import an item whereas an extern crate with this name has
159+
already been imported.
160+
161+
Erroneous code example:
162+
163+
```compile_fail,E0254
164+
extern crate collections;
165+
166+
mod foo {
167+
pub trait collections {
168+
fn do_something();
169+
}
170+
}
171+
172+
use foo::collections; // error: an extern crate named `collections` has already
173+
// been imported in this module
174+
175+
fn main() {}
176+
```
177+
178+
To fix issue issue, you have to rename at least one of the two imports.
179+
Example:
180+
181+
```ignore
182+
extern crate collections as libcollections; // ok!
183+
184+
mod foo {
185+
pub trait collections {
186+
fn do_something();
187+
}
188+
}
189+
190+
use foo::collections;
191+
192+
fn main() {}
193+
```
194+
"##,
195+
156196
E0255: r##"
157197
You can't import a value whose name is the same as another value defined in the
158198
module.
@@ -1237,7 +1277,6 @@ impl Foo for i32 {}
12371277
register_diagnostics! {
12381278
// E0153, unused error code
12391279
// E0157, unused error code
1240-
E0254, // import conflicts with imported crate in this module
12411280
// E0257,
12421281
// E0258,
12431282
E0402, // cannot use an outer type parameter in this context

src/librustc_typeck/astconv.rs

+25-5
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
310310
None => match rscope.anon_regions(default_span, 1) {
311311
Ok(rs) => rs[0],
312312
Err(params) => {
313-
let mut err = struct_span_err!(self.tcx().sess, default_span, E0106,
314-
"missing lifetime specifier");
313+
let ampersand_span = Span { hi: default_span.lo, ..default_span};
314+
315+
let mut err = struct_span_err!(self.tcx().sess, ampersand_span, E0106,
316+
"missing lifetime specifier");
317+
err.span_label(ampersand_span, &format!("expected lifetime parameter"));
318+
315319
if let Some(params) = params {
316320
report_elision_failure(&mut err, params);
317321
}
@@ -2269,9 +2273,25 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
22692273
}
22702274

22712275
fn report_lifetime_number_error(tcx: TyCtxt, span: Span, number: usize, expected: usize) {
2272-
span_err!(tcx.sess, span, E0107,
2273-
"wrong number of lifetime parameters: expected {}, found {}",
2274-
expected, number);
2276+
let label = if number < expected {
2277+
if expected == 1 {
2278+
format!("expected {} lifetime parameter", expected)
2279+
} else {
2280+
format!("expected {} lifetime parameters", expected)
2281+
}
2282+
} else {
2283+
let additional = number - expected;
2284+
if additional == 1 {
2285+
"unexpected lifetime parameter".to_string()
2286+
} else {
2287+
format!("{} unexpected lifetime parameters", additional)
2288+
}
2289+
};
2290+
struct_span_err!(tcx.sess, span, E0107,
2291+
"wrong number of lifetime parameters: expected {}, found {}",
2292+
expected, number)
2293+
.span_label(span, &label)
2294+
.emit();
22752295
}
22762296

22772297
// A helper struct for conveniently grouping a set of bounds which we pass to

src/librustc_typeck/check/compare_method.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use rustc::ty;
1414
use rustc::traits::{self, ProjectionMode};
1515
use rustc::ty::error::ExpectedFound;
1616
use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace};
17+
use rustc::hir::map::Node;
18+
use rustc::hir::{ImplItemKind, TraitItem_};
1719

1820
use syntax::ast;
1921
use syntax_pos::Span;
@@ -447,7 +449,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
447449
// Compute skolemized form of impl and trait const tys.
448450
let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs);
449451
let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs);
450-
let origin = TypeOrigin::Misc(impl_c_span);
452+
let mut origin = TypeOrigin::Misc(impl_c_span);
451453

452454
let err = infcx.commit_if_ok(|_| {
453455
// There is no "body" here, so just pass dummy id.
@@ -482,11 +484,31 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
482484
debug!("checking associated const for compatibility: impl ty {:?}, trait ty {:?}",
483485
impl_ty,
484486
trait_ty);
487+
488+
// Locate the Span containing just the type of the offending impl
489+
if let Some(impl_trait_node) = tcx.map.get_if_local(impl_c.def_id) {
490+
if let Node::NodeImplItem(impl_trait_item) = impl_trait_node {
491+
if let ImplItemKind::Const(ref ty, _) = impl_trait_item.node {
492+
origin = TypeOrigin::Misc(ty.span);
493+
}
494+
}
495+
}
496+
485497
let mut diag = struct_span_err!(
486498
tcx.sess, origin.span(), E0326,
487499
"implemented const `{}` has an incompatible type for trait",
488500
trait_c.name
489501
);
502+
503+
// Add a label to the Span containing just the type of the item
504+
if let Some(orig_trait_node) = tcx.map.get_if_local(trait_c.def_id) {
505+
if let Node::NodeTraitItem(orig_trait_item) = orig_trait_node {
506+
if let TraitItem_::ConstTraitItem(ref ty, _) = orig_trait_item.node {
507+
diag.span_label(ty.span, &format!("original trait requirement"));
508+
}
509+
}
510+
}
511+
490512
infcx.note_type_err(
491513
&mut diag, origin,
492514
Some(infer::ValuePairs::Types(ExpectedFound {

0 commit comments

Comments
 (0)