diff options
| author | bors <bors@rust-lang.org> | 2016-11-09 11:58:25 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-09 11:58:25 -0800 |
| commit | da2ce2276873242a101f205537e7ce297d68f8dd (patch) | |
| tree | b0de0fa6de932ca2ebeb973b7c92014903edb54e /src/test | |
| parent | bca365e688f0424fb99d38d477a9b7863bb070d3 (diff) | |
| parent | 60c74b76c4698d0223223e42853c5a89fd33fd09 (diff) | |
Auto merge of #37670 - eddyb:rollup, r=eddyb
Rollup of 15 pull requests - Successful merges: #36868, #37134, #37229, #37250, #37370, #37428, #37432, #37472, #37524, #37614, #37622, #37627, #37636, #37644, #37654 - Failed merges: #37463, #37542, #37645
Diffstat (limited to 'src/test')
49 files changed, 915 insertions, 88 deletions
diff --git a/src/test/compile-fail-fulldeps/proc-macro/attribute.rs b/src/test/compile-fail-fulldeps/proc-macro/attribute.rs index d1b2aa330ed..e22339694f9 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attribute.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/attribute.rs @@ -33,8 +33,8 @@ pub fn foo3(input: proc_macro::TokenStream) -> proc_macro::TokenStream { input } -#[proc_macro_derive(b, c)] -//~^ ERROR: attribute must only have one argument +#[proc_macro_derive(b, c, d)] +//~^ ERROR: attribute must have either one or two arguments pub fn foo4(input: proc_macro::TokenStream) -> proc_macro::TokenStream { input } @@ -44,3 +44,21 @@ pub fn foo4(input: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn foo5(input: proc_macro::TokenStream) -> proc_macro::TokenStream { input } + +#[proc_macro_derive(f, attributes(g = "h"))] +//~^ ERROR: must only be one word +pub fn foo6(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(i, attributes(j(k)))] +//~^ ERROR: must only be one word +pub fn foo7(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(l, attributes(m), n)] +//~^ ERROR: attribute must have either one or two arguments +pub fn foo8(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs new file mode 100644 index 00000000000..70b778b1030 --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs @@ -0,0 +1,25 @@ +// Copyright 2016 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. + +// force-host +// no-prefer-dynamic + +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(B, attributes(B))] +pub fn derive_b(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs index 23dcbe03b5f..4f4ed90f8fc 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs @@ -17,8 +17,8 @@ extern crate derive_unstable_2; #[derive(Unstable)] -struct A; //~^ ERROR: reserved for internal compiler +struct A; fn main() { foo(); diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs index fb86f6f1b65..84ac776a765 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs @@ -17,8 +17,8 @@ extern crate derive_unstable; #[derive(Unstable)] -struct A; //~^ ERROR: use of unstable library feature +struct A; fn main() { unsafe { foo(); } diff --git a/src/test/compile-fail/feature-gate-relaxed-adts-2.rs b/src/test/compile-fail-fulldeps/proc-macro/item-error.rs index a75f2647f49..2a68accf91f 100644 --- a/src/test/compile-fail/feature-gate-relaxed-adts-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/item-error.rs @@ -8,20 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Z(u8, u8); +// aux-build:derive-b.rs -enum E { - U(u8, u8), +#![feature(proc_macro)] +#![allow(warnings)] + +#[macro_use] +extern crate derive_b; + +#[derive(B)] +struct A { + a: &u64 +//~^ ERROR: missing lifetime specifier } fn main() { - match Z(0, 1) { - Z{..} => {} //~ ERROR tuple structs and variants in struct patterns are unstable - } - match E::U(0, 1) { - E::U{..} => {} //~ ERROR tuple structs and variants in struct patterns are unstable - } - - let z1 = Z(0, 1); - let z2 = Z { ..z1 }; //~ ERROR tuple structs and variants in struct patterns are unstable } diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs new file mode 100644 index 00000000000..651a277d4ab --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs @@ -0,0 +1,26 @@ +// Copyright 2016 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. + +// aux-build:derive-b.rs + +#![feature(proc_macro)] +#![allow(warnings)] + +#[macro_use] +extern crate derive_b; + +#[derive(B)] +#[B] +#[C] //~ ERROR: The attribute `C` is currently unknown to the compiler +#[B(D)] +#[B(E = "foo")] +struct B; + +fn main() {} diff --git a/src/test/compile-fail/auxiliary/empty-struct.rs b/src/test/compile-fail/auxiliary/empty-struct.rs index dcbb0ce178b..4a302865634 100644 --- a/src/test/compile-fail/auxiliary/empty-struct.rs +++ b/src/test/compile-fail/auxiliary/empty-struct.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(relaxed_adts)] - pub struct XEmpty1 {} pub struct XEmpty2; pub struct XEmpty6(); diff --git a/src/test/compile-fail/auxiliary/namespace-mix-new.rs b/src/test/compile-fail/auxiliary/namespace-mix-new.rs index 88e8b0d56fe..d42c0ee1a4d 100644 --- a/src/test/compile-fail/auxiliary/namespace-mix-new.rs +++ b/src/test/compile-fail/auxiliary/namespace-mix-new.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(item_like_imports, relaxed_adts)] +#![feature(item_like_imports)] pub mod c { pub struct S {} diff --git a/src/test/compile-fail/auxiliary/namespace-mix-old.rs b/src/test/compile-fail/auxiliary/namespace-mix-old.rs index 7bbba7163b5..29b139d771b 100644 --- a/src/test/compile-fail/auxiliary/namespace-mix-old.rs +++ b/src/test/compile-fail/auxiliary/namespace-mix-old.rs @@ -10,8 +10,6 @@ // FIXME: Remove when `item_like_imports` is stabilized. -#![feature(relaxed_adts)] - pub mod c { pub struct S {} pub struct TS(); diff --git a/src/test/compile-fail/empty-struct-braces-pat-2.rs b/src/test/compile-fail/empty-struct-braces-pat-2.rs index 58e3ca6b3ac..4349e72c5d7 100644 --- a/src/test/compile-fail/empty-struct-braces-pat-2.rs +++ b/src/test/compile-fail/empty-struct-braces-pat-2.rs @@ -12,8 +12,6 @@ // aux-build:empty-struct.rs -#![feature(relaxed_adts)] - extern crate empty_struct; use empty_struct::*; diff --git a/src/test/compile-fail/empty-struct-braces-pat-3.rs b/src/test/compile-fail/empty-struct-braces-pat-3.rs index 1960eca9f80..d6c5b953492 100644 --- a/src/test/compile-fail/empty-struct-braces-pat-3.rs +++ b/src/test/compile-fail/empty-struct-braces-pat-3.rs @@ -12,8 +12,6 @@ // aux-build:empty-struct.rs -#![feature(relaxed_adts)] - extern crate empty_struct; use empty_struct::*; diff --git a/src/test/compile-fail/empty-struct-tuple-pat.rs b/src/test/compile-fail/empty-struct-tuple-pat.rs index f15c126a126..5e683eafade 100644 --- a/src/test/compile-fail/empty-struct-tuple-pat.rs +++ b/src/test/compile-fail/empty-struct-tuple-pat.rs @@ -12,8 +12,6 @@ // aux-build:empty-struct.rs -#![feature(relaxed_adts)] - extern crate empty_struct; use empty_struct::*; diff --git a/src/test/compile-fail/empty-struct-unit-pat.rs b/src/test/compile-fail/empty-struct-unit-pat.rs index 90f6ae5755f..532c2d85053 100644 --- a/src/test/compile-fail/empty-struct-unit-pat.rs +++ b/src/test/compile-fail/empty-struct-unit-pat.rs @@ -12,8 +12,6 @@ // aux-build:empty-struct.rs -#![feature(relaxed_adts)] - extern crate empty_struct; use empty_struct::*; diff --git a/src/test/compile-fail/issue-17800.rs b/src/test/compile-fail/issue-17800.rs index d5f1614c14d..f7cae91aa93 100644 --- a/src/test/compile-fail/issue-17800.rs +++ b/src/test/compile-fail/issue-17800.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(relaxed_adts)] - enum MyOption<T> { MySome(T), MyNone, diff --git a/src/test/compile-fail/issue-3907.rs b/src/test/compile-fail/issue-3907.rs index 93556577ad3..86906ed9af2 100644 --- a/src/test/compile-fail/issue-3907.rs +++ b/src/test/compile-fail/issue-3907.rs @@ -18,7 +18,7 @@ struct S { } impl Foo for S { //~ ERROR: `Foo` is not a trait - //~| NOTE: not a trait + //~| NOTE: expected trait, found type alias //~| NOTE: type aliases cannot be used for traits fn bar() { } } diff --git a/src/test/compile-fail/issue-4736.rs b/src/test/compile-fail/issue-4736.rs index c93e75042dd..19803079d02 100644 --- a/src/test/compile-fail/issue-4736.rs +++ b/src/test/compile-fail/issue-4736.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(relaxed_adts)] - struct NonCopyable(()); fn main() { diff --git a/src/test/compile-fail/issue-5035.rs b/src/test/compile-fail/issue-5035.rs index 7a36012925e..8ebcba47134 100644 --- a/src/test/compile-fail/issue-5035.rs +++ b/src/test/compile-fail/issue-5035.rs @@ -11,7 +11,7 @@ trait I {} type K = I; impl K for isize {} //~ ERROR: `K` is not a trait - //~| NOTE: not a trait + //~| NOTE: expected trait, found type alias //~| NOTE: aliases cannot be used for traits use ImportError; //~ ERROR unresolved import `ImportError` [E0432] diff --git a/src/test/compile-fail/namespace-mix-new.rs b/src/test/compile-fail/namespace-mix-new.rs index 0abe8bd4390..59592e3d737 100644 --- a/src/test/compile-fail/namespace-mix-new.rs +++ b/src/test/compile-fail/namespace-mix-new.rs @@ -10,7 +10,7 @@ // aux-build:namespace-mix-new.rs -#![feature(item_like_imports, relaxed_adts)] +#![feature(item_like_imports)] extern crate namespace_mix_new; use namespace_mix_new::*; diff --git a/src/test/compile-fail/namespace-mix-old.rs b/src/test/compile-fail/namespace-mix-old.rs index ad676644196..8cd82050814 100644 --- a/src/test/compile-fail/namespace-mix-old.rs +++ b/src/test/compile-fail/namespace-mix-old.rs @@ -12,8 +12,6 @@ // aux-build:namespace-mix-old.rs -#![feature(relaxed_adts)] - extern crate namespace_mix_old; use namespace_mix_old::{xm1, xm2, xm3, xm4, xm5, xm6, xm7, xm8, xm9, xmA, xmB, xmC}; diff --git a/src/test/compile-fail/feature-gate-relaxed-adts.rs b/src/test/compile-fail/numeric-fields-feature-gate.rs index dc5e347aadf..3ce85813a9b 100644 --- a/src/test/compile-fail/feature-gate-relaxed-adts.rs +++ b/src/test/compile-fail/numeric-fields-feature-gate.rs @@ -8,19 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct S(); //~ ERROR empty tuple structs and enum variants are unstable -struct Z(u8, u8); - -enum E { - V(), //~ ERROR empty tuple structs and enum variants are unstable - U(u8, u8), -} +struct S(u8); fn main() { - match S() { - S() => {} //~ ERROR empty tuple structs patterns are unstable - } - match E::V() { - E::V() => {} //~ ERROR empty tuple structs patterns are unstable + let s = S{0: 10}; //~ ERROR numeric fields in struct expressions are unstable + match s { + S{0: a, ..} => {} //~ ERROR numeric fields in struct patterns are unstable } } diff --git a/src/test/incremental/hashes/let_expressions.rs b/src/test/incremental/hashes/let_expressions.rs new file mode 100644 index 00000000000..7bfd8077a3d --- /dev/null +++ b/src/test/incremental/hashes/let_expressions.rs @@ -0,0 +1,228 @@ +// Copyright 2016 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. + + +// This test case tests the incremental compilation hash (ICH) implementation +// for let expressions. + +// The general pattern followed here is: Change one thing between rev1 and rev2 +// and make sure that the hash has changed, then change nothing between rev2 and +// rev3 and make sure that the hash has not changed. + +// must-compile-successfully +// revisions: cfail1 cfail2 cfail3 +// compile-flags: -Z query-dep-graph + + +#![allow(warnings)] +#![feature(rustc_attrs)] +#![crate_type="rlib"] + +// Change Name ----------------------------------------------------------------- +#[cfg(cfail1)] +pub fn change_name() { + let _x = 2u64; +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_name() { + let _y = 2u64; +} + + + +// Add Type -------------------------------------------------------------------- +#[cfg(cfail1)] +pub fn add_type() { + let _x = 2u32; +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_type() { + let _x: u32 = 2u32; +} + + + +// Change Type ----------------------------------------------------------------- +#[cfg(cfail1)] +pub fn change_type() { + let _x: u64 = 2; +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_type() { + let _x: u8 = 2; +} + + + +// Change Mutability of Reference Type ----------------------------------------- +#[cfg(cfail1)] +pub fn change_mutability_of_reference_type() { + let _x: &u64; +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_mutability_of_reference_type() { + let _x: &mut u64; +} + + + +// Change Mutability of Slot --------------------------------------------------- +#[cfg(cfail1)] +pub fn change_mutability_of_slot() { + let mut _x: u64 = 0; +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_mutability_of_slot() { + let _x: u64 = 0; +} + + + +// Change Simple Binding to Pattern -------------------------------------------- +#[cfg(cfail1)] +pub fn change_simple_binding_to_pattern() { + let _x = (0u8, 'x'); +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_simple_binding_to_pattern() { + let (_a, _b) = (0u8, 'x'); +} + + + +// Change Name in Pattern ------------------------------------------------------ +#[cfg(cfail1)] +pub fn change_name_in_pattern() { + let (_a, _b) = (1u8, 'y'); +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_name_in_pattern() { + let (_a, _c) = (1u8, 'y'); +} + + + +// Add `ref` in Pattern -------------------------------------------------------- +#[cfg(cfail1)] +pub fn add_ref_in_pattern() { + let (_a, _b) = (1u8, 'y'); +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_ref_in_pattern() { + let (ref _a, _b) = (1u8, 'y'); +} + + + +// Add `&` in Pattern ---------------------------------------------------------- +#[cfg(cfail1)] +pub fn add_amp_in_pattern() { + let (_a, _b) = (&1u8, 'y'); +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_amp_in_pattern() { + let (&_a, _b) = (&1u8, 'y'); +} + + + +// Change Mutability of Binding in Pattern ------------------------------------- +#[cfg(cfail1)] +pub fn change_mutability_of_binding_in_pattern() { + let (_a, _b) = (99u8, 'q'); +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_mutability_of_binding_in_pattern() { + let (mut _a, _b) = (99u8, 'q'); +} + + + +// Add Initializer ------------------------------------------------------------- +#[cfg(cfail1)] +pub fn add_initializer() { + let _x: i16; +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_initializer() { + let _x: i16 = 3i16; +} + + + +// Change Initializer ---------------------------------------------------------- +#[cfg(cfail1)] +pub fn change_initializer() { + let _x = 4u16; +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_initializer() { + let _x = 5u16; +} diff --git a/src/test/incremental/hashes/match_expressions.rs b/src/test/incremental/hashes/match_expressions.rs new file mode 100644 index 00000000000..95e94a91c5b --- /dev/null +++ b/src/test/incremental/hashes/match_expressions.rs @@ -0,0 +1,342 @@ +// Copyright 2016 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. + + +// This test case tests the incremental compilation hash (ICH) implementation +// for match expressions. + +// The general pattern followed here is: Change one thing between rev1 and rev2 +// and make sure that the hash has changed, then change nothing between rev2 and +// rev3 and make sure that the hash has not changed. + +// must-compile-successfully +// revisions: cfail1 cfail2 cfail3 +// compile-flags: -Z query-dep-graph + + +#![allow(warnings)] +#![feature(rustc_attrs)] +#![crate_type="rlib"] + +// Add Arm --------------------------------------------------------------------- +#[cfg(cfail1)] +pub fn add_arm(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + _ => 100, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_arm(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + 2 => 2, + _ => 100, + } +} + + + +// Change Order Of Arms -------------------------------------------------------- +#[cfg(cfail1)] +pub fn change_order_of_arms(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + _ => 100, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_order_of_arms(x: u32) -> u32 { + match x { + 1 => 1, + 0 => 0, + _ => 100, + } +} + + + +// Add Guard Clause ------------------------------------------------------------ +#[cfg(cfail1)] +pub fn add_guard_clause(x: u32, y: bool) -> u32 { + match x { + 0 => 0, + 1 => 1, + _ => 100, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_guard_clause(x: u32, y: bool) -> u32 { + match x { + 0 => 0, + 1 if y => 1, + _ => 100, + } +} + + + +// Change Guard Clause ------------------------------------------------------------ +#[cfg(cfail1)] +pub fn change_guard_clause(x: u32, y: bool) -> u32 { + match x { + 0 => 0, + 1 if y => 1, + _ => 100, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_guard_clause(x: u32, y: bool) -> u32 { + match x { + 0 => 0, + 1 if !y => 1, + _ => 100, + } +} + + + +// Add @-Binding --------------------------------------------------------------- +#[cfg(cfail1)] +pub fn add_at_binding(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + _ => x, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_at_binding(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + x @ _ => x, + } +} + + + +// Change Name of @-Binding ---------------------------------------------------- +#[cfg(cfail1)] +pub fn change_name_of_at_binding(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + x @ _ => 7, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_name_of_at_binding(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + y @ _ => 7, + } +} + + + +// Change Simple Binding To Pattern -------------------------------------------- +#[cfg(cfail1)] +pub fn change_simple_name_to_pattern(x: u32) -> u32 { + match (x, x & 1) { + (0, 0) => 0, + a => 1 + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_simple_name_to_pattern(x: u32) -> u32 { + match (x, x & 1) { + (0, 0) => 0, + (x, y) => 1 + } +} + + + +// Change Name In Pattern ------------------------------------------------------ +#[cfg(cfail1)] +pub fn change_name_in_pattern(x: u32) -> u32 { + match (x, x & 1) { + (a, 0) => 0, + (a, 1) => a, + _ => 100, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_name_in_pattern(x: u32) -> u32 { + match (x, x & 1) { + (b, 0) => 0, + (a, 1) => a, + _ => 100, + } +} + + + +// Change Mutability Of Binding In Pattern ------------------------------------- +#[cfg(cfail1)] +pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { + match (x, x & 1) { + (a, 0) => 0, + _ => 1 + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { + match (x, x & 1) { + (mut a, 0) => 0, + _ => 1 + } +} + + + +// Add `ref` To Binding In Pattern ------------------------------------- +#[cfg(cfail1)] +pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 { + match (x, x & 1) { + (a, 0) => 0, + _ => 1 + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 { + match (x, x & 1) { + (ref a, 0) => 0, + _ => 1, + } +} + + + +// Add `&` To Binding In Pattern ------------------------------------- +#[cfg(cfail1)] +pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 { + match (&x, x & 1) { + (a, 0) => 0, + _ => 1 + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 { + match (&x, x & 1) { + (&a, 0) => 0, + _ => 1, + } +} + + + +// Change RHS Of Arm ----------------------------------------------------------- +#[cfg(cfail1)] +pub fn change_rhs_of_arm(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + _ => 2, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn change_rhs_of_arm(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 3, + _ => 2, + } +} + + + +// Add Alternative To Arm ------------------------------------------------------ +#[cfg(cfail1)] +pub fn add_alternative_to_arm(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + _ => 2, + } +} + +#[cfg(not(cfail1))] +#[rustc_dirty(label="Hir", cfg="cfail2")] +#[rustc_clean(label="Hir", cfg="cfail3")] +#[rustc_metadata_dirty(cfg="cfail2")] +#[rustc_metadata_clean(cfg="cfail3")] +pub fn add_alternative_to_arm(x: u32) -> u32 { + match x { + 0 | 7 => 0, + 1 => 3, + _ => 2, + } +} diff --git a/src/test/run-make/missing-items/Makefile b/src/test/run-make/missing-items/Makefile new file mode 100644 index 00000000000..bcc9cdf2d65 --- /dev/null +++ b/src/test/run-make/missing-items/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + $(RUSTC) m1.rs -C prefer-dynamic + $(RUSTC) m2.rs 2>&1 | grep "error\[E0046\]: not all trait items implemented, missing: .*" + $(RUSTC) m2.rs 2>&1 | grep " --> m2.rs:18:1" + $(RUSTC) m2.rs 2>&1 | grep " | ^ missing .CONSTANT., .Type., .method. in implementation" + $(RUSTC) m2.rs 2>&1 | grep " = note: .CONSTANT. from trait: .const CONSTANT: u32;." + $(RUSTC) m2.rs 2>&1 | grep " = note: .Type. from trait: .type Type;." + $(RUSTC) m2.rs 2>&1 | grep " = note: .method. from trait: .fn(&Self, std::string::String) -> <Self as m1::X>::Type." diff --git a/src/test/run-make/missing-items/m1.rs b/src/test/run-make/missing-items/m1.rs new file mode 100644 index 00000000000..060c7a9571b --- /dev/null +++ b/src/test/run-make/missing-items/m1.rs @@ -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. + +#![feature(associated_consts)] +#![crate_type = "dylib"] +pub trait X { + const CONSTANT: u32; + type Type; + fn method(&self, s: String) -> Self::Type; +} diff --git a/src/test/run-make/missing-items/m2.rs b/src/test/run-make/missing-items/m2.rs new file mode 100644 index 00000000000..7055673acc9 --- /dev/null +++ b/src/test/run-make/missing-items/m2.rs @@ -0,0 +1,19 @@ +// 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. + +#![feature(associated_consts)] +#![crate_type = "dylib"] +extern crate m1; + +struct X { +} + +impl m1::X for X { +} diff --git a/src/test/run-pass-fulldeps/empty-struct-braces-derive.rs b/src/test/run-pass-fulldeps/empty-struct-braces-derive.rs index 66ffff94333..79ce3cb68d4 100644 --- a/src/test/run-pass-fulldeps/empty-struct-braces-derive.rs +++ b/src/test/run-pass-fulldeps/empty-struct-braces-derive.rs @@ -10,7 +10,6 @@ // `#[derive(Trait)]` works for empty structs/variants with braces or parens. -#![feature(relaxed_adts)] #![feature(rustc_private)] extern crate serialize as rustc_serialize; diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs index 99586b0bb49..1d34049db24 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs @@ -21,13 +21,12 @@ use proc_macro::TokenStream; #[proc_macro_derive(AddImpl)] // #[cfg(proc_macro)] pub fn derive(input: TokenStream) -> TokenStream { - (input.to_string() + " - impl B { + "impl B { fn foo(&self) {} } fn foo() {} mod bar { pub fn foo() {} } - ").parse().unwrap() + ".parse().unwrap() } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs index 27c3d643ca4..7260bc4a5e7 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs @@ -21,11 +21,8 @@ use proc_macro::TokenStream; #[proc_macro_derive(Append)] pub fn derive_a(input: TokenStream) -> TokenStream { - let mut input = input.to_string(); - input.push_str(" - impl Append for A { - fn foo(&self) {} - } - "); - input.parse().unwrap() + "impl Append for A { + fn foo(&self) {} + } + ".parse().unwrap() } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs index c2de173568b..eaada554227 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs @@ -23,5 +23,5 @@ pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert!(input.contains("struct A;")); assert!(input.contains("#[derive(Debug, PartialEq, Eq, Copy, Clone)]")); - "#[derive(Debug, PartialEq, Eq, Copy, Clone)] struct A;".parse().unwrap() + "".parse().unwrap() } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs new file mode 100644 index 00000000000..a02b798c802 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs @@ -0,0 +1,29 @@ +// Copyright 2016 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. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(B, attributes(B, C))] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("#[B]")); + assert!(input.contains("struct B {")); + assert!(input.contains("#[C]")); + assert!(input.contains("#[derive(Debug, PartialEq, Eq, Copy, Clone)]")); + "".parse().unwrap() +} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs index bd283ca57eb..bc8a0d57591 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs @@ -21,7 +21,7 @@ use proc_macro::TokenStream; #[proc_macro_derive(AToB)] pub fn derive1(input: TokenStream) -> TokenStream { println!("input1: {:?}", input.to_string()); - assert_eq!(input.to_string(), "#[derive(BToC)]\nstruct A;\n"); + assert_eq!(input.to_string(), "struct A;\n"); "#[derive(BToC)] struct B;".parse().unwrap() } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs index 155b125690c..50eaf035962 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs @@ -24,8 +24,6 @@ pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert!(input.contains("struct A;")); r#" - struct A; - impl A { fn a(&self) { panic!("hello"); diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-b.rs b/src/test/run-pass-fulldeps/proc-macro/derive-b.rs new file mode 100644 index 00000000000..f5bb93f0124 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/derive-b.rs @@ -0,0 +1,32 @@ +// Copyright 2016 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. + +// aux-build:derive-b.rs +// ignore-stage1 + +#![feature(proc_macro)] + +#[macro_use] +extern crate derive_b; + +#[derive(Debug, PartialEq, B, Eq, Copy, Clone)] +#[B] +struct B { + #[C] + a: u64 +} + +fn main() { + B { a: 3 }; + assert_eq!(B { a: 3 }, B { a: 3 }); + let b = B { a: 3 }; + let _d = b; + let _e = b; +} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs index b3edc8f1c31..608f86bca57 100644 --- a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs +++ b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs @@ -15,7 +15,7 @@ #[macro_use] extern crate derive_same_struct; -#[derive(AToB, BToC)] +#[derive(AToB)] struct A; fn main() { diff --git a/src/test/run-pass/auxiliary/empty-struct.rs b/src/test/run-pass/auxiliary/empty-struct.rs index b599d7bee73..734e57a774d 100644 --- a/src/test/run-pass/auxiliary/empty-struct.rs +++ b/src/test/run-pass/auxiliary/empty-struct.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(relaxed_adts)] - pub struct XEmpty1 {} pub struct XEmpty2; pub struct XEmpty7(); diff --git a/src/test/run-pass/empty-struct-braces.rs b/src/test/run-pass/empty-struct-braces.rs index 48966f24a2e..7c161ba8dd9 100644 --- a/src/test/run-pass/empty-struct-braces.rs +++ b/src/test/run-pass/empty-struct-braces.rs @@ -13,8 +13,6 @@ // aux-build:empty-struct.rs -#![feature(relaxed_adts)] - extern crate empty_struct; use empty_struct::*; diff --git a/src/test/ui/codemap_tests/two_files.stderr b/src/test/ui/codemap_tests/two_files.stderr index d58e7148f61..d05e6eb2bbe 100644 --- a/src/test/ui/codemap_tests/two_files.stderr +++ b/src/test/ui/codemap_tests/two_files.stderr @@ -2,7 +2,7 @@ error[E0404]: `Bar` is not a trait --> $DIR/two_files.rs:15:6 | 15 | impl Bar for Baz { } - | ^^^ not a trait + | ^^^ expected trait, found type alias | = note: type aliases cannot be used for traits diff --git a/src/test/compile-fail/E0046.rs b/src/test/ui/span/E0046.rs index a8b56b2b9ab..9e757860a85 100644 --- a/src/test/compile-fail/E0046.rs +++ b/src/test/ui/span/E0046.rs @@ -10,6 +10,7 @@ trait Foo { fn foo(); + //~^ NOTE `foo` from trait } struct Bar; diff --git a/src/test/ui/span/E0046.stderr b/src/test/ui/span/E0046.stderr new file mode 100644 index 00000000000..729a5156124 --- /dev/null +++ b/src/test/ui/span/E0046.stderr @@ -0,0 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/E0046.rs:18:1 + | +12 | fn foo(); + | --------- `foo` from trait +... +18 | impl Foo for Bar {} + | ^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error + diff --git a/src/test/compile-fail/impl-wrong-item-for-trait.rs b/src/test/ui/span/impl-wrong-item-for-trait.rs index 388c9a1729c..54ed42af5d5 100644 --- a/src/test/compile-fail/impl-wrong-item-for-trait.rs +++ b/src/test/ui/span/impl-wrong-item-for-trait.rs @@ -10,11 +10,11 @@ #![feature(associated_consts)] +use std::fmt::Debug; + trait Foo { fn bar(&self); - //~^ NOTE item in trait - //~| NOTE item in trait - const MY_CONST: u32; //~ NOTE item in trait + const MY_CONST: u32; } pub struct FooConstForMethod; @@ -50,4 +50,7 @@ impl Foo for FooTypeForMethod { const MY_CONST: u32 = 1; } +impl Debug for FooTypeForMethod { +} + fn main () {} diff --git a/src/test/ui/span/impl-wrong-item-for-trait.stderr b/src/test/ui/span/impl-wrong-item-for-trait.stderr new file mode 100644 index 00000000000..244285e3584 --- /dev/null +++ b/src/test/ui/span/impl-wrong-item-for-trait.stderr @@ -0,0 +1,64 @@ +error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>` + --> $DIR/impl-wrong-item-for-trait.rs:25:5 + | +16 | fn bar(&self); + | -------------- item in trait +... +25 | const bar: u64 = 1; + | ^^^^^^^^^^^^^^^^^^^ does not match trait + +error[E0046]: not all trait items implemented, missing: `bar` + --> $DIR/impl-wrong-item-for-trait.rs:22:1 + | +16 | fn bar(&self); + | -------------- `bar` from trait +... +22 | impl Foo for FooConstForMethod { + | ^ missing `bar` in implementation + +error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `<FooMethodForConst as Foo>` + --> $DIR/impl-wrong-item-for-trait.rs:37:5 + | +17 | const MY_CONST: u32; + | -------------------- item in trait +... +37 | fn MY_CONST() {} + | ^^^^^^^^^^^^^^^^ does not match trait + +error[E0046]: not all trait items implemented, missing: `MY_CONST` + --> $DIR/impl-wrong-item-for-trait.rs:33:1 + | +17 | const MY_CONST: u32; + | -------------------- `MY_CONST` from trait +... +33 | impl Foo for FooMethodForConst { + | ^ missing `MY_CONST` in implementation + +error[E0325]: item `bar` is an associated type, which doesn't match its trait `<FooTypeForMethod as Foo>` + --> $DIR/impl-wrong-item-for-trait.rs:47:5 + | +16 | fn bar(&self); + | -------------- item in trait +... +47 | type bar = u64; + | ^^^^^^^^^^^^^^^ does not match trait + +error[E0046]: not all trait items implemented, missing: `bar` + --> $DIR/impl-wrong-item-for-trait.rs:44:1 + | +16 | fn bar(&self); + | -------------- `bar` from trait +... +44 | impl Foo for FooTypeForMethod { + | ^ missing `bar` in implementation + +error[E0046]: not all trait items implemented, missing: `fmt` + --> $DIR/impl-wrong-item-for-trait.rs:53:1 + | +53 | impl Debug for FooTypeForMethod { + | ^ missing `fmt` in implementation + | + = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` + +error: aborting due to 7 previous errors + diff --git a/src/test/compile-fail/issue-23729.rs b/src/test/ui/span/issue-23729.rs index b1047ce18cc..66134a03baf 100644 --- a/src/test/compile-fail/issue-23729.rs +++ b/src/test/ui/span/issue-23729.rs @@ -20,6 +20,7 @@ fn main() { impl Iterator for Recurrence { //~^ ERROR E0046 //~| NOTE missing `Item` in implementation + //~| NOTE `Item` from trait: `type Item;` #[inline] fn next(&mut self) -> Option<u64> { if self.pos < 2 { diff --git a/src/test/ui/span/issue-23729.stderr b/src/test/ui/span/issue-23729.stderr new file mode 100644 index 00000000000..493ca01778b --- /dev/null +++ b/src/test/ui/span/issue-23729.stderr @@ -0,0 +1,10 @@ +error[E0046]: not all trait items implemented, missing: `Item` + --> $DIR/issue-23729.rs:20:9 + | +20 | impl Iterator for Recurrence { + | ^ missing `Item` in implementation + | + = note: `Item` from trait: `type Item;` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/issue-23827.rs b/src/test/ui/span/issue-23827.rs index 2062e237312..a5ab443597b 100644 --- a/src/test/compile-fail/issue-23827.rs +++ b/src/test/ui/span/issue-23827.rs @@ -36,6 +36,7 @@ impl<C: Component> FnMut<(C,)> for Prototype { impl<C: Component> FnOnce<(C,)> for Prototype { //~^ ERROR E0046 //~| NOTE missing `Output` in implementation + //~| NOTE `Output` from trait: `type Output;` extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype { Fn::call(&self, (comp,)) } diff --git a/src/test/ui/span/issue-23827.stderr b/src/test/ui/span/issue-23827.stderr new file mode 100644 index 00000000000..5130bb53a19 --- /dev/null +++ b/src/test/ui/span/issue-23827.stderr @@ -0,0 +1,10 @@ +error[E0046]: not all trait items implemented, missing: `Output` + --> $DIR/issue-23827.rs:36:1 + | +36 | impl<C: Component> FnOnce<(C,)> for Prototype { + | ^ missing `Output` in implementation + | + = note: `Output` from trait: `type Output;` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/issue-24356.rs b/src/test/ui/span/issue-24356.rs index d39fd539dce..0997dc802f8 100644 --- a/src/test/compile-fail/issue-24356.rs +++ b/src/test/ui/span/issue-24356.rs @@ -30,6 +30,7 @@ fn main() { impl Deref for Thing { //~^ ERROR E0046 //~| NOTE missing `Target` in implementation + //~| NOTE `Target` from trait: `type Target;` fn deref(&self) -> i8 { self.0 } } diff --git a/src/test/ui/span/issue-24356.stderr b/src/test/ui/span/issue-24356.stderr new file mode 100644 index 00000000000..906ef25ca0e --- /dev/null +++ b/src/test/ui/span/issue-24356.stderr @@ -0,0 +1,10 @@ +error[E0046]: not all trait items implemented, missing: `Target` + --> $DIR/issue-24356.rs:30:9 + | +30 | impl Deref for Thing { + | ^ missing `Target` in implementation + | + = note: `Target` from trait: `type Target;` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/issue-16819.rs b/src/test/ui/span/issue-35987.rs index 4301b47f2e9..8ff5f3b8398 100644 --- a/src/test/compile-fail/issue-16819.rs +++ b/src/test/ui/span/issue-35987.rs @@ -1,4 +1,4 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,19 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct TS ( //~ ERROR empty tuple structs and enum variants are unstable - #[cfg(untrue)] - i32, -); +struct Foo<T: Clone>(T); -enum E { - TV ( //~ ERROR empty tuple structs and enum variants are unstable - #[cfg(untrue)] - i32, - ) -} +use std::ops::Add; + +impl<T: Clone, Add> Add for Foo<T> { + type Output = usize; -fn main() { - let s = TS; - let tv = E::TV; + fn add(self, rhs: Self) -> Self::Output { + unimplemented!(); + } } diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr new file mode 100644 index 00000000000..2370b3d6c61 --- /dev/null +++ b/src/test/ui/span/issue-35987.stderr @@ -0,0 +1,12 @@ +error[E0404]: `Add` is not a trait + --> $DIR/issue-35987.rs:15:21 + | +15 | impl<T: Clone, Add> Add for Foo<T> { + | --- ^^^ expected trait, found type parameter + | | + | type parameter defined here + +error: main function not found + +error: cannot continue compilation due to previous error + |
