Skip to content

D126 (#2944): the slice fixture spells []T; a &[]T parameter gets a help - #2992

Merged
ehartford merged 1 commit into
mainfrom
d126-slice-demand
Nov 2, 2026
Merged

ehartford merged 1 commit into
mainfrom
d126-slice-demand

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

#2944's example used Rust's &[i32], which With reads as a reference to a slice; with the slice spelling []i32 every case in the issue already works, so the example was wrong (#2987's rule), not the compiler. Fixture moved to test/behavior, row D126 flips, and the argument-mismatch diagnostic helps a &[]T parameter. Battery to follow.

…T` at a parameter gets a help

#2944's example wrote `fn sum(xs: &[i32])`: `&[i32]` parses as `&[]i32`, a
reference to a slice, which no argument satisfies; the slice is `[]i32`,
and with it `sum([1, 2, 3])`, `sum(ys)` and `first(NAMES)` compile and run
on the installed compiler — the example was wrong, not the compiler
(#2987's rule). The open fixture moves to test/behavior with the slice
spelling and the D126 row flips to implemented. The argument-mismatch
diagnostic now adds a help when the parameter is `&[]T`: a slice is
already a view; write `[]T`.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery green on 974476a (out/battery/status.txt: rc= green).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant