Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

accept multi-part substitutions #162

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -184,7 +184,7 @@ pub fn collect_suggestions<S: ::std::hash::BuildHasher>(
})
.filter_map(collect_span)
.collect();
if replacements.len() == 1 {
if !replacements.is_empty() {
Some(Solution {
message: child.message.clone(),
replacements,
Expand Down
5 changes: 0 additions & 5 deletions tests/edge-cases/skip-multi-option-lints.fixed.rs

This file was deleted.

100 changes: 0 additions & 100 deletions tests/edge-cases/skip-multi-option-lints.json

This file was deleted.

5 changes: 0 additions & 5 deletions tests/edge-cases/skip-multi-option-lints.rs

This file was deleted.

12 changes: 0 additions & 12 deletions tests/edge_cases.rs

This file was deleted.

6 changes: 6 additions & 0 deletions tests/everything/dot-dot-not-last.fixed.rs
@@ -0,0 +1,6 @@
struct Point { x: isize, y: isize }

fn main() {
let p = Point { x: 1, y: 2 };
let Point { y, .. } = p;
}
126 changes: 126 additions & 0 deletions tests/everything/dot-dot-not-last.json
@@ -0,0 +1,126 @@
{
"message": "expected `}`, found `,`",
"code": null,
"level": "error",
"spans": [
{
"file_name": "$DIR/issue-53934-multiple-parts.rs",
"byte_start": 166,
"byte_end": 167,
"line_start": 7,
"line_end": 7,
"column_start": 19,
"column_end": 20,
"is_primary": true,
"text": [
{
"text": " let Point { .., y, } = p;",
"highlight_start": 19,
"highlight_end": 20
}
],
"label": "expected `}`",
"suggested_replacement": null,
"suggestion_applicability": null,
"expansion": null
},
{
"file_name": "$DIR/issue-53934-multiple-parts.rs",
"byte_start": 164,
"byte_end": 167,
"line_start": 7,
"line_end": 7,
"column_start": 17,
"column_end": 20,
"is_primary": false,
"text": [
{
"text": " let Point { .., y, } = p;",
"highlight_start": 17,
"highlight_end": 20
}
],
"label": "`..` must be at the end and cannot have a trailing comma",
"suggested_replacement": null,
"suggestion_applicability": null,
"expansion": null
}
],
"children": [
{
"message": "move the `..` to the end of the field list",
"code": null,
"level": "help",
"spans": [
{
"file_name": "$DIR/issue-53934-multiple-parts.rs",
"byte_start": 164,
"byte_end": 168,
"line_start": 7,
"line_end": 7,
"column_start": 17,
"column_end": 21,
"is_primary": true,
"text": [
{
"text": " let Point { .., y, } = p;",
"highlight_start": 17,
"highlight_end": 21
}
],
"label": null,
"suggested_replacement": "",
"suggestion_applicability": "MachineApplicable",
"expansion": null
},
{
"file_name": "$DIR/issue-53934-multiple-parts.rs",
"byte_start": 171,
"byte_end": 172,
"line_start": 7,
"line_end": 7,
"column_start": 24,
"column_end": 25,
"is_primary": true,
"text": [
{
"text": " let Point { .., y, } = p;",
"highlight_start": 24,
"highlight_end": 25
}
],
"label": null,
"suggested_replacement": ".. }",
"suggestion_applicability": "MachineApplicable",
"expansion": null
}
],
"children": [],
"rendered": null
}
],
"rendered": "error: expected `}`, found `,`
--> $DIR/issue-53934-multiple-parts.rs:7:19
|
LL | let Point { .., y, } = p;
| --^
| | |
| | expected `}`
| `..` must be at the end and cannot have a trailing comma
help: move the `..` to the end of the field list
|
LL | let Point { y, .. } = p;
| -- ^^^^

"
}
{
"message": "aborting due to previous error",
"code": null,
"level": "error",
"spans": [],
"children": [],
"rendered": "error: aborting due to previous error

"
}
6 changes: 6 additions & 0 deletions tests/everything/dot-dot-not-last.rs
@@ -0,0 +1,6 @@
struct Point { x: isize, y: isize }

fn main() {
let p = Point { x: 1, y: 2 };
let Point { .., y, } = p;
}
11 changes: 11 additions & 0 deletions tests/everything/explicit-outlives-multispan.fixed.rs
@@ -0,0 +1,11 @@
#![allow(dead_code)]
#![deny(explicit_outlives_requirements)]

use std::fmt::Debug;

struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T, U: Debug> {
tee: &'a T,
yoo: &'b U
}

fn main() {}