Skip to content

Commit

Permalink
Auto merge of #36274 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

- Successful merges: #35845, #35983, #36065, #36102, #36242, #36245
- Failed merges:
  • Loading branch information
bors authored Sep 6, 2016
2 parents cbe4de7 + 20ec61e commit e1d0de8
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 76 deletions.
6 changes: 3 additions & 3 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ fn signal_shadowing_problem(sess: &Session, name: ast::Name, orig: Original, sha
{} name that is already in scope",
shadower.kind.desc(), name, orig.kind.desc()))
};
err.span_note(orig.span,
&format!("shadowed {} `{}` declared here",
orig.kind.desc(), name));
err.span_label(orig.span, &"first declared here");
err.span_label(shadower.span,
&format!("lifetime {} already in scope", name));
err.emit();
}

Expand Down
20 changes: 11 additions & 9 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2437,16 +2437,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if arg_count == 1 {" was"} else {"s were"}),
error_code);

err.span_label(sp, &format!("expected {}{} parameter{}",
if variadic {"at least "} else {""},
expected_count,
if expected_count == 1 {""} else {"s"}));

let input_types = fn_inputs.iter().map(|i| format!("{:?}", i)).collect::<Vec<String>>();
if input_types.len() > 0 {
err.note(&format!("the following parameter type{} expected: {}",
if expected_count == 1 {" was"} else {"s were"},
input_types.join(", ")));
if input_types.len() > 1 {
err.note("the following parameter types were expected:");
err.note(&input_types.join(", "));
} else if input_types.len() > 0 {
err.note(&format!("the following parameter type was expected: {}",
input_types[0]));
} else {
err.span_label(sp, &format!("expected {}{} parameter{}",
if variadic {"at least "} else {""},
expected_count,
if expected_count == 1 {""} else {"s"}));
}
err.emit();
}
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ declare_features! (
(removed, struct_inherit, "1.0.0", None),
(removed, test_removed_feature, "1.0.0", None),
(removed, visible_private_types, "1.0.0", None),
(removed, unsafe_no_drop_flag, "1.0.0", None),
);

declare_features! (
Expand Down
3 changes: 1 addition & 2 deletions src/test/compile-fail/E0060.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ extern "C" {
fn main() {
unsafe { printf(); }
//~^ ERROR E0060
//~| NOTE expected at least 1 parameter
//~| NOTE the following parameter type was expected
//~| NOTE the following parameter type was expected: *const u8
}
10 changes: 8 additions & 2 deletions src/test/compile-fail/E0061.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@

fn f(a: u16, b: &str) {}

fn f2(a: u16) {}

fn main() {
f(0);
//~^ ERROR E0061
//~| NOTE expected 2 parameters
//~| NOTE the following parameter types were expected
//~| NOTE the following parameter types were expected:
//~| NOTE u16, &str

f2();
//~^ ERROR E0061
//~| NOTE the following parameter type was expected: u16
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/E0496.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ struct Foo<'a> {
}

impl<'a> Foo<'a> {
//~^ NOTE first declared here
fn f<'a>(x: &'a i32) { //~ ERROR E0496
//~^ NOTE lifetime 'a already in scope
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-18819.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ fn print_x(_: &Foo<Item=bool>, extra: &str) {
fn main() {
print_x(X);
//~^ ERROR this function takes 2 parameters but 1 parameter was supplied
//~| NOTE the following parameter types were expected: &Foo<Item=bool>, &str
//~| NOTE expected 2 parameters
//~| NOTE the following parameter types were expected:
//~| NOTE &Foo<Item=bool>, &str
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-3044.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ fn main() {
});
//~^^ ERROR this function takes 2 parameters but 1 parameter was supplied
//~| NOTE the following parameter types were expected
//~| NOTE expected 2 parameters
//~| NOTE _, _
// the first error is, um, non-ideal.
}
1 change: 0 additions & 1 deletion src/test/compile-fail/issue-4935.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ fn foo(a: usize) {}
fn main() { foo(5, 6) }
//~^ ERROR this function takes 1 parameter but 2 parameters were supplied
//~| NOTE the following parameter type was expected
//~| NOTE expected 1 parameter
33 changes: 17 additions & 16 deletions src/test/compile-fail/loops-reject-duplicate-labels-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@
// https://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833

pub fn foo() {
{ 'fl: for _ in 0..10 { break; } } //~ NOTE shadowed label `'fl` declared here
{ 'fl: for _ in 0..10 { break; } } //~ NOTE first declared here
{ 'fl: loop { break; } } //~ WARN label name `'fl` shadows a label name that is already in scope

{ 'lf: loop { break; } } //~ NOTE shadowed label `'lf` declared here
//~^ NOTE lifetime 'fl already in scope
{ 'lf: loop { break; } } //~ NOTE first declared here
{ 'lf: for _ in 0..10 { break; } } //~ WARN label name `'lf` shadows a label name that is already in scope

{ 'wl: while 2 > 1 { break; } } //~ NOTE shadowed label `'wl` declared here
//~^ NOTE lifetime 'lf already in scope
{ 'wl: while 2 > 1 { break; } } //~ NOTE first declared here
{ 'wl: loop { break; } } //~ WARN label name `'wl` shadows a label name that is already in scope

{ 'lw: loop { break; } } //~ NOTE shadowed label `'lw` declared here
//~^ NOTE lifetime 'wl already in scope
{ 'lw: loop { break; } } //~ NOTE first declared here
{ 'lw: while 2 > 1 { break; } } //~ WARN label name `'lw` shadows a label name that is already in scope

{ 'fw: for _ in 0..10 { break; } } //~ NOTE shadowed label `'fw` declared here
//~^ NOTE lifetime 'lw already in scope
{ 'fw: for _ in 0..10 { break; } } //~ NOTE first declared here
{ 'fw: while 2 > 1 { break; } } //~ WARN label name `'fw` shadows a label name that is already in scope

{ 'wf: while 2 > 1 { break; } } //~ NOTE shadowed label `'wf` declared here
//~^ NOTE lifetime 'fw already in scope
{ 'wf: while 2 > 1 { break; } } //~ NOTE first declared here
{ 'wf: for _ in 0..10 { break; } } //~ WARN label name `'wf` shadows a label name that is already in scope

{ 'tl: while let Some(_) = None::<i32> { break; } } //~ NOTE shadowed label `'tl` declared here
//~^ NOTE lifetime 'wf already in scope
{ 'tl: while let Some(_) = None::<i32> { break; } } //~ NOTE first declared here
{ 'tl: loop { break; } } //~ WARN label name `'tl` shadows a label name that is already in scope

{ 'lt: loop { break; } } //~ NOTE shadowed label `'lt` declared here
//~^ NOTE lifetime 'tl already in scope
{ 'lt: loop { break; } } //~ NOTE first declared here
{ 'lt: while let Some(_) = None::<i32> { break; } }
//~^ WARN label name `'lt` shadows a label name that is already in scope
//~^ WARN label name `'lt` shadows a label name that is already in scope
//~| NOTE lifetime 'lt already in scope
}

#[rustc_error]
Expand Down
32 changes: 17 additions & 15 deletions src/test/compile-fail/loops-reject-duplicate-labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,32 @@
// This is testing the exact cases that are in the issue description.

fn foo() {
'fl: for _ in 0..10 { break; } //~ NOTE shadowed label `'fl` declared here
'fl: for _ in 0..10 { break; } //~ NOTE first declared here
'fl: loop { break; } //~ WARN label name `'fl` shadows a label name that is already in scope
//~^ NOTE lifetime 'fl already in scope

'lf: loop { break; } //~ NOTE shadowed label `'lf` declared here
'lf: loop { break; } //~ NOTE first declared here
'lf: for _ in 0..10 { break; } //~ WARN label name `'lf` shadows a label name that is already in scope

'wl: while 2 > 1 { break; } //~ NOTE shadowed label `'wl` declared here
//~^ NOTE lifetime 'lf already in scope
'wl: while 2 > 1 { break; } //~ NOTE first declared here
'wl: loop { break; } //~ WARN label name `'wl` shadows a label name that is already in scope

'lw: loop { break; } //~ NOTE shadowed label `'lw` declared here
//~^ NOTE lifetime 'wl already in scope
'lw: loop { break; } //~ NOTE first declared here
'lw: while 2 > 1 { break; } //~ WARN label name `'lw` shadows a label name that is already in scope

'fw: for _ in 0..10 { break; } //~ NOTE shadowed label `'fw` declared here
//~^ NOTE lifetime 'lw already in scope
'fw: for _ in 0..10 { break; } //~ NOTE first declared here
'fw: while 2 > 1 { break; } //~ WARN label name `'fw` shadows a label name that is already in scope

'wf: while 2 > 1 { break; } //~ NOTE shadowed label `'wf` declared here
//~^ NOTE lifetime 'fw already in scope
'wf: while 2 > 1 { break; } //~ NOTE first declared here
'wf: for _ in 0..10 { break; } //~ WARN label name `'wf` shadows a label name that is already in scope

'tl: while let Some(_) = None::<i32> { break; } //~ NOTE shadowed label `'tl` declared here
//~^ NOTE lifetime 'wf already in scope
'tl: while let Some(_) = None::<i32> { break; } //~ NOTE first declared here
'tl: loop { break; } //~ WARN label name `'tl` shadows a label name that is already in scope

'lt: loop { break; } //~ NOTE shadowed label `'lt` declared here
//~^ NOTE lifetime 'tl already in scope
'lt: loop { break; } //~ NOTE first declared here
'lt: while let Some(_) = None::<i32> { break; }
//~^ WARN label name `'lt` shadows a label name that is already in scope
//~^ WARN label name `'lt` shadows a label name that is already in scope
//~| NOTE lifetime 'lt already in scope
}

// Note however that it is okay for the same label to be reused in
Expand Down
36 changes: 24 additions & 12 deletions src/test/compile-fail/loops-reject-labels-shadowing-lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#![allow(dead_code, unused_variables)]

fn foo() {
fn foo<'a>() { //~ NOTE shadowed lifetime `'a` declared here
fn foo<'a>() { //~ NOTE first declared here
'a: loop { break 'a; }
//~^ WARN label name `'a` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'a already in scope
}

struct Struct<'b, 'c> { _f: &'b i8, _g: &'c i8 }
Expand All @@ -40,76 +41,87 @@ fn foo() {
}
}

impl<'bad, 'c> Struct<'bad, 'c> { //~ NOTE shadowed lifetime `'bad` declared here
impl<'bad, 'c> Struct<'bad, 'c> { //~ NOTE first declared here
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}

impl<'b, 'bad> Struct<'b, 'bad> { //~ NOTE shadowed lifetime `'bad` declared here
impl<'b, 'bad> Struct<'b, 'bad> { //~ NOTE first declared here
fn meth_bad2(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}

impl<'b, 'c> Struct<'b, 'c> {
fn meth_bad3<'bad>(x: &'bad i8) { //~ NOTE shadowed lifetime `'bad` declared here
fn meth_bad3<'bad>(x: &'bad i8) { //~ NOTE first declared here
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}

fn meth_bad4<'a,'bad>(x: &'a i8, y: &'bad i8) {
//~^ NOTE shadowed lifetime `'bad` declared here
//~^ NOTE first declared here
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}

impl <'bad, 'e> Enum<'bad, 'e> { //~ NOTE shadowed lifetime `'bad` declared here
impl <'bad, 'e> Enum<'bad, 'e> { //~ NOTE first declared here
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}
impl <'d, 'bad> Enum<'d, 'bad> { //~ NOTE shadowed lifetime `'bad` declared here
impl <'d, 'bad> Enum<'d, 'bad> { //~ NOTE first declared here
fn meth_bad2(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}
impl <'d, 'e> Enum<'d, 'e> {
fn meth_bad3<'bad>(x: &'bad i8) { //~ NOTE shadowed lifetime `'bad` declared here
fn meth_bad3<'bad>(x: &'bad i8) { //~ NOTE first declared here
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}

fn meth_bad4<'a,'bad>(x: &'bad i8) { //~ NOTE shadowed lifetime `'bad` declared here
fn meth_bad4<'a,'bad>(x: &'bad i8) { //~ NOTE first declared here
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}

trait HasDefaultMethod1<'bad> { //~ NOTE shadowed lifetime `'bad` declared here
trait HasDefaultMethod1<'bad> { //~ NOTE first declared here
fn meth_okay() {
'c: loop { break 'c; }
}
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}
trait HasDefaultMethod2<'a,'bad> { //~ NOTE shadowed lifetime `'bad` declared here
trait HasDefaultMethod2<'a,'bad> { //~ NOTE first declared here
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}
trait HasDefaultMethod3<'a,'b> {
fn meth_bad<'bad>(&self) { //~ NOTE shadowed lifetime `'bad` declared here
fn meth_bad<'bad>(&self) { //~ NOTE first declared here
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'bad already in scope
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ fn foo() {

let z = 3_i8;

'a: loop { //~ NOTE shadowed label `'a` declared here
'a: loop { //~ NOTE first declared here
let b = Box::new(|x: &i8| *x) as Box<for <'a> Fn(&'a i8) -> i8>;
//~^ WARN lifetime name `'a` shadows a label name that is already in scope
//~| NOTE lifetime 'a already in scope
assert_eq!((*b)(&z), z);
break 'a;
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/compile-fail/method-call-err-msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ fn main() {
//~^ NOTE expected 0 parameters
.one() //~ ERROR this function takes 1 parameter but 0 parameters were supplied
//~^ NOTE the following parameter type was expected
//~| NOTE expected 1 parameter
.two(0); //~ ERROR this function takes 2 parameters but 1 parameter was supplied
//~^ NOTE the following parameter types were expected
//~| NOTE expected 2 parameters
//~| NOTE isize, isize

let y = Foo;
y.zero()
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/not-enough-arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ fn foo(a: isize, b: isize, c: isize, d:isize) {
fn main() {
foo(1, 2, 3);
//~^ ERROR this function takes 4 parameters but 3
//~| NOTE the following parameter types were expected
//~| NOTE expected 4 parameters
//~| NOTE the following parameter types were expected:
//~| NOTE isize, isize, isize, isize
}
2 changes: 0 additions & 2 deletions src/test/compile-fail/overloaded-calls-bad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ fn main() {
let ans = s();
//~^ ERROR this function takes 1 parameter but 0 parameters were supplied
//~| NOTE the following parameter type was expected
//~| NOTE expected 1 parameter
let ans = s("burma", "shave");
//~^ ERROR this function takes 1 parameter but 2 parameters were supplied
//~| NOTE the following parameter type was expected
//~| NOTE expected 1 parameter
}
6 changes: 4 additions & 2 deletions src/test/compile-fail/shadowed-lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
struct Foo<'a>(&'a isize);

impl<'a> Foo<'a> {
//~^ NOTE shadowed lifetime `'a` declared here
//~^ NOTE first declared here
fn shadow_in_method<'a>(&'a self) -> &'a isize {
//~^ ERROR lifetime name `'a` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'a already in scope
self.0
}

fn shadow_in_type<'b>(&'b self) -> &'b isize {
//~^ NOTE shadowed lifetime `'b` declared here
//~^ NOTE first declared here
let x: for<'b> fn(&'b isize) = panic!();
//~^ ERROR lifetime name `'b` shadows a lifetime name that is already in scope
//~| NOTE lifetime 'b already in scope
self.0
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail/variadic-ffi-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ extern "C" fn bar(f: isize, x: u8) {}
fn main() {
unsafe {
foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
//~^ NOTE the following parameter types were expected
//~| NOTE expected at least 2 parameters
//~^ NOTE the following parameter types were expected:
//~| NOTE isize, u8
foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
//~^ NOTE the following parameter types were expected
//~| NOTE expected at least 2 parameters
//~^ NOTE the following parameter types were expected:
//~| NOTE isize, u8

let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
//~^ ERROR: mismatched types
Expand Down

0 comments on commit e1d0de8

Please sign in to comment.