Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4621ce9

Browse files
committed
Update into-iter-on-arrays test to check future-incompat-report
1 parent 4b4f84f commit 4621ce9

File tree

4 files changed

+165
-12
lines changed

4 files changed

+165
-12
lines changed

src/test/ui/iterators/into-iter-on-arrays-lint.fixed

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-pass
22
// run-rustfix
3-
// compiler-flags: -Z emit-future-compat-report
3+
// compile-flags: -Z emit-future-incompat-report
44

55
fn main() {
66
let small = [1, 2];
@@ -56,4 +56,7 @@ fn main() {
5656
(&small as &[_]).into_iter();
5757
small[..].into_iter();
5858
std::iter::IntoIterator::into_iter(&[1, 2]);
59+
60+
#[allow(array_into_iter)]
61+
[0, 1].into_iter();
5962
}

src/test/ui/iterators/into-iter-on-arrays-lint.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ fn main() {
5656
(&small as &[_]).into_iter();
5757
small[..].into_iter();
5858
std::iter::IntoIterator::into_iter(&[1, 2]);
59+
60+
#[allow(array_into_iter)]
61+
[0, 1].into_iter();
5962
}

src/test/ui/iterators/into-iter-on-arrays-lint.stderr

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,139 @@ LL | Box::new(Box::new([0u8; 33])).into_iter();
109109

110110
warning: 12 warnings emitted
111111

112+
Future incompatibility report: Future breakage date: None, diagnostic:
113+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
114+
--> $DIR/into-iter-on-arrays-lint.rs:10:11
115+
|
116+
LL | small.into_iter();
117+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
118+
|
119+
= note: `#[warn(array_into_iter)]` on by default
120+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
121+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
122+
123+
Future breakage date: None, diagnostic:
124+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
125+
--> $DIR/into-iter-on-arrays-lint.rs:13:12
126+
|
127+
LL | [1, 2].into_iter();
128+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
129+
|
130+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
131+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
132+
133+
Future breakage date: None, diagnostic:
134+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
135+
--> $DIR/into-iter-on-arrays-lint.rs:16:9
136+
|
137+
LL | big.into_iter();
138+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
139+
|
140+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
141+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
142+
143+
Future breakage date: None, diagnostic:
144+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
145+
--> $DIR/into-iter-on-arrays-lint.rs:19:15
146+
|
147+
LL | [0u8; 33].into_iter();
148+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
149+
|
150+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
151+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
152+
153+
Future breakage date: None, diagnostic:
154+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
155+
--> $DIR/into-iter-on-arrays-lint.rs:23:21
156+
|
157+
LL | Box::new(small).into_iter();
158+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
159+
|
160+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
161+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
162+
163+
Future breakage date: None, diagnostic:
164+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
165+
--> $DIR/into-iter-on-arrays-lint.rs:26:22
166+
|
167+
LL | Box::new([1, 2]).into_iter();
168+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
169+
|
170+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
171+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
172+
173+
Future breakage date: None, diagnostic:
174+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
175+
--> $DIR/into-iter-on-arrays-lint.rs:29:19
176+
|
177+
LL | Box::new(big).into_iter();
178+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
179+
|
180+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
181+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
182+
183+
Future breakage date: None, diagnostic:
184+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
185+
--> $DIR/into-iter-on-arrays-lint.rs:32:25
186+
|
187+
LL | Box::new([0u8; 33]).into_iter();
188+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
189+
|
190+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
191+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
192+
193+
Future breakage date: None, diagnostic:
194+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
195+
--> $DIR/into-iter-on-arrays-lint.rs:36:31
196+
|
197+
LL | Box::new(Box::new(small)).into_iter();
198+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
199+
|
200+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
201+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
202+
203+
Future breakage date: None, diagnostic:
204+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
205+
--> $DIR/into-iter-on-arrays-lint.rs:39:32
206+
|
207+
LL | Box::new(Box::new([1, 2])).into_iter();
208+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
209+
|
210+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
211+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
212+
213+
Future breakage date: None, diagnostic:
214+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
215+
--> $DIR/into-iter-on-arrays-lint.rs:42:29
216+
|
217+
LL | Box::new(Box::new(big)).into_iter();
218+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
219+
|
220+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
221+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
222+
223+
Future breakage date: None, diagnostic:
224+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
225+
--> $DIR/into-iter-on-arrays-lint.rs:45:35
226+
|
227+
LL | Box::new(Box::new([0u8; 33])).into_iter();
228+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
229+
|
230+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
231+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
232+
233+
Future breakage date: None, diagnostic:
234+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
235+
--> $DIR/into-iter-on-arrays-lint.rs:61:12
236+
|
237+
LL | [0, 1].into_iter();
238+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
239+
|
240+
note: the lint level is defined here
241+
--> $DIR/into-iter-on-arrays-lint.rs:60:13
242+
|
243+
LL | #[allow(array_into_iter)]
244+
| ^^^^^^^^^^^^^^^
245+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
246+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
247+

src/tools/compiletest/src/json.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ struct DiagnosticSpan {
3838

3939
#[derive(Deserialize)]
4040
struct FutureIncompatReport {
41-
future_incompat_report: Vec<FutureBreakageItem>
41+
future_incompat_report: Vec<FutureBreakageItem>,
4242
}
4343

4444
#[derive(Deserialize)]
4545
struct FutureBreakageItem {
4646
future_breakage_date: Option<String>,
47-
diagnostic: Diagnostic
47+
diagnostic: Diagnostic,
4848
}
4949

5050
impl DiagnosticSpan {
@@ -80,9 +80,10 @@ struct DiagnosticCode {
8080
}
8181

8282
pub fn rustfix_diagnostics_only(output: &str) -> String {
83-
output.lines().filter(|line| {
84-
line.starts_with('{') && serde_json::from_str::<Diagnostic>(line).is_ok()
85-
}).collect()
83+
output
84+
.lines()
85+
.filter(|line| line.starts_with('{') && serde_json::from_str::<Diagnostic>(line).is_ok())
86+
.collect()
8687
}
8788

8889
pub fn extract_rendered(output: &str) -> String {
@@ -93,12 +94,22 @@ pub fn extract_rendered(output: &str) -> String {
9394
if let Ok(diagnostic) = serde_json::from_str::<Diagnostic>(line) {
9495
diagnostic.rendered
9596
} else if let Ok(report) = serde_json::from_str::<FutureIncompatReport>(line) {
96-
Some(format!("Future incompatibility report: {}",
97-
report.future_incompat_report.into_iter().map(|item| {
98-
format!("Future breakage date: {}, diagnostic:\n{}",
99-
item.future_breakage_date.unwrap_or_else(|| "None".to_string()),
100-
item.diagnostic.rendered.unwrap_or_else(|| "Not rendered".to_string()))
101-
}).collect::<String>()))
97+
Some(format!(
98+
"Future incompatibility report: {}",
99+
report
100+
.future_incompat_report
101+
.into_iter()
102+
.map(|item| {
103+
format!(
104+
"Future breakage date: {}, diagnostic:\n{}",
105+
item.future_breakage_date.unwrap_or_else(|| "None".to_string()),
106+
item.diagnostic
107+
.rendered
108+
.unwrap_or_else(|| "Not rendered".to_string())
109+
)
110+
})
111+
.collect::<String>()
112+
))
102113
} else if serde_json::from_str::<ArtifactNotification>(line).is_ok() {
103114
// Ignore the notification.
104115
None

0 commit comments

Comments
 (0)