Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add future incompatibility lint for array.into_iter() #66017

Merged
merged 3 commits into from
Nov 7, 2019

Conversation

LukasKalbertodt
Copy link
Member

@LukasKalbertodt LukasKalbertodt commented Nov 1, 2019

This is for #65819. This lint warns when calling into_iter on an array directly. That's because today the method call resolves to <&[T] as IntoIterator>::into_iter but that would change when adding IntoIterator impls for arrays. This problem is discussed in detail in #65819.

We still haven't decided how to proceed exactly, but it seems like adding a lint is a good idea regardless?

Also: this is the first time I implement a lint, so there are probably a lot of things I can improve. I used a different strategy than @scottmcm describes here since I already started implementing this before they commented.

TODO

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 1, 2019
@rust-highfive

This comment has been minimized.

@scottmcm
Copy link
Member

scottmcm commented Nov 1, 2019

(My way was a hack; a real lint like this is a much better plan.)

I think a lint here is definitely valuable. Could even run it on slices as well, since in theory we might want to be able to use unsized locals to have IntoIterator on non-ref [T] some day. And I've not seen anyone argue that .into_iter() is ever better than .iter() in these situations.

src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
@LukasKalbertodt
Copy link
Member Author

I just pushed a new version. I think it's fine now. My code now checks if the original expr type is an array and if autoref coercion happened. I think this should exactly what we want. At least the UI test now works as you expected.

@rust-highfive

This comment has been minimized.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-11-04T21:00:01.9594777Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-11-04T21:00:01.9794374Z ##[command]git config gc.auto 0
2019-11-04T21:00:01.9878749Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-11-04T21:00:01.9945948Z ##[command]git config --get-all http.proxy
2019-11-04T21:00:02.0094304Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/66017/merge:refs/remotes/pull/66017/merge
---
2019-11-04T22:01:16.3784005Z .................................................................................................... 1600/9276
2019-11-04T22:01:22.1760816Z .................................................................................................... 1700/9276
2019-11-04T22:01:35.0497290Z ..............................................................i...............i..................... 1800/9276
2019-11-04T22:01:42.5549053Z .................................................................................................... 1900/9276
2019-11-04T22:01:58.2437292Z ....................................................iiiii........................................... 2000/9276
2019-11-04T22:02:09.4343041Z .................................................................................................... 2200/9276
2019-11-04T22:02:12.0307920Z .................................................................................................... 2300/9276
2019-11-04T22:02:15.5633352Z .................................................................................................... 2400/9276
2019-11-04T22:02:39.5544987Z .................................................................................................... 2500/9276
2019-11-04T22:02:39.5544987Z .................................................................................................... 2500/9276
2019-11-04T22:02:42.4003116Z .................................................................................................... 2600/9276
2019-11-04T22:02:50.4237480Z .................................................................................................... 2700/9276
2019-11-04T22:02:59.6567255Z ....................i............................................................................... 2800/9276
2019-11-04T22:03:08.6213900Z .................................................................................................... 2900/9276
2019-11-04T22:03:13.3245934Z ...................i................................................................................ 3000/9276
2019-11-04T22:03:22.1647611Z .................................................................................................... 3100/9276
2019-11-04T22:03:27.9262213Z .................................................................................................... 3200/9276
2019-11-04T22:03:36.9409424Z .ii................................................................................................. 3300/9276
2019-11-04T22:03:54.2687887Z ..............................................................................................i..... 3500/9276
2019-11-04T22:04:01.9385631Z .........................................i.......................................................... 3600/9276
2019-11-04T22:04:08.6515267Z .................................................................................................... 3700/9276
2019-11-04T22:04:15.2426161Z .................................................................................................... 3800/9276
---
2019-11-04T22:05:34.5518844Z ....................................................i...............i............................... 4800/9276
2019-11-04T22:05:43.8218320Z .................................................................................................... 4900/9276
2019-11-04T22:05:52.6809376Z .................................................................................................... 5000/9276
2019-11-04T22:05:58.8421506Z .................................................................................................... 5100/9276
2019-11-04T22:06:09.6697751Z .....................................................Fii.ii...........i............................. 5200/9276
2019-11-04T22:06:19.9867639Z .................................................................................................... 5400/9276
2019-11-04T22:06:30.4704251Z .................................................................................................... 5500/9276
2019-11-04T22:06:38.0417351Z ...........................i........................................................................ 5600/9276
2019-11-04T22:06:44.7021796Z .................................................................................................... 5700/9276
2019-11-04T22:06:44.7021796Z .................................................................................................... 5700/9276
2019-11-04T22:06:57.0020735Z .................................................................................................... 5800/9276
2019-11-04T22:07:08.8417751Z ............ii...i..ii...........i.................................................................. 5900/9276
2019-11-04T22:07:29.5669220Z .................................................................................................... 6100/9276
2019-11-04T22:07:38.4662008Z .................................................................................................... 6200/9276
2019-11-04T22:07:38.4662008Z .................................................................................................... 6200/9276
2019-11-04T22:07:52.7849490Z ...............................i..ii................................................................ 6300/9276
2019-11-04T22:08:14.1505153Z ..................................................................................................i. 6500/9276
2019-11-04T22:08:16.4551995Z .................................................................................................... 6600/9276
2019-11-04T22:08:18.7783594Z ............................................................................i....................... 6700/9276
2019-11-04T22:08:21.6294049Z .................................................................................................... 6800/9276
---
2019-11-04T22:13:22.3675500Z failures:
2019-11-04T22:13:22.3718710Z 
2019-11-04T22:13:22.3719238Z ---- [ui] ui/iterators/into-iter-on-arrays-lint.rs stdout ----
2019-11-04T22:13:22.3719281Z 
2019-11-04T22:13:22.3719700Z error: /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:9: unexpected warning: '9:11: 9:20: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!'
2019-11-04T22:13:22.3719767Z 
2019-11-04T22:13:22.3720157Z error: /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:11: unexpected warning: '11:12: 11:21: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!'
2019-11-04T22:13:22.3720225Z 
2019-11-04T22:13:22.3720597Z error: /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:13: unexpected warning: '13:9: 13:18: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!'
2019-11-04T22:13:22.3720644Z 
2019-11-04T22:13:22.3721031Z error: /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:15: unexpected warning: '15:15: 15:24: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!'
2019-11-04T22:13:22.3721132Z error: 4 unexpected errors found, 0 expected errors not found
2019-11-04T22:13:22.3721195Z status: exit code: 0
2019-11-04T22:13:22.3721195Z status: exit code: 0
2019-11-04T22:13:22.3722359Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/into-iter-on-arrays-lint/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/into-iter-on-arrays-lint/auxiliary"
2019-11-04T22:13:22.3722486Z unexpected errors (from JSON output): [
2019-11-04T22:13:22.3722596Z         line_num: 9,
2019-11-04T22:13:22.3722638Z         kind: Some(
2019-11-04T22:13:22.3722689Z             Warning,
2019-11-04T22:13:22.3722729Z         ),
2019-11-04T22:13:22.3722729Z         ),
2019-11-04T22:13:22.3722804Z         msg: "9:11: 9:20: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!",
2019-11-04T22:13:22.3722906Z     Error {
2019-11-04T22:13:22.3722965Z         line_num: 11,
2019-11-04T22:13:22.3723006Z         kind: Some(
2019-11-04T22:13:22.3723048Z             Warning,
2019-11-04T22:13:22.3723048Z             Warning,
2019-11-04T22:13:22.3723105Z         ),
2019-11-04T22:13:22.3723163Z         msg: "11:12: 11:21: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!",
2019-11-04T22:13:22.3723271Z     Error {
2019-11-04T22:13:22.3723312Z         line_num: 13,
2019-11-04T22:13:22.3723353Z         kind: Some(
2019-11-04T22:13:22.3723410Z             Warning,
2019-11-04T22:13:22.3723410Z             Warning,
2019-11-04T22:13:22.3723450Z         ),
2019-11-04T22:13:22.3723507Z         msg: "13:9: 13:18: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!",
2019-11-04T22:13:22.3723787Z     Error {
2019-11-04T22:13:22.3723829Z         line_num: 15,
2019-11-04T22:13:22.3723938Z         kind: Some(
2019-11-04T22:13:22.3724004Z             Warning,
2019-11-04T22:13:22.3724004Z             Warning,
2019-11-04T22:13:22.3724043Z         ),
2019-11-04T22:13:22.3724099Z         msg: "15:15: 15:24: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!",
2019-11-04T22:13:22.3724205Z ]
2019-11-04T22:13:22.3724232Z 
2019-11-04T22:13:22.3724637Z thread '[ui] ui/iterators/into-iter-on-arrays-lint.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:1520:13
2019-11-04T22:13:22.3724721Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
---
2019-11-04T22:13:22.3725411Z 
2019-11-04T22:13:22.3757805Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-11-04T22:13:22.3773215Z 
2019-11-04T22:13:22.3773296Z 
2019-11-04T22:13:22.3778297Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-11-04T22:13:22.3778561Z 
2019-11-04T22:13:22.3778609Z 
2019-11-04T22:13:22.3784579Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-11-04T22:13:22.3784649Z Build completed unsuccessfully in 1:06:26
2019-11-04T22:13:22.3784649Z Build completed unsuccessfully in 1:06:26
2019-11-04T22:13:22.3837597Z == clock drift check ==
2019-11-04T22:13:22.3852274Z   local time: Mon Nov  4 22:13:22 UTC 2019
2019-11-04T22:13:22.6645465Z   network time: Mon, 04 Nov 2019 22:13:22 GMT
2019-11-04T22:13:22.6652871Z == end clock drift check ==
2019-11-04T22:13:24.0745245Z 
2019-11-04T22:13:24.0861388Z ##[error]Bash exited with code '1'.
2019-11-04T22:13:24.0896477Z ##[section]Starting: Checkout
2019-11-04T22:13:24.0898466Z ==============================================================================
2019-11-04T22:13:24.0898527Z Task         : Get sources
2019-11-04T22:13:24.0898579Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@LukasKalbertodt
Copy link
Member Author

Can someone tell me what I'm doing wrong here? x.py test runs perfectly fine locally. Do the //~^ WARNING attributes need to contain the full message? I don't know how these inline annotations work and neither the rustc guide nor compiletest-rs docs are helping me.

@jonas-schievink
Copy link
Contributor

It looks like the future-compat warnings include another warning (?) within the notes. Try changing the annotations like this:

//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
//~| WARNING this was previously accepted by the compiler but is being phased out

@TethysSvensson
Copy link
Contributor

Does this lint catch this example?

trait IntoIteratorExt: IntoIterator + Sized {
    fn into_iter_first(self) -> Option<Self::Item> {
        self.into_iter().next()
    }
}

impl<T: IntoIterator> IntoIteratorExt for T {}

fn foo(value: Option<&i32>) {
    println!("{}", value.unwrap());
}

fn main() {
    foo([1,2,3].into_iter_first());
}

This could potentially be split over multiple crates.

@LukasKalbertodt
Copy link
Member Author

@TethysSvensson Nope, the lint does not catch that. I'd guess this is a lot more complicated to test for. As I won't be able to look into this in the next days, I'd say we merge this as is (if everything else is OK) to get it into 1.40 still. Unless it's too late for that anyway...

From the regressed crates that I looked at, no crate failed due to something like you are suggesting. You are absolutely right that this would break, but as far as I know, we haven't seen this yet. Maybe we can – after merging this PR – create a PR that denies-by-default this lint and run crater on the regressed crates again. By checking how many still regress (this time due to the lint), we can see how many regressions the lint doesn't catch.

@@ -0,0 +1,87 @@
use crate::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe we prefer single line imports.

src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Outdated Show resolved Hide resolved
src/librustc_lint/array_into_iter.rs Show resolved Hide resolved
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-11-06T08:11:00.7138765Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-11-06T08:11:00.7346524Z ##[command]git config gc.auto 0
2019-11-06T08:11:01.2450285Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-11-06T08:11:01.2453886Z ##[command]git config --get-all http.proxy
2019-11-06T08:11:01.2457416Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/66017/merge:refs/remotes/pull/66017/merge
---
2019-11-06T09:21:34.7577381Z .................................................................................................... 1600/9280
2019-11-06T09:21:41.6911758Z .................................................................................................... 1700/9280
2019-11-06T09:21:56.8369074Z ...............................................................i...............i.................... 1800/9280
2019-11-06T09:22:05.8151231Z .................................................................................................... 1900/9280
2019-11-06T09:22:24.4367566Z .....................................................iiiii.......................................... 2000/9280
2019-11-06T09:22:37.6088153Z .................................................................................................... 2200/9280
2019-11-06T09:22:40.7013945Z .................................................................................................... 2300/9280
2019-11-06T09:22:44.7865677Z .................................................................................................... 2400/9280
2019-11-06T09:23:13.1870175Z .................................................................................................... 2500/9280
2019-11-06T09:23:13.1870175Z .................................................................................................... 2500/9280
2019-11-06T09:23:16.6368042Z .................................................................................................... 2600/9280
2019-11-06T09:23:25.8888763Z .................................................................................................... 2700/9280
2019-11-06T09:23:36.4438452Z .....................i.............................................................................. 2800/9280
2019-11-06T09:23:47.2867620Z .................................................................................................... 2900/9280
2019-11-06T09:23:52.6769660Z ....................i............................................................................... 3000/9280
2019-11-06T09:24:02.8973824Z .................................................................................................... 3100/9280
2019-11-06T09:24:09.3980577Z .................................................................................................... 3200/9280
2019-11-06T09:24:20.0036336Z ..ii................................................................................................ 3300/9280
2019-11-06T09:24:39.9989075Z ...............................................................................................i.... 3500/9280
2019-11-06T09:24:48.7149479Z ..........................................i......................................................... 3600/9280
2019-11-06T09:24:56.7367470Z .................................................................................................... 3700/9280
2019-11-06T09:25:04.5715173Z .................................................................................................... 3800/9280
---
2019-11-06T09:26:38.3078419Z .....................................................i...............i.............................. 4800/9280
2019-11-06T09:26:49.4190993Z .................................................................................................... 4900/9280
2019-11-06T09:26:59.9148066Z .................................................................................................... 5000/9280
2019-11-06T09:27:07.4096873Z .................................................................................................... 5100/9280
2019-11-06T09:27:20.4084997Z .....................................................F.ii.ii...........i............................ 5200/9280
2019-11-06T09:27:32.2037635Z .................................................................................................... 5400/9280
2019-11-06T09:27:44.3544121Z .................................................................................................... 5500/9280
2019-11-06T09:27:53.4163072Z ............................i....................................................................... 5600/9280
2019-11-06T09:28:01.5972019Z .................................................................................................... 5700/9280
2019-11-06T09:28:01.5972019Z .................................................................................................... 5700/9280
2019-11-06T09:28:15.9478008Z .................................................................................................... 5800/9280
2019-11-06T09:28:29.9694167Z .............ii...i..ii...........i................................................................. 5900/9280
2019-11-06T09:28:54.3188620Z .................................................................................................... 6100/9280
2019-11-06T09:29:04.6247432Z .................................................................................................... 6200/9280
2019-11-06T09:29:04.6247432Z .................................................................................................... 6200/9280
2019-11-06T09:29:25.3912390Z ................................i..ii............................................................... 6300/9280
2019-11-06T09:29:49.6097520Z ...................................................................................................i 6500/9280
2019-11-06T09:29:52.2400441Z .................................................................................................... 6600/9280
2019-11-06T09:29:54.7770578Z ..............................................................................i..................... 6700/9280
2019-11-06T09:29:57.9520516Z .................................................................................................... 6800/9280
---
2019-11-06T09:32:06.7822133Z .................................................................................................... 7500/9280
2019-11-06T09:32:16.9209600Z .................................................................................................... 7600/9280
2019-11-06T09:32:30.2288711Z .................................................................................................... 7700/9280
2019-11-06T09:32:41.2598567Z .................................................................................................... 7800/9280
2019-11-06T09:32:49.2667034Z .ii......i.......................................................................................... 7900/9280
2019-11-06T09:33:15.5568952Z .................................................................................................... 8100/9280
2019-11-06T09:33:26.2933228Z .................................................................................................... 8200/9280
2019-11-06T09:33:36.3207911Z .................................................................................................... 8300/9280
2019-11-06T09:34:24.4685112Z .................................................................................................... 8400/9280
---
2019-11-06T09:35:51.1985781Z ---- [ui] ui/iterators/into-iter-on-arrays-lint.rs stdout ----
2019-11-06T09:35:51.1986560Z diff of stderr:
2019-11-06T09:35:51.1987973Z 
2019-11-06T09:35:51.1988095Z 34    |
2019-11-06T09:35:51.1988172Z 35    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2019-11-06T09:35:51.1988818Z 36    = note: for more information, see issue #66145 <***/issues/66145>
2019-11-06T09:35:51.1989135Z 37 
2019-11-06T09:35:51.1989182Z 
2019-11-06T09:35:51.1989230Z 
2019-11-06T09:35:51.1989316Z The actual stderr differed from the expected stderr.
2019-11-06T09:35:51.1989316Z The actual stderr differed from the expected stderr.
2019-11-06T09:35:51.1989902Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/into-iter-on-arrays-lint/into-iter-on-arrays-lint.stderr
2019-11-06T09:35:51.1990139Z To update references, rerun the tests and pass the `--bless` flag
2019-11-06T09:35:51.1990597Z To only update this specific test, also pass `--test-args iterators/into-iter-on-arrays-lint.rs`
2019-11-06T09:35:51.1993430Z error: 1 errors occurred comparing output.
2019-11-06T09:35:51.2005219Z status: exit code: 0
2019-11-06T09:35:51.2005219Z status: exit code: 0
2019-11-06T09:35:51.2006516Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/into-iter-on-arrays-lint/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/into-iter-on-arrays-lint/auxiliary"
2019-11-06T09:35:51.2008084Z ------------------------------------------
2019-11-06T09:35:51.2008125Z 
2019-11-06T09:35:51.2008356Z ------------------------------------------
2019-11-06T09:35:51.2008402Z stderr:
2019-11-06T09:35:51.2008402Z stderr:
2019-11-06T09:35:51.2008640Z ------------------------------------------
2019-11-06T09:35:51.2008778Z 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.
2019-11-06T09:35:51.2009061Z   --> /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:9:11
2019-11-06T09:35:51.2009188Z LL |     small.into_iter();
2019-11-06T09:35:51.2009188Z LL |     small.into_iter();
2019-11-06T09:35:51.2009243Z    |           ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
2019-11-06T09:35:51.2009365Z    = note: `#[warn(array_into_iter)]` on by default
2019-11-06T09:35:51.2009365Z    = note: `#[warn(array_into_iter)]` on by default
2019-11-06T09:35:51.2009621Z    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2019-11-06T09:35:51.2010349Z    = note: for more information, see issue #66145 <***/issues/66145>
2019-11-06T09:35:51.2010386Z 
2019-11-06T09:35:51.2010445Z 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.
2019-11-06T09:35:51.2010730Z   --> /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:12:12
2019-11-06T09:35:51.2010815Z LL |     [1, 2].into_iter();
2019-11-06T09:35:51.2010815Z LL |     [1, 2].into_iter();
2019-11-06T09:35:51.2010883Z    |            ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
2019-11-06T09:35:51.2010927Z    |
2019-11-06T09:35:51.2010978Z    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2019-11-06T09:35:51.2011426Z    = note: for more information, see issue #66145 <***/issues/66145>
2019-11-06T09:35:51.2011462Z 
2019-11-06T09:35:51.2011521Z warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
2019-11-06T09:35:51.2011800Z   --> /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:15:9
2019-11-06T09:35:51.2011883Z LL |     big.into_iter();
2019-11-06T09:35:51.2011883Z LL |     big.into_iter();
2019-11-06T09:35:51.2011950Z    |         ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
2019-11-06T09:35:51.2011996Z    |
2019-11-06T09:35:51.2012047Z    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2019-11-06T09:35:51.2012351Z    = note: for more information, see issue #66145 <***/issues/66145>
2019-11-06T09:35:51.2012393Z 
2019-11-06T09:35:51.2012458Z warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
2019-11-06T09:35:51.2012735Z   --> /checkout/src/test/ui/iterators/into-iter-on-arrays-lint.rs:18:15
2019-11-06T09:35:51.2012819Z LL |     [0u8; 33].into_iter();
2019-11-06T09:35:51.2012819Z LL |     [0u8; 33].into_iter();
2019-11-06T09:35:51.2012887Z    |               ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
2019-11-06T09:35:51.2012931Z    |
2019-11-06T09:35:51.2012983Z    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2019-11-06T09:35:51.2013283Z    = note: for more information, see issue #66145 <***/issues/66145>
2019-11-06T09:35:51.2013340Z 
2019-11-06T09:35:51.2013565Z ------------------------------------------
2019-11-06T09:35:51.2013603Z 
2019-11-06T09:35:51.2013626Z 
---
2019-11-06T09:35:51.2023217Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-11-06T09:35:51.2023747Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-11-06T09:35:51.2040061Z 
2019-11-06T09:35:51.2040183Z 
2019-11-06T09:35:51.2041967Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-11-06T09:35:51.2042323Z 
2019-11-06T09:35:51.2042353Z 
2019-11-06T09:35:51.2073303Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-11-06T09:35:51.2073866Z Build completed unsuccessfully in 1:17:37
2019-11-06T09:35:51.2073866Z Build completed unsuccessfully in 1:17:37
2019-11-06T09:35:51.2133662Z == clock drift check ==
2019-11-06T09:35:51.2150256Z   local time: Wed Nov  6 09:35:51 UTC 2019
2019-11-06T09:35:51.3671221Z   network time: Wed, 06 Nov 2019 09:35:51 GMT
2019-11-06T09:35:51.3673192Z == end clock drift check ==
2019-11-06T09:35:52.6907663Z 
2019-11-06T09:35:52.7095105Z ##[error]Bash exited with code '1'.
2019-11-06T09:35:52.7133836Z ##[section]Starting: Checkout
2019-11-06T09:35:52.7137138Z ==============================================================================
2019-11-06T09:35:52.7137223Z Task         : Get sources
2019-11-06T09:35:52.7137271Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 6, 2019

📌 Commit 51a4cd0fc62345ccdf4b698b3b283fcd193e9d59 has been approved by matthewjasper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2019
@matthewjasper
Copy link
Contributor

@bors r-
r=me once tests are green

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 6, 2019
As we might want to add `IntoIterator` impls for arrays in the future,
and since that introduces a breaking change, this lint warns and
suggests using `iter()` instead (which is shorter and more explicit).
@LukasKalbertodt
Copy link
Member Author

Pushed again. Sorry for delay. Should be green now, I tested locally.

@cramertj
Copy link
Member

cramertj commented Nov 6, 2019

@bors r=matthewjasper

@bors
Copy link
Contributor

bors commented Nov 6, 2019

📌 Commit 761ba89 has been approved by matthewjasper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 6, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 7, 2019
…t, r=matthewjasper

Add future incompatibility lint for `array.into_iter()`

This is for rust-lang#65819. This lint warns when calling `into_iter` on an array directly. That's because today the method call resolves to `<&[T] as IntoIterator>::into_iter` but that would change when adding `IntoIterator` impls for arrays. This problem is discussed in detail in rust-lang#65819.

We still haven't decided how to proceed exactly, but it seems like adding a lint is a good idea regardless?

Also: this is the first time I implement a lint, so there are probably a lot of things I can improve. I used a different strategy than @scottmcm describes [here](rust-lang#65819 (comment)) since I already started implementing this before they commented.

### TODO

- [x] Decide if we want this lint -> apparently [we want](rust-lang#65819 (comment))
- [x] Open a lint-tracking-issue and add the correct issue number in the code -> rust-lang#66145
bors added a commit that referenced this pull request Nov 7, 2019
Rollup of 5 pull requests

Successful merges:

 - #59789 (Revert two unapproved changes to rustc_typeck.)
 - #65752 (Use structured suggestions for missing associated items)
 - #65884 (syntax: ABI-oblivious grammar)
 - #65974 (A scheme for more macro-matcher friendly pre-expansion gating)
 - #66017 (Add future incompatibility lint for `array.into_iter()`)

Failed merges:

 - #66056 (rustc_metadata: Some reorganization of the module structure)

r? @ghost
@bors bors merged commit 761ba89 into rust-lang:master Nov 7, 2019
@flip1995
Copy link
Member

flip1995 commented Nov 7, 2019

Well that deprecates the into_iter_on_array Clippy lint 😄

flip1995 added a commit to Manishearth/rust-clippy that referenced this pull request Nov 7, 2019
This lint was uplifted/reimplemented by rustc.
Rustup to rust-lang/rust#66017
flip1995 added a commit to Manishearth/rust-clippy that referenced this pull request Nov 7, 2019
This lint was uplifted/reimplemented by rustc.
Rustup to rust-lang/rust#66017
flip1995 added a commit to Manishearth/rust-clippy that referenced this pull request Nov 7, 2019
This lint was uplifted/reimplemented by rustc.
Rustup to rust-lang/rust#66017
@LukasKalbertodt LukasKalbertodt deleted the array-into-iter-lint branch November 7, 2019 22:39
bors bot added a commit to rust-itertools/itertools that referenced this pull request Sep 22, 2020
475: Trait impls for tuples of arity <= 12 r=jswrenn a=jswrenn

I stopped at 12, because that's where libcore stops.

fixes #428
fixes #398

476: Undeprecate and optimize `fold_while` r=jswrenn a=jswrenn

Prompted by #469.

479: fix compiler warning on array.into_iter() r=jswrenn a=dmitris

Fix the compile warnings listed below by changing `into_iter()` invocation to `iter()` 
in the `impl_zip_iter` macro as recommended in rust-lang/rust#66145.
For additional background, see also rust-lang/rust#65819 and rust-lang/rust#66017 (the latter is the linter change producing the warning).

```
$ cargo build
   Compiling itertools v0.9.0 (/Users/dsavints/dev/hack/github.com/rust-itertools/itertools)
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.
   --> src/ziptuple.rs:111:47
    |
111 |                 let size = *[$( $B.len(), )*].into_iter().min().unwrap();
    |                                               ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
...
128 | impl_zip_iter!(A);
    | ------------------ in this macro invocation
    |
    = note: `#[warn(array_into_iter)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #66145 <rust-lang/rust#66145>
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

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.
   --> src/ziptuple.rs:111:47
    |
111 |                 let size = *[$( $B.len(), )*].into_iter().min().unwrap();
    |                                               ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
...
129 | impl_zip_iter!(A, B);
    | --------------------- in this macro invocation
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #66145 <rust-lang/rust#66145>
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
```

Co-authored-by: Jack Wrenn <[email protected]>
Co-authored-by: Dmitry Savintsev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.