Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d561a84
Update tests
veera-sivarajan Mar 3, 2024
9aac0c9
Mention Register Size in `#[warn(asm_sub_register)]`
veera-sivarajan Mar 3, 2024
d3299af
transmute: caution against int2ptr transmutation
RalfJung Mar 12, 2024
1bde828
Improve style
veera-sivarajan Mar 13, 2024
982918f
Handle str literals written with `'` lexed as lifetime
estebank Mar 9, 2024
4a10b01
Use shorter span for existing `'` -> `"` structured suggestion
estebank Mar 9, 2024
999a0dc
review comment: `str` -> string in messages
estebank Mar 13, 2024
6f388ef
Extend test to trigger on 2015, 2018 and 2021 editions
estebank Mar 14, 2024
ea1883d
Silence redundant error on char literal that was meant to be a string…
estebank Mar 14, 2024
f4d30b1
fix rustdoc test
estebank Mar 17, 2024
f4adb1e
add notes on how to store 'ptr or int'
RalfJung Mar 14, 2024
2758435
Fix compile of wasm64-unknown-unknown target
alexcrichton Mar 20, 2024
afc99cc
Update test for `aarch64`
veera-sivarajan Mar 20, 2024
063f011
add test for #52334
matthiaskrgr Mar 22, 2024
c3bde24
add test for #64784 Declarative macros can create infinite glob impo…
matthiaskrgr Mar 22, 2024
72d2b59
add test for str as extern "C" arg causes compiler panic #80125
matthiaskrgr Mar 22, 2024
6b0dfc5
add test for ice 83056 "bad input type for cast"
matthiaskrgr Mar 22, 2024
c7ef3cd
add test for #88212 ICE when lambda captures unsized local
matthiaskrgr Mar 22, 2024
3c1db06
add test for 88421 ICE: could not fully normalize `&<MyType as std::o…
matthiaskrgr Mar 22, 2024
efc57fb
add test for ice #90691 ICE: resolution failed during building vtable…
matthiaskrgr Mar 22, 2024
15ef7a0
add test for stack overflow with recursive type #98842
matthiaskrgr Mar 22, 2024
1fcf2ea
Uniquify ReError on input mode in canonicalizer
compiler-errors Mar 22, 2024
dec36c3
CFI: Support self_cell-like recursion
maurer Mar 3, 2024
4e8753b
Rework rmake support library to have a weakly-typed API with helper m…
jieyouxu Mar 13, 2024
246f746
Add test in `higher-ranked`
Luv-Ray Mar 23, 2024
188c46a
regression test for #103626
kadiwa4 Feb 19, 2024
7967915
CFI: Use Instance at callsites
maurer Mar 15, 2024
f434c27
CFI: Strip auto traits off Self for virtual calls
maurer Mar 15, 2024
b6b5745
In `pretty_print_type()`, print `async fn` futures' paths instead of …
kpreid Mar 23, 2024
e74b01e
core/panicking: fix outdated comment
RalfJung Mar 23, 2024
1480b14
add issue numbers via // issue: rust-lang/rust#ISSUE_NUM directive
matthiaskrgr Mar 22, 2024
62dd74b
Rollup merge of #121281 - kadiwa4:test_103626, r=estebank,lcnr
workingjubilee Mar 24, 2024
59ef740
Rollup merge of #121940 - veera-sivarajan:bugfix-121593, r=fmease
workingjubilee Mar 24, 2024
b6681d6
Rollup merge of #122217 - estebank:issue-119685, r=fmease
workingjubilee Mar 24, 2024
0f61527
Rollup merge of #122379 - RalfJung:int2ptr-transmute, r=m-ou-se
workingjubilee Mar 24, 2024
afa0060
Rollup merge of #122460 - jieyouxu:rmake-example-refactor, r=Nilstrieb
workingjubilee Mar 24, 2024
e87c914
Rollup merge of #122797 - alexcrichton:fix-compile-wasm64, r=Mark-Sim…
workingjubilee Mar 24, 2024
5f437ee
Rollup merge of #122875 - maurer:cfi-transparent-termination, r=worki…
workingjubilee Mar 24, 2024
0d52874
Rollup merge of #122879 - maurer:callsite-instances, r=workingjubilee
workingjubilee Mar 24, 2024
a280307
Rollup merge of #122895 - matthiaskrgr:ice-tests-5xxxx-to-9xxxx, r=fm…
workingjubilee Mar 24, 2024
35d575e
Rollup merge of #122907 - compiler-errors:uniquify-reerror, r=lcnr
workingjubilee Mar 24, 2024
7baf5d8
Rollup merge of #122923 - kpreid:print-async-def, r=compiler-errors
workingjubilee Mar 24, 2024
4ea53c0
Rollup merge of #122942 - Luv-Ray:master, r=lcnr
workingjubilee Mar 24, 2024
2dcdbfd
Rollup merge of #122963 - RalfJung:core-panicking, r=m-ou-se
workingjubilee Mar 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use shorter span for existing ' -> " structured suggestion
  • Loading branch information
estebank committed Mar 17, 2024
commit 4a10b01f9504f8ad2ffb9b357845341f4fba6bf0
13 changes: 5 additions & 8 deletions compiler/rustc_infer/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,15 +1339,12 @@ pub enum TypeErrorAdditionalDiags {
span: Span,
code: String,
},
#[suggestion(
infer_meant_str_literal,
code = "\"{code}\"",
applicability = "machine-applicable"
)]
#[multipart_suggestion(infer_meant_str_literal, applicability = "machine-applicable")]
MeantStrLiteral {
#[primary_span]
span: Span,
code: String,
#[suggestion_part(code = "\"")]
start: Span,
#[suggestion_part(code = "\"")]
end: Span,
},
#[suggestion(
infer_consider_specifying_length,
Expand Down
14 changes: 4 additions & 10 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2078,16 +2078,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// If a string was expected and the found expression is a character literal,
// perhaps the user meant to write `"s"` to specify a string literal.
(ty::Ref(_, r, _), ty::Char) if r.is_str() => {
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) {
if let Some(code) =
code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
{
suggestions.push(TypeErrorAdditionalDiags::MeantStrLiteral {
span,
code: escape_literal(code),
})
}
}
suggestions.push(TypeErrorAdditionalDiags::MeantStrLiteral {
start: span.with_hi(span.lo() + BytePos(1)),
end: span.with_lo(span.hi() - BytePos(1)),
})
}
// For code `if Some(..) = expr `, the type mismatch may be expected `bool` but found `()`,
// we try to suggest to add the missing `let` for `if let Some(..) = expr`
Expand Down
11 changes: 10 additions & 1 deletion compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2216,12 +2216,21 @@ pub enum MoreThanOneCharSugg {
ch: String,
},
#[suggestion(parse_use_double_quotes, code = "{sugg}", applicability = "machine-applicable")]
Quotes {
QuotesFull {
#[primary_span]
span: Span,
is_byte: bool,
sugg: String,
},
#[multipart_suggestion(parse_use_double_quotes, applicability = "machine-applicable")]
Quotes {
#[suggestion_part(code = "{prefix}\"")]
start: Span,
#[suggestion_part(code = "\"")]
end: Span,
is_byte: bool,
prefix: &'static str,
},
}

#[derive(Subdiagnostic)]
Expand Down
20 changes: 15 additions & 5 deletions compiler/rustc_parse/src/lexer/unescape_error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,21 @@ pub(crate) fn emit_unescape_error(
}
escaped.push(c);
}
let sugg = format!("{prefix}\"{escaped}\"");
MoreThanOneCharSugg::Quotes {
span: full_lit_span,
is_byte: mode == Mode::Byte,
sugg,
if escaped.len() != lit.len() {
let sugg = format!("{prefix}\"{escaped}\"");
MoreThanOneCharSugg::QuotesFull {
span: full_lit_span,
is_byte: mode == Mode::Byte,
sugg,
}
} else {
MoreThanOneCharSugg::Quotes {
start: full_lit_span
.with_hi(full_lit_span.lo() + BytePos((prefix.len() + 1) as u32)),
end: full_lit_span.with_lo(full_lit_span.hi() - BytePos(1)),
is_byte: mode == Mode::Byte,
prefix,
}
}
});
dcx.emit_err(UnescapeError::MoreThanOneChar {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/inference/str-as-char.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LL | let _: &str = '\"\"\"';
help: if you meant to write a `str` literal, use double quotes
|
LL | let _: &str = "\"\"\"";
| ~~~~~~~~
| ~ ~

error: character literal may only contain one codepoint
--> $DIR/str-as-char.rs:10:19
Expand All @@ -42,7 +42,7 @@ LL | let _: &str = 'a';
help: if you meant to write a `str` literal, use double quotes
|
LL | let _: &str = "a";
| ~~~
| ~ ~

error: aborting due to 4 previous errors

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-23589.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LL | let v: Vec(&str) = vec!['1', '2'];
help: if you meant to write a `str` literal, use double quotes
|
LL | let v: Vec(&str) = vec!["1", '2'];
| ~~~
| ~ ~

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lexer/lex-bad-char-literals-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | 'nope'
help: if you meant to write a `str` literal, use double quotes
|
LL | "nope"
| ~~~~~~
| ~ ~

error: aborting due to 1 previous error

4 changes: 2 additions & 2 deletions tests/ui/lexer/lex-bad-char-literals-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | static c: char = '●●';
help: if you meant to write a `str` literal, use double quotes
|
LL | static c: char = "●●";
| ~~~~
| ~ ~

error: character literal may only contain one codepoint
--> $DIR/lex-bad-char-literals-3.rs:5:20
Expand All @@ -18,7 +18,7 @@ LL | let ch: &str = '●●';
help: if you meant to write a `str` literal, use double quotes
|
LL | let ch: &str = "●●";
| ~~~~
| ~ ~

error: aborting due to 2 previous errors

4 changes: 2 additions & 2 deletions tests/ui/lexer/lex-bad-char-literals-5.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | static c: char = '\x10\x10';
help: if you meant to write a `str` literal, use double quotes
|
LL | static c: char = "\x10\x10";
| ~~~~~~~~~~
| ~ ~

error: character literal may only contain one codepoint
--> $DIR/lex-bad-char-literals-5.rs:5:20
Expand All @@ -18,7 +18,7 @@ LL | let ch: &str = '\x10\x10';
help: if you meant to write a `str` literal, use double quotes
|
LL | let ch: &str = "\x10\x10";
| ~~~~~~~~~~
| ~ ~

error: aborting due to 2 previous errors

6 changes: 3 additions & 3 deletions tests/ui/lexer/lex-bad-char-literals-6.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | let x: &str = 'ab';
help: if you meant to write a `str` literal, use double quotes
|
LL | let x: &str = "ab";
| ~~~~
| ~ ~

error: character literal may only contain one codepoint
--> $DIR/lex-bad-char-literals-6.rs:4:19
Expand All @@ -18,7 +18,7 @@ LL | let y: char = 'cd';
help: if you meant to write a `str` literal, use double quotes
|
LL | let y: char = "cd";
| ~~~~
| ~ ~

error: character literal may only contain one codepoint
--> $DIR/lex-bad-char-literals-6.rs:6:13
Expand All @@ -29,7 +29,7 @@ LL | let z = 'ef';
help: if you meant to write a `str` literal, use double quotes
|
LL | let z = "ef";
| ~~~~
| ~ ~

error[E0308]: mismatched types
--> $DIR/lex-bad-char-literals-6.rs:13:20
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lexer/lex-bad-str-literal-as-char-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | println!(' 1 + 1');
help: if you meant to write a `str` literal, use double quotes
|
LL | println!(" 1 + 1");
| ~~~~~~~~
| ~ ~

error: aborting due to 1 previous error

4 changes: 2 additions & 2 deletions tests/ui/parser/issues/issue-64732.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | let _foo = b'hello\0';
help: if you meant to write a byte string literal, use double quotes
|
LL | let _foo = b"hello\0";
| ~~~~~~~~~~
| ~~ ~

error: character literal may only contain one codepoint
--> $DIR/issue-64732.rs:6:16
Expand All @@ -18,7 +18,7 @@ LL | let _bar = 'hello';
help: if you meant to write a `str` literal, use double quotes
|
LL | let _bar = "hello";
| ~~~~~~~
| ~ ~

error: aborting due to 2 previous errors

4 changes: 2 additions & 2 deletions tests/ui/parser/unicode-character-literal.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | let _spade = '♠️';
help: if you meant to write a `str` literal, use double quotes
|
LL | let _spade = "♠️";
| ~~~
| ~ ~

error: character literal may only contain one codepoint
--> $DIR/unicode-character-literal.rs:12:14
Expand All @@ -28,7 +28,7 @@ LL | let _s = 'ṩ̂̊';
help: if you meant to write a `str` literal, use double quotes
|
LL | let _s = "ṩ̂̊";
| ~~~
| ~ ~

error: character literal may only contain one codepoint
--> $DIR/unicode-character-literal.rs:17:14
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/str/str-as-char.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | println!('●●');
help: if you meant to write a `str` literal, use double quotes
|
LL | println!("●●");
| ~~~~
| ~ ~

error: aborting due to 1 previous error