Skip to content

Commit

Permalink
Added cfail test
Browse files Browse the repository at this point in the history
Changed error to 'use of trait `{}` as a struct constructor'
  • Loading branch information
wickerwaka committed Aug 30, 2014
1 parent f5776f8 commit d3d14d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4000,7 +4000,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
}
Some(def::DefTrait(def_id)) => {
span_err!(tcx.sess, path.span, E0159,
"`{}` is a trait not a structure",
"use of trait `{}` as a struct constructor",
pprust::path_to_string(path));
check_struct_fields_on_error(fcx,
id,
Expand Down
17 changes: 17 additions & 0 deletions src/test/compile-fail/trait-as-struct-constructor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

trait TraitNotAStruct { }

fn main() {
TraitNotAStruct{ value: 0 };
//~^ ERROR: use of trait `TraitNotAStruct` as a struct constructor [E0159]
}

9 comments on commit d3d14d6

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at wickerwaka@d3d14d6

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging wickerwaka/rust/ice-16750 = d3d14d6 into auto

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wickerwaka/rust/ice-16750 = d3d14d6 merged ok, testing candidate = e82c2c6d

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at wickerwaka@d3d14d6

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging wickerwaka/rust/ice-16750 = d3d14d6 into auto

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wickerwaka/rust/ice-16750 = d3d14d6 merged ok, testing candidate = 01364c4

@bors
Copy link
Contributor

@bors bors commented on d3d14d6 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 01364c4

Please sign in to comment.