about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-10-06 16:26:11 +0900
committerGitHub <noreply@github.com>2020-10-06 16:26:11 +0900
commit22c5e0c34760b5d8f8a3c815f01ca2ed20d4ceeb (patch)
tree3f55e30cd3d36b311de56f83a14ab3fabf68ef36
parenta7b721968a75be2b21c180d87328db02eb823376 (diff)
parentf34f4a732714c397c30055feddb2b520b6acd38e (diff)
downloadrust-22c5e0c34760b5d8f8a3c815f01ca2ed20d4ceeb.tar.gz
rust-22c5e0c34760b5d8f8a3c815f01ca2ed20d4ceeb.zip
Rollup merge of #77560 - rschoon:fix-litkind-rc-bytebuf, r=lcnr
Fix LitKind's byte buffer to use refcounted slice

While working on adding a new lint for clippy (see https://github.com/rust-lang/rust-clippy/pull/6044) for avoiding shared ownership of "mutable buffer" types (such as using `Rc<Vec<T>>` instead of `Rc<[T]>`), I noticed a type exported from rustc_ast and used by clippy gets caught by the lint. This PR fixes the exported type.

This PR includes the actual change to clippy too, but I will open a PR directly against clippy for that part (although it will currently fail to build there).
-rw-r--r--clippy_lints/src/consts.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs
index 0000d39263e..062c9bd2d9e 100644
--- a/clippy_lints/src/consts.rs
+++ b/clippy_lints/src/consts.rs
@@ -155,7 +155,7 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
     match *lit {
         LitKind::Str(ref is, _) => Constant::Str(is.to_string()),
         LitKind::Byte(b) => Constant::Int(u128::from(b)),
-        LitKind::ByteStr(ref s) => Constant::Binary(Lrc::from(s.as_slice())),
+        LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
         LitKind::Char(c) => Constant::Char(c),
         LitKind::Int(n, _) => Constant::Int(n),
         LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {