Files
rust/tests/ui/range/issue-54505.fixed
Esteban Küber e0752ad257 Provide diagnostic for Struct(a, .., z) expression
People might extrapolate from `Struct { .. }` that `Struct(..)` would work, but it doesn't.
2024-12-09 21:55:12 +00:00

45 lines
1.0 KiB
Rust

//@ run-rustfix
// Regression test for #54505 - range borrowing suggestion had
// incorrect syntax (missing parentheses).
use std::ops::RangeBounds;
// take a reference to any built-in range
fn take_range(_r: &impl RangeBounds<i8>) {}
fn main() {
take_range(&(0..1));
//~^ ERROR mismatched types [E0308]
//~| HELP consider borrowing here
//~| SUGGESTION &(
take_range(&(1..));
//~^ ERROR mismatched types [E0308]
//~| HELP consider borrowing here
//~| SUGGESTION &(
take_range(&(..));
//~^ ERROR mismatched types [E0308]
//~| HELP you might have meant
//~| HELP consider borrowing here
//~| SUGGESTION &(
take_range(&(0..=1));
//~^ ERROR mismatched types [E0308]
//~| HELP consider borrowing here
//~| SUGGESTION &(
take_range(&(..5));
//~^ ERROR mismatched types [E0308]
//~| HELP consider borrowing here
//~| SUGGESTION &(
take_range(&(..=42));
//~^ ERROR mismatched types [E0308]
//~| HELP consider borrowing here
//~| SUGGESTION &(
}