Skip to content

Only report Self: Sized violation once. #26027

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,20 +881,28 @@ fn check_error_patterns(props: &TestProps,
}
let mut next_err_idx = 0;
let mut next_err_pat = &props.error_patterns[next_err_idx];
let mut done = false;
for line in output_to_check.lines() {
let mut matched_all_patterns = false;
let mut lines = output_to_check.lines();
for line in &mut lines {
if line.contains(next_err_pat) {
debug!("found error pattern {}", next_err_pat);
next_err_idx += 1;
if next_err_idx == props.error_patterns.len() {
debug!("found all error patterns");
done = true;
matched_all_patterns = true;
break;
}
next_err_pat = &props.error_patterns[next_err_idx];
}
}
if done { return; }

if matched_all_patterns {
if lines.next().is_none() {
debug!("found all error patterns");
return;
} else {
fatal_proc_rec("no more error patterns to match against", proc_res);
}
}

let missing_patterns = &props.error_patterns[next_err_idx..];
if missing_patterns.len() == 1 {
Expand Down
13 changes: 8 additions & 5 deletions src/librustc/middle/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,15 @@ pub fn object_safety_violations<'tcx>(tcx: &ty::ctxt<'tcx>,
trait_def_id: ast::DefId)
-> Vec<ObjectSafetyViolation<'tcx>>
{
traits::supertrait_def_ids(tcx, trait_def_id)
let mut violations: Vec<_> = traits::supertrait_def_ids(tcx, trait_def_id)
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id))
.collect()
.collect();

if trait_has_sized_self(tcx, trait_def_id) {
violations.push(ObjectSafetyViolation::SizedSelf);
}

violations
}

fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
Expand All @@ -104,9 +110,6 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
.collect();

// Check the trait itself.
if trait_has_sized_self(tcx, trait_def_id) {
violations.push(ObjectSafetyViolation::SizedSelf);
}
if supertraits_reference_self(tcx, trait_def_id) {
violations.push(ObjectSafetyViolation::SupertraitSelf);
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail-fulldeps/plugin-MacroRulesTT.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -11,6 +11,7 @@
// aux-build:macro_crate_MacroRulesTT.rs
// ignore-stage1
// error-pattern: plugin tried to register a new MacroRulesTT
// error-pattern: aborting due to previous error

#![feature(plugin)]
#![plugin(macro_crate_MacroRulesTT)]
Expand Down
9 changes: 5 additions & 4 deletions src/test/compile-fail/arg-count-mismatch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,8 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: parameters were supplied

fn f(x: isize) { }

fn main() { let i: (); i = f(); }
fn main() {
let i: ();
i = f(); //~ ERROR this function takes 1 parameter but 0 parameters were supplied
}
9 changes: 5 additions & 4 deletions src/test/compile-fail/arg-type-mismatch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -9,8 +9,9 @@
// except according to those terms.


// error-pattern: mismatched types

fn f(x: isize) { }

fn main() { let i: (); i = f(()); }
fn main() {
let i: ();
i = f(()); //~ ERROR mismatched types
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/asm-src-loc-codegen-units.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -12,6 +12,8 @@
// ignore-stage1
// compile-flags: -C codegen-units=2
// error-pattern: build without -C codegen-units for more exact errors
// error-pattern: aborting due to previous error
// error-pattern: aborting due to worker thread panic

#![feature(asm)]

Expand Down
5 changes: 2 additions & 3 deletions src/test/compile-fail/attr-bad-crate-attr.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: expected item

#![attr = "val"]
#[attr = "val"] // Unterminated
//~^ ERROR expected item after attributes
10 changes: 7 additions & 3 deletions src/test/compile-fail/bad-env-capture.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,9 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: can't capture dynamic environment in a fn item;
fn foo() {
let x: isize;
fn bar() { log(debug, x); }
fn bar() {
println!("{}", x);
//~^ ERROR can't capture dynamic environment in a fn item; use the || { ... } closure
// form instead
//~| ERROR unresolved name `x`
}
}
fn main() { foo(); }
10 changes: 7 additions & 3 deletions src/test/compile-fail/bad-env-capture2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,8 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: can't capture dynamic environment in a fn item;
fn foo(x: isize) {
fn bar() { log(debug, x); }
fn bar() {
println!("{}", x);
//~^ ERROR can't capture dynamic environment in a fn item; use the || { ... } closure
// form instead
//~| ERROR unresolved name `x`
}
}
fn main() { foo(2); }
10 changes: 7 additions & 3 deletions src/test/compile-fail/bad-env-capture3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,10 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: can't capture dynamic environment in a fn item;
fn foo(x: isize) {
fn mth() {
fn bar() { log(debug, x); }
fn bar() {
println!("{}", x);
//~^ ERROR can't capture dynamic environment in a fn item; use the || { ... } closure
// form instead
//~| ERROR unresolved name `x`
}
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/test/compile-fail/bad-expr-path.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,8 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: unresolved name `m1::arguments`. Did you mean `arguments`?

mod m1 {}

fn main(arguments: Vec<String>) { log(debug, m1::arguments); }
fn main(arguments: Vec<String>) {
println!("{:?}", m1::arguments);
//~^ ERROR unresolved name `m1::arguments`. Did you mean `arguments`?
}
7 changes: 3 additions & 4 deletions src/test/compile-fail/bad-expr-path2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,12 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: unresolved name `m1::arguments`. Did you mean `arguments`?

mod m1 {
pub mod arguments {}
}

fn main(arguments: Vec<String>) {
log(debug, m1::arguments);
println!("{:?}", m1::arguments);
//~^ ERROR unresolved name `m1::arguments`. Did you mean `arguments`?
}
10 changes: 6 additions & 4 deletions src/test/compile-fail/bad-module.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: unresolved name

fn main() { let foo = thing::len(Vec::new()); }
fn main() {
let foo = thing::len(Vec::new());
//~^ ERROR failed to resolve. Use of undeclared type or module `thing`
//~| ERROR unresolved name `thing::len`
}
5 changes: 2 additions & 3 deletions src/test/compile-fail/binop-bitxor-str.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,6 +8,5 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:`^` cannot be applied to type `collections::string::String`

fn main() { let x = "a".to_string() ^ "b".to_string(); }
//~^ ERROR binary operation `^` cannot be applied to type `collections::string::String`
5 changes: 2 additions & 3 deletions src/test/compile-fail/binop-mul-bool.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,6 +8,5 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:`*` cannot be applied to type `bool`

fn main() { let x = true * false; }
//~^ ERROR binary operation `*` cannot be applied to type `bool`
11 changes: 4 additions & 7 deletions src/test/compile-fail/bogus-tag.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,15 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


// error-pattern: unresolved

enum color { rgb(isize, isize, isize), rgba(isize, isize, isize, isize), }

fn main() {
let red: color = rgb(255, 0, 0);
let red: color = rgb(255, 0, 0); //~ ERROR unresolved name `rgb`
match red {
rgb(r, g, b) => { println!("rgb"); }
hsl(h, s, l) => { println!("hsl"); }
rgb(r, g, b) => { println!("rgb"); } //~ ERROR unresolved enum variant, struct or const `rgb`
hsl(h, s, l) => { println!("hsl"); } //~ ERROR unresolved enum variant, struct or const `hsl`
}
}
8 changes: 4 additions & 4 deletions src/test/compile-fail/capture1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


// error-pattern: can't capture dynamic environment in a fn item;

fn main() {
let bar: isize = 5;
fn foo() -> isize { return bar; }
//~^ ERROR can't capture dynamic environment in a fn item; use the || { ... } closure
// form instead
//~| ERROR unresolved name `bar`
}
5 changes: 2 additions & 3 deletions src/test/compile-fail/cast-as-bool.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,5 +8,4 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: cannot cast as `bool`, compare with zero instead
fn main() { let u = (5 as bool); }
fn main() { let u = (5 as bool); } //~ ERROR cannot cast as `bool`, compare with zero instead
7 changes: 4 additions & 3 deletions src/test/compile-fail/cast-from-nil.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,5 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: non-scalar cast: `()` as `u32`
fn main() { let u = (assert!(true) as u32); }
fn main() {
let u = (assert!(true) as u32); //~ ERROR non-scalar cast: `()` as `u32`
}
7 changes: 4 additions & 3 deletions src/test/compile-fail/cast-to-nil.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,5 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: non-scalar cast: `u32` as `()`
fn main() { let u = 0u32 as (); }
fn main() {
let u = 0u32 as (); //~ ERROR non-scalar cast: `u32` as `()`
}
1 change: 1 addition & 0 deletions src/test/compile-fail/cfg-attr-cfg-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.
//
// error-pattern: main function not found
// error-pattern: aborting due to previous error
// compile-flags: --cfg foo

// main is conditionally compiled, but the conditional compilation
Expand Down
Loading