about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/lexer
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-01-09 09:08:49 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-01-10 07:40:00 +1100
commited76b0b882d0acff9295bcd76c2b119cf83e7219 (patch)
treeb40f6c489904d201833e5e446afbfbee1501e26a /compiler/rustc_parse/src/lexer
parent2ea7a37e1113febac8603729e33fdd94f2738807 (diff)
downloadrust-ed76b0b882d0acff9295bcd76c2b119cf83e7219.tar.gz
rust-ed76b0b882d0acff9295bcd76c2b119cf83e7219.zip
Rename consuming chaining methods on `DiagnosticBuilder`.
In #119606 I added them and used a `_mv` suffix, but that wasn't great.

A `with_` prefix has three different existing uses.
- Constructors, e.g. `Vec::with_capacity`.
- Wrappers that provide an environment to execute some code, e.g.
  `with_session_globals`.
- Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`.

The third case is exactly what we want, so this commit changes
`DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`.

Thanks to @compiler-errors for the suggestion.
Diffstat (limited to 'compiler/rustc_parse/src/lexer')
-rw-r--r--compiler/rustc_parse/src/lexer/mod.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs
index a45bc581240..7db9291921f 100644
--- a/compiler/rustc_parse/src/lexer/mod.rs
+++ b/compiler/rustc_parse/src/lexer/mod.rs
@@ -250,7 +250,7 @@ impl<'a> StringReader<'a> {
                     if starts_with_number {
                         let span = self.mk_sp(start, self.pos);
                         self.dcx().struct_err("lifetimes cannot start with a number")
-                            .span_mv(span)
+                            .with_span(span)
                             .stash(span, StashKey::LifetimeIsChar);
                     }
                     let ident = Symbol::intern(lifetime_name);
@@ -397,7 +397,7 @@ impl<'a> StringReader<'a> {
                 if !terminated {
                     self.dcx()
                         .struct_span_fatal(self.mk_sp(start, end), "unterminated character literal")
-                        .code_mv(error_code!(E0762))
+                        .with_code(error_code!(E0762))
                         .emit()
                 }
                 self.cook_quoted(token::Char, Mode::Char, start, end, 1, 1) // ' '
@@ -409,7 +409,7 @@ impl<'a> StringReader<'a> {
                             self.mk_sp(start + BytePos(1), end),
                             "unterminated byte constant",
                         )
-                        .code_mv(error_code!(E0763))
+                        .with_code(error_code!(E0763))
                         .emit()
                 }
                 self.cook_quoted(token::Byte, Mode::Byte, start, end, 2, 1) // b' '
@@ -421,7 +421,7 @@ impl<'a> StringReader<'a> {
                             self.mk_sp(start, end),
                             "unterminated double quote string",
                         )
-                        .code_mv(error_code!(E0765))
+                        .with_code(error_code!(E0765))
                         .emit()
                 }
                 self.cook_quoted(token::Str, Mode::Str, start, end, 1, 1) // " "
@@ -433,7 +433,7 @@ impl<'a> StringReader<'a> {
                             self.mk_sp(start + BytePos(1), end),
                             "unterminated double quote byte string",
                         )
-                        .code_mv(error_code!(E0766))
+                        .with_code(error_code!(E0766))
                         .emit()
                 }
                 self.cook_quoted(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
@@ -445,7 +445,7 @@ impl<'a> StringReader<'a> {
                             self.mk_sp(start + BytePos(1), end),
                             "unterminated C string",
                         )
-                        .code_mv(error_code!(E0767))
+                        .with_code(error_code!(E0767))
                         .emit()
                 }
                 self.cook_c_string(token::CStr, Mode::CStr, start, end, 2, 1) // c" "