Skip to content

Commit

Permalink
Auto merge of #124097 - compiler-errors:box-into-iter, r=WaffleLapkin
Browse files Browse the repository at this point in the history
Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints

* Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021.
* Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity).
* Adds some tests.
* Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing.

Based mostly off of #116607.

ACP: rust-lang/libs-team#263
References #59878
Tracking for Rust 2024: rust-lang/rust#123759

Crater run was done here: rust-lang/rust#116607 (comment)
Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.
  • Loading branch information
bors committed May 21, 2024
2 parents 0b2bf65 + d074351 commit ff11eae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/fail/shims/backtrace/bad-backtrace-decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern "Rust" {

fn main() {
let frames = unsafe { miri_get_backtrace(0) };
for frame in frames.into_iter() {
for frame in frames.iter() {
unsafe {
miri_resolve_frame(*frame, 0); //~ ERROR: Undefined Behavior: bad declaration of miri_resolve_frame - should return a struct with 5 fields
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/backtrace/backtrace-api-v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn func_d() -> Box<[*mut ()]> {
fn main() {
let mut seen_main = false;
let frames = func_a();
for frame in frames.into_iter() {
for frame in frames.iter() {
let miri_frame = unsafe { miri_resolve_frame(*frame, 0) };
let name = String::from_utf8(miri_frame.name.into()).unwrap();
let filename = String::from_utf8(miri_frame.filename.into()).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/backtrace/backtrace-api-v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn func_d() -> Box<[*mut ()]> {
fn main() {
let mut seen_main = false;
let frames = func_a();
for frame in frames.into_iter() {
for frame in frames.iter() {
let miri_frame = unsafe { miri_resolve_frame(*frame, 1) };

let mut name = vec![0; miri_frame.name_len];
Expand Down

0 comments on commit ff11eae

Please sign in to comment.