mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Avoid another &Lrc<..>
in a return value.
This commit is contained in:
parent
2123509351
commit
4547c0a990
@ -1380,7 +1380,7 @@ pub enum ExternalSourceKind {
|
||||
}
|
||||
|
||||
impl ExternalSource {
|
||||
pub fn get_source(&self) -> Option<&Lrc<String>> {
|
||||
pub fn get_source(&self) -> Option<&str> {
|
||||
match self {
|
||||
ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src),
|
||||
_ => None,
|
||||
|
@ -257,7 +257,7 @@ fn t10() {
|
||||
);
|
||||
imported_src_file.add_external_src(|| Some(unnormalized.to_string()));
|
||||
assert_eq!(
|
||||
imported_src_file.external_src.borrow().get_source().unwrap().as_ref(),
|
||||
imported_src_file.external_src.borrow().get_source().unwrap(),
|
||||
normalized,
|
||||
"imported source file should be normalized"
|
||||
);
|
||||
|
@ -287,6 +287,7 @@ impl SourceFileRange {
|
||||
self.sf
|
||||
.src
|
||||
.as_ref()
|
||||
.map(|src| src.as_str())
|
||||
.or_else(|| self.sf.external_src.get().and_then(|src| src.get_source()))
|
||||
.and_then(|x| x.get(self.range.clone()))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user