Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
378 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// run-rustfix | ||
|
||
// Regression test for changes introduced while fixing #54505 | ||
|
||
// This test uses non-literals for Ranges | ||
// (expecting no parens with borrow suggestion) | ||
|
||
use std::ops::RangeBounds; | ||
|
||
|
||
// take a reference to any built-in range | ||
fn take_range(_r: &impl RangeBounds<i8>) {} | ||
|
||
|
||
fn main() { | ||
take_range(std::ops::Range { start: 0, end: 1 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &std::ops::Range { start: 0, end: 1 } | ||
|
||
take_range(::std::ops::Range { start: 0, end: 1 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } | ||
|
||
take_range(std::ops::RangeFrom { start: 1 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &std::ops::RangeFrom { start: 1 } | ||
|
||
take_range(::std::ops::RangeFrom { start: 1 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &::std::ops::RangeFrom { start: 1 } | ||
|
||
take_range(std::ops::RangeFull {}); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &std::ops::RangeFull {} | ||
|
||
take_range(::std::ops::RangeFull {}); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &::std::ops::RangeFull {} | ||
|
||
take_range(std::ops::RangeInclusive::new(0, 1)); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) | ||
|
||
take_range(::std::ops::RangeInclusive::new(0, 1)); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) | ||
|
||
take_range(std::ops::RangeTo { end: 5 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &std::ops::RangeTo { end: 5 } | ||
|
||
take_range(::std::ops::RangeTo { end: 5 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &::std::ops::RangeTo { end: 5 } | ||
|
||
take_range(std::ops::RangeToInclusive { end: 5 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } | ||
|
||
take_range(::std::ops::RangeToInclusive { end: 5 }); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// run-rustfix | ||
// error-pattern: error: `#[panic_handler]` function required, but not found | ||
// error-pattern: language item required, but not found: `panic_info` | ||
|
||
|
||
// Regression test for #54505 - range borrowing suggestion had | ||
// incorrect syntax (missing parentheses). | ||
|
||
// This test doesn't use std | ||
// (so all Ranges resolve to core::ops::Range...) | ||
|
||
#![no_std] | ||
|
||
use core::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 &(0..1) | ||
|
||
take_range(1..); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(1..) | ||
|
||
take_range(..); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..) | ||
|
||
take_range(0..=1); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(0..=1) | ||
|
||
take_range(..5); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..5) | ||
|
||
take_range(..=42); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..=42) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// 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 &(0..1) | ||
|
||
take_range(&(1..)); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(1..) | ||
|
||
take_range(&(..)); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..) | ||
|
||
take_range(&(0..=1)); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(0..=1) | ||
|
||
take_range(&(..5)); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..5) | ||
|
||
take_range(&(..=42)); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..=42) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// 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 &(0..1) | ||
|
||
take_range(1..); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(1..) | ||
|
||
take_range(..); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..) | ||
|
||
take_range(0..=1); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(0..=1) | ||
|
||
take_range(..5); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..5) | ||
|
||
take_range(..=42); | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider borrowing here | ||
//~| SUGGESTION &(..=42) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-54505.rs:24:16 | ||
| | ||
LL | take_range(0..1); | ||
| ^^^^ | ||
| | | ||
| expected reference, found struct `std::ops::Range` | ||
| help: consider borrowing here: `&(0..1)` | ||
| | ||
= note: expected type `&_` | ||
found type `std::ops::Range<{integer}>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-54505.rs:29:16 | ||
| | ||
LL | take_range(1..); | ||
| ^^^ | ||
| | | ||
| expected reference, found struct `std::ops::RangeFrom` | ||
| help: consider borrowing here: `&(1..)` | ||
| | ||
= note: expected type `&_` | ||
found type `std::ops::RangeFrom<{integer}>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-54505.rs:34:16 | ||
| | ||
LL | take_range(..); | ||
| ^^ | ||
| | | ||
| expected reference, found struct `std::ops::RangeFull` | ||
| help: consider borrowing here: `&(..)` | ||
| | ||
= note: expected type `&_` | ||
found type `std::ops::RangeFull` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-54505.rs:39:16 | ||
| | ||
LL | take_range(0..=1); | ||
| ^^^^^ | ||
| | | ||
| expected reference, found struct `std::ops::RangeInclusive` | ||
| help: consider borrowing here: `&(0..=1)` | ||
| | ||
= note: expected type `&_` | ||
found type `std::ops::RangeInclusive<{integer}>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-54505.rs:44:16 | ||
| | ||
LL | take_range(..5); | ||
| ^^^ | ||
| | | ||
| expected reference, found struct `std::ops::RangeTo` | ||
| help: consider borrowing here: `&(..5)` | ||
| | ||
= note: expected type `&_` | ||
found type `std::ops::RangeTo<{integer}>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-54505.rs:49:16 | ||
| | ||
LL | take_range(..=42); | ||
| ^^^^^ | ||
| | | ||
| expected reference, found struct `std::ops::RangeToInclusive` | ||
| help: consider borrowing here: `&(..=42)` | ||
| | ||
= note: expected type `&_` | ||
found type `std::ops::RangeToInclusive<{integer}>` | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |