Skip to content

Commit aaa4e16

Browse files
committed
correct usage of snippet_with_context
1 parent e3ec8c0 commit aaa4e16

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clippy_lints/src/useless_pathbuf_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessPathbufConversion {
4545
&& is_type_diagnostic_item(cx, *inner_ty, sym::Path)
4646
{
4747
let mut app = Applicability::MachineApplicable;
48-
let arg_snippet = snippet_with_context(cx, arg.span, arg.span.ctxt(), "..", &mut app).0;
48+
let arg_snippet = snippet_with_context(cx, arg.span, inner.span.ctxt(), "..", &mut app).0;
4949

5050
let sugg = format!("Path::new({arg_snippet})");
5151

clippy_utils/src/source.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,8 @@ pub fn snippet_block_with_context(
653653
/// would result in `box []`. If given the context of the address of expression, this function will
654654
/// correctly get a snippet of `vec![]`.
655655
///
656+
/// NOTE: Typically the `outer` context should be taken from the parent node, not from the node itself.
657+
///
656658
/// This will also return whether or not the snippet is a macro call.
657659
pub fn snippet_with_context<'a>(
658660
sess: &impl HasSession,

0 commit comments

Comments
 (0)