reword the message to suggest surrounding with parentheses
This commit is contained in:
parent
3983881d4e
commit
e3071eaa60
@ -695,7 +695,7 @@ parse_struct_literal_body_without_path =
|
|||||||
|
|
||||||
parse_struct_literal_needing_parens =
|
parse_struct_literal_needing_parens =
|
||||||
invalid struct literal
|
invalid struct literal
|
||||||
.suggestion = you might need to surround the struct literal in parentheses
|
.suggestion = you might need to surround the struct literal with parentheses
|
||||||
|
|
||||||
parse_struct_literal_not_allowed_here = struct literals are not allowed here
|
parse_struct_literal_not_allowed_here = struct literals are not allowed here
|
||||||
.suggestion = surround the struct literal with parentheses
|
.suggestion = surround the struct literal with parentheses
|
||||||
|
@ -751,7 +751,10 @@ pub fn span_extend_prev_while(
|
|||||||
f: impl Fn(char) -> bool,
|
f: impl Fn(char) -> bool,
|
||||||
) -> Result<Span, SpanSnippetError> {
|
) -> Result<Span, SpanSnippetError> {
|
||||||
self.span_to_source(span, |s, start, _end| {
|
self.span_to_source(span, |s, start, _end| {
|
||||||
let n = s[..start].char_indices().rfind(|&(_, c)| !f(c)).map_or(start, |(i, _)| start - i - 1);
|
let n = s[..start]
|
||||||
|
.char_indices()
|
||||||
|
.rfind(|&(_, c)| !f(c))
|
||||||
|
.map_or(start, |(i, _)| start - i - 1);
|
||||||
Ok(span.with_lo(span.lo() - BytePos(n as u32)))
|
Ok(span.with_lo(span.lo() - BytePos(n as u32)))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ error: invalid struct literal
|
|||||||
LL | if x == module::Type { x: module::C, y: 1 } {
|
LL | if x == module::Type { x: module::C, y: 1 } {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
help: you might need to surround the struct literal in parentheses
|
help: you might need to surround the struct literal with parentheses
|
||||||
|
|
|
|
||||||
LL | if x == (module::Type { x: module::C, y: 1 }) {
|
LL | if x == (module::Type { x: module::C, y: 1 }) {
|
||||||
| + +
|
| + +
|
||||||
@ -15,7 +15,7 @@ error: invalid struct literal
|
|||||||
LL | if x ==module::Type { x: module::C, y: 1 } {
|
LL | if x ==module::Type { x: module::C, y: 1 } {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
help: you might need to surround the struct literal in parentheses
|
help: you might need to surround the struct literal with parentheses
|
||||||
|
|
|
|
||||||
LL | if x ==(module::Type { x: module::C, y: 1 }) {
|
LL | if x ==(module::Type { x: module::C, y: 1 }) {
|
||||||
| + +
|
| + +
|
||||||
@ -26,7 +26,7 @@ error: invalid struct literal
|
|||||||
LL | if x == Type { x: module::C, y: 1 } {
|
LL | if x == Type { x: module::C, y: 1 } {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
help: you might need to surround the struct literal in parentheses
|
help: you might need to surround the struct literal with parentheses
|
||||||
|
|
|
|
||||||
LL | if x == (Type { x: module::C, y: 1 }) {
|
LL | if x == (Type { x: module::C, y: 1 }) {
|
||||||
| + +
|
| + +
|
||||||
@ -37,7 +37,7 @@ error: invalid struct literal
|
|||||||
LL | if x == demo_module::Type { x: module::C, y: 1 } {
|
LL | if x == demo_module::Type { x: module::C, y: 1 } {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
help: you might need to surround the struct literal in parentheses
|
help: you might need to surround the struct literal with parentheses
|
||||||
|
|
|
|
||||||
LL | if x == (demo_module::Type { x: module::C, y: 1 }) {
|
LL | if x == (demo_module::Type { x: module::C, y: 1 }) {
|
||||||
| + +
|
| + +
|
||||||
|
@ -4,7 +4,7 @@ error: invalid struct literal
|
|||||||
LL | if Example { a: one(), }.is_pos() {
|
LL | if Example { a: one(), }.is_pos() {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
help: you might need to surround the struct literal in parentheses
|
help: you might need to surround the struct literal with parentheses
|
||||||
|
|
|
|
||||||
LL | if (Example { a: one(), }).is_pos() {
|
LL | if (Example { a: one(), }).is_pos() {
|
||||||
| + +
|
| + +
|
||||||
|
Loading…
Reference in New Issue
Block a user