File: bounds.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (32 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#![crate_name = "foo"]

pub trait Eq {}
pub trait Eq2 {}

// Checking that "where predicates" and "generics params" are merged.
//@ has 'foo/trait.T.html'
//@ has - "//*[@id='tymethod.f']/h4" "fn f<'a, 'b, 'c, T>()where Self: Eq, T: Eq + 'a, 'c: 'b + 'a,"
pub trait T {
    fn f<'a, 'b, 'c: 'a, T: Eq + 'a>()
        where Self: Eq, Self: Eq, T: Eq, 'c: 'b;
}

// Checking that a duplicated "where predicate" is removed.
//@ has 'foo/trait.T2.html'
//@ has - "//*[@id='tymethod.f']/h4" "fn f<T>()where Self: Eq + Eq2, T: Eq2 + Eq,"
pub trait T2 {
    fn f<T: Eq>()
        where Self: Eq, Self: Eq2, T: Eq2;
}

// Checking that we support empty bounds (we used to crash on empty outlives-bounds).
// Note that we don't want to hide them since they have a semantic effect.
// For outlives-bounds, they force the lifetime param to be early-bound instead of late-bound.
// For trait bounds, it can affect well-formedness (see `ClauseKind::WellFormed`).
//@ has 'foo/fn.empty.html'
//@ has - '//pre[@class="rust item-decl"]' "empty<'a, T>()where T:, 'a:,"
pub fn empty<'a, T>()
    where
        T:,
        'a:,
{}