]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/impl_trait_projections.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / impl-trait / impl_trait_projections.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10 use std::fmt::Debug;
11 use std::option;
12
13 fn parametrized_type_is_allowed() -> Option<impl Debug> {
14     Some(5i32)
15 }
16
17 fn path_parametrized_type_is_allowed() -> option::Option<impl Debug> {
18     Some(5i32)
19 }
20
21 fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item {
22 //~^ ERROR `impl Trait` is not allowed in path parameters
23 //~^^ ERROR ambiguous associated type
24     x.next().unwrap()
25 }
26
27 fn projection_with_named_trait_is_disallowed(x: impl Iterator)
28     -> <impl Iterator as Iterator>::Item
29 //~^ ERROR `impl Trait` is not allowed in path parameters
30 {
31     x.next().unwrap()
32 }
33
34 fn projection_with_named_trait_inside_path_is_disallowed()
35     -> <::std::ops::Range<impl Debug> as Iterator>::Item
36 //~^ ERROR `impl Trait` is not allowed in path parameters
37 {
38     (1i32..100).next().unwrap()
39 }
40
41 fn projection_from_impl_trait_inside_dyn_trait_is_disallowed()
42     -> <dyn Iterator<Item = impl Debug> as Iterator>::Item
43 //~^ ERROR `impl Trait` is not allowed in path parameters
44 {
45     panic!()
46 }
47
48 fn main() {}