Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #36274

Merged
merged 10 commits into from
Sep 6, 2016
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ then
fi

CMD="${CFG_LOCAL_RUST_ROOT}/bin/rustc${BIN_SUF}"
LRV=`$CMD --version`
LRV=`LD_LIBRARY_PATH=${CFG_LOCAL_RUST_ROOT}/lib $CMD --version`
if [ $? -ne 0 ]
then
step_msg "failure while running $CMD --version"
Expand Down
8 changes: 7 additions & 1 deletion src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,13 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}
#[unstable(feature = "fused", issue = "35602")]
impl<'a, T> FusedIterator for IterMut<'a, T> {}

/// An iterator over the value in a `Ok` variant of a `Result`.
/// An iterator over the value in a `Ok` variant of a `Result`. This struct is
/// created by the [`into_iter`] method on [`Result`][`Result`] (provided by
/// the [`IntoIterator`] trait).
///
/// [`Result`]: enum.Result.html
/// [`into_iter`]: ../iter/trait.IntoIterator.html#tymethod.into_iter
/// [`IntoIterator`]: ../iter/trait.IntoIterator.html
#[derive(Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<T> { inner: Option<T> }
Expand Down
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 @@ -2466,16 +2466,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
}
Loading