Skip to content

Commit 462a8b3

Browse files
committed
Dogfood strip_circumfix
1 parent 838a912 commit 462a8b3

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

compiler/rustc_metadata/src/errors.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ impl<'a> MissingNativeLibrary<'a> {
251251
// if it looks like the user has provided a complete filename rather just the bare lib name,
252252
// then provide a note that they might want to try trimming the name
253253
let suggested_name = if !verbatim {
254-
if let Some(libname) = libname.strip_prefix("lib")
255-
&& let Some(libname) = libname.strip_suffix(".a")
256-
{
254+
if let Some(libname) = libname.strip_circumfix("lib", ".a") {
257255
// this is a unix style filename so trim prefix & suffix
258256
Some(libname)
259257
} else if let Some(libname) = libname.strip_suffix(".lib") {

compiler/rustc_metadata/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![feature(never_type)]
1111
#![feature(proc_macro_internals)]
1212
#![feature(result_option_map_or_default)]
13+
#![feature(strip_circumfix)]
1314
#![feature(trusted_len)]
1415
// tidy-alphabetical-end
1516

compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,8 +1758,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17581758
// specify a byte literal
17591759
(ty::Uint(ty::UintTy::U8), ty::Char) => {
17601760
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span)
1761-
&& let Some(code) =
1762-
code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
1761+
&& let Some(code) = code.strip_circumfix('\'', '\'')
17631762
// forbid all Unicode escapes
17641763
&& !code.starts_with("\\u")
17651764
// forbids literal Unicode characters beyond ASCII
@@ -1776,7 +1775,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17761775
// specify a character literal (issue #92479)
17771776
(ty::Char, ty::Ref(_, r, _)) if r.is_str() => {
17781777
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span)
1779-
&& let Some(code) = code.strip_prefix('"').and_then(|s| s.strip_suffix('"'))
1778+
&& let Some(code) = code.strip_circumfix('"', '"')
17801779
&& code.chars().count() == 1
17811780
{
17821781
suggestions.push(TypeErrorAdditionalDiags::MeantCharLiteral {

compiler/rustc_trait_selection/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#![feature(iter_intersperse)]
2323
#![feature(iterator_try_reduce)]
2424
#![feature(never_type)]
25+
#![feature(strip_circumfix)]
2526
#![feature(try_blocks)]
2627
#![feature(unwrap_infallible)]
2728
#![feature(yeet_expr)]

0 commit comments

Comments
 (0)