Skip to content

Commit bd1f5b5

Browse files
committed
Add localhost.txt and more test cases for external included expression
1 parent f0c88b1 commit bd1f5b5

7 files changed

+25
-57
lines changed

tests/ui/ip_constant.fixed

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,6 @@ fn macro_test() {
102102
// no lint
103103
}
104104

105-
include!("ip_constant_included.rs");
106-
107-
fn external_constant_test() {
108-
use std::net::{Ipv4Addr, Ipv6Addr};
109-
110-
let _ = Ipv4Addr::LOCALHOST;
111-
//~^ ip_constant
112-
113-
let _ = Ipv6Addr::LOCALHOST;
114-
}
115-
116105
fn main() {
117106
// UI Test
118107
}

tests/ui/ip_constant.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,6 @@ fn macro_test() {
122122
// no lint
123123
}
124124

125-
include!("ip_constant_included.rs");
126-
127-
fn external_constant_test() {
128-
use std::net::{Ipv4Addr, Ipv6Addr};
129-
130-
let _ = Ipv4Addr::new(EXTERNAL_CONST_U8_127, 0, 0, 1);
131-
//~^ ip_constant
132-
133-
let _ = Ipv6Addr::new(
134-
//~^ ip_constant
135-
EXTERNAL_CONST_U16_0,
136-
0,
137-
0,
138-
0,
139-
0,
140-
0,
141-
0,
142-
1,
143-
);
144-
}
145-
146125
fn main() {
147126
// UI Test
148127
}

tests/ui/ip_constant.stderr

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,5 @@ error: use `Ipv6Addr::LOCALHOST` instead
165165
LL | let _ = Ipv6Addr::new(0 + 0, 0, 0, 0, 0, { 2 - 1 - CONST_U16_1 }, 0, 1);
166166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ipv6Addr::LOCALHOST`
167167

168-
error: use `Ipv4Addr::LOCALHOST` instead
169-
--> tests/ui/ip_constant.rs:130:13
170-
|
171-
LL | let _ = Ipv4Addr::new(EXTERNAL_CONST_U8_127, 0, 0, 1);
172-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ipv4Addr::LOCALHOST`
173-
174-
error: use `Ipv6Addr::LOCALHOST` instead
175-
--> tests/ui/ip_constant.rs:133:13
176-
|
177-
LL | let _ = Ipv6Addr::new(
178-
| _____________^
179-
LL | |
180-
LL | | EXTERNAL_CONST_U16_0,
181-
LL | | 0,
182-
... |
183-
LL | | 1,
184-
LL | | );
185-
| |_____^ help: try: `Ipv6Addr::LOCALHOST`
186-
187-
error: aborting due to 27 previous errors
168+
error: aborting due to 25 previous errors
188169

tests/ui/ip_constant_from_external.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@error-in-other-file: use `std::net::Ipv4Addr::LOCALHOST` instead
2+
//@no-rustfix
3+
#![warn(clippy::ip_constant)]
4+
5+
fn external_constant_test() {
6+
let _ = include!("localhost.txt");
7+
// lint in external file `localhost.txt`
8+
}
9+
10+
fn main() {
11+
external_constant_test();
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: use `std::net::Ipv4Addr::LOCALHOST` instead
2+
--> tests/ui/localhost.txt:1:1
3+
|
4+
LL | std::net::Ipv4Addr::new(127, 0, 0, 1)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::net::Ipv4Addr::LOCALHOST`
6+
|
7+
= note: `-D clippy::ip-constant` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::ip_constant)]`
9+
10+
error: aborting due to 1 previous error
11+

tests/ui/ip_constant_included.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/ui/localhost.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
std::net::Ipv4Addr::new(127, 0, 0, 1)

0 commit comments

Comments
 (0)