Skip to content

Commit 4547c0a

Browse files
committed
Avoid another &Lrc<..> in a return value.
1 parent 2123509 commit 4547c0a

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

compiler/rustc_span/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ pub enum ExternalSourceKind {
13801380
}
13811381

13821382
impl ExternalSource {
1383-
pub fn get_source(&self) -> Option<&Lrc<String>> {
1383+
pub fn get_source(&self) -> Option<&str> {
13841384
match self {
13851385
ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src),
13861386
_ => None,

compiler/rustc_span/src/source_map/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ fn t10() {
257257
);
258258
imported_src_file.add_external_src(|| Some(unnormalized.to_string()));
259259
assert_eq!(
260-
imported_src_file.external_src.borrow().get_source().unwrap().as_ref(),
260+
imported_src_file.external_src.borrow().get_source().unwrap(),
261261
normalized,
262262
"imported source file should be normalized"
263263
);

src/tools/clippy/clippy_utils/src/source.rs

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ impl SourceFileRange {
287287
self.sf
288288
.src
289289
.as_ref()
290+
.map(|src| src.as_str())
290291
.or_else(|| self.sf.external_src.get().and_then(|src| src.get_source()))
291292
.and_then(|x| x.get(self.range.clone()))
292293
}

0 commit comments

Comments
 (0)