]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/manual_main_separator_str.fixed
New upstream version 1.74.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / manual_main_separator_str.fixed
CommitLineData
353b0b11
FG
1#![allow(unused)]
2#![warn(clippy::manual_main_separator_str)]
3
4use std::path::MAIN_SEPARATOR;
5
6fn len(s: &str) -> usize {
7 s.len()
8}
9
10struct U<'a> {
11 f: &'a str,
12 g: &'a String,
13}
14
15struct V<T> {
16 f: T,
17}
18
19fn main() {
20 // Should lint
21 let _: &str = std::path::MAIN_SEPARATOR_STR;
22 let _ = len(std::path::MAIN_SEPARATOR_STR);
23 let _: Vec<u16> = std::path::MAIN_SEPARATOR_STR.encode_utf16().collect();
24
25 // Should lint for field `f` only
26 let _ = U {
27 f: std::path::MAIN_SEPARATOR_STR,
28 g: &MAIN_SEPARATOR.to_string(),
29 };
30
31 // Should not lint
32 let _: &String = &MAIN_SEPARATOR.to_string();
33 let _ = &MAIN_SEPARATOR.to_string();
34 let _ = V {
35 f: &MAIN_SEPARATOR.to_string(),
36 };
37}