]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/issue-90870.rs
Rollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr
[rust.git] / tests / ui / consts / issue-90870.rs
1 // Regression test for issue #90870.
2
3 // run-rustfix
4
5 #![allow(dead_code)]
6
7 const fn f(a: &u8, b: &u8) -> bool {
8     a == b
9     //~^ ERROR: cannot call non-const operator in constant functions [E0015]
10     //~| HELP: consider dereferencing here
11     //~| HELP: add `#![feature(const_trait_impl)]`
12 }
13
14 const fn g(a: &&&&i64, b: &&&&i64) -> bool {
15     a == b
16     //~^ ERROR: cannot call non-const operator in constant functions [E0015]
17     //~| HELP: consider dereferencing here
18     //~| HELP: add `#![feature(const_trait_impl)]`
19 }
20
21 const fn h(mut a: &[u8], mut b: &[u8]) -> bool {
22     while let ([l, at @ ..], [r, bt @ ..]) = (a, b) {
23         if l == r {
24         //~^ ERROR: cannot call non-const operator in constant functions [E0015]
25         //~| HELP: consider dereferencing here
26         //~| HELP: add `#![feature(const_trait_impl)]`
27             a = at;
28             b = bt;
29         } else {
30             return false;
31         }
32     }
33
34     a.is_empty() && b.is_empty()
35 }
36
37 fn main() {}