Fix file formatting
This commit is contained in:
parent
03a63fd4a4
commit
9f5e17fd0a
@ -42,10 +42,16 @@ pub(crate) fn new(matches: &getopts::Matches, dcx: DiagCtxtHandle<'_>) -> Option
|
|||||||
scrape_tests,
|
scrape_tests,
|
||||||
}),
|
}),
|
||||||
(Some(_), false, _) | (None, true, _) => {
|
(Some(_), false, _) | (None, true, _) => {
|
||||||
dcx.fatal("must use --scrape-examples-output-path and --scrape-examples-target-crate together");
|
dcx.fatal(
|
||||||
|
"must use --scrape-examples-output-path and --scrape-examples-target-crate \
|
||||||
|
together",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
(None, false, true) => {
|
(None, false, true) => {
|
||||||
dcx.fatal("must use --scrape-examples-output-path and --scrape-examples-target-crate with --scrape-tests");
|
dcx.fatal(
|
||||||
|
"must use --scrape-examples-output-path and \
|
||||||
|
--scrape-examples-target-crate with --scrape-tests",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
(None, false, false) => None,
|
(None, false, false) => None,
|
||||||
}
|
}
|
||||||
@ -163,14 +169,15 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// If this span comes from a macro expansion, then the source code may not actually show
|
// If this span comes from a macro expansion, then the source code may not actually show
|
||||||
// a use of the given item, so it would be a poor example. Hence, we skip all uses in macros.
|
// a use of the given item, so it would be a poor example. Hence, we skip all uses in
|
||||||
|
// macros.
|
||||||
if call_span.from_expansion() {
|
if call_span.from_expansion() {
|
||||||
trace!("Rejecting expr from macro: {call_span:?}");
|
trace!("Rejecting expr from macro: {call_span:?}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the enclosing item has a span coming from a proc macro, then we also don't want to include
|
// If the enclosing item has a span coming from a proc macro, then we also don't want to
|
||||||
// the example.
|
// include the example.
|
||||||
let enclosing_item_span =
|
let enclosing_item_span =
|
||||||
tcx.hir().span_with_body(tcx.hir().get_parent_item(ex.hir_id).into());
|
tcx.hir().span_with_body(tcx.hir().get_parent_item(ex.hir_id).into());
|
||||||
if enclosing_item_span.from_expansion() {
|
if enclosing_item_span.from_expansion() {
|
||||||
@ -178,11 +185,12 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the enclosing item doesn't actually enclose the call, this means we probably have a weird
|
// If the enclosing item doesn't actually enclose the call, this means we probably have a
|
||||||
// macro issue even though the spans aren't tagged as being from an expansion.
|
// weird macro issue even though the spans aren't tagged as being from an expansion.
|
||||||
if !enclosing_item_span.contains(call_span) {
|
if !enclosing_item_span.contains(call_span) {
|
||||||
warn!(
|
warn!(
|
||||||
"Attempted to scrape call at [{call_span:?}] whose enclosing item [{enclosing_item_span:?}] doesn't contain the span of the call."
|
"Attempted to scrape call at [{call_span:?}] whose enclosing item \
|
||||||
|
[{enclosing_item_span:?}] doesn't contain the span of the call."
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -190,7 +198,8 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
|
|||||||
// Similarly for the call w/ the function ident.
|
// Similarly for the call w/ the function ident.
|
||||||
if !call_span.contains(ident_span) {
|
if !call_span.contains(ident_span) {
|
||||||
warn!(
|
warn!(
|
||||||
"Attempted to scrape call at [{call_span:?}] whose identifier [{ident_span:?}] was not contained in the span of the call."
|
"Attempted to scrape call at [{call_span:?}] whose identifier [{ident_span:?}] was \
|
||||||
|
not contained in the span of the call."
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -224,7 +233,8 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
|
|||||||
Some(url) => url,
|
Some(url) => url,
|
||||||
None => {
|
None => {
|
||||||
trace!(
|
trace!(
|
||||||
"Rejecting expr ({call_span:?}) whose clean span ({clean_span:?}) cannot be turned into a link"
|
"Rejecting expr ({call_span:?}) whose clean span ({clean_span:?}) \
|
||||||
|
cannot be turned into a link"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -272,7 +282,8 @@ pub(crate) fn run(
|
|||||||
let (cx, _) = Context::init(krate, renderopts, cache, tcx).map_err(|e| e.to_string())?;
|
let (cx, _) = Context::init(krate, renderopts, cache, tcx).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
// Collect CrateIds corresponding to provided target crates
|
// Collect CrateIds corresponding to provided target crates
|
||||||
// If two different versions of the crate in the dependency tree, then examples will be collected from both.
|
// If two different versions of the crate in the dependency tree, then examples will be
|
||||||
|
// collected from both.
|
||||||
let all_crates = tcx
|
let all_crates = tcx
|
||||||
.crates(())
|
.crates(())
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user