Skip to content

Conversation

@CathalMullan
Copy link
Collaborator

@CathalMullan CathalMullan commented Nov 22, 2025

Resolves #184, Resolves #169, Resolves #93

This refactors the dependency analysis to be more robust when it comes to handling the differences between code imports, dependency keys and package names.

  • Dependencies referenced through features are now correctly detected.
  • The fix command can now remove [target.'cfg(...)'.dependencies] dependencies.
  • Redundant ignores where the ignored package is actually in use now print a warning.
  • Improved error messages on syn parsing errors.
  • Added tests around hyphen vs underscore dependency naming, and cross-package renames.

Here's a before and after for the errors messages:

Before:

> cargo shear --expand
Analyzing /home/cmullan/workspace/rustls

unexpected token, expected `;`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After:

> cargo shear --expand
Analyzing /home/cmullan/workspace/rustls

Syntax error in rustls-ci-bench at line 467:30:
unexpected token, expected `;`

   464 |             let waker = noop_waker();
   465 |             let mut ctx = task::Context::from_waker(&waker);
   466 |             match {
>  467 |                         super let mut pinned = future;
   468 |                         unsafe { ::core::pin::Pin::new_unchecked(&mut pinned) }
   469 |                     }.poll(&mut ctx) {
   470 |                 Poll::Ready(result) => result,

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

(syn doesn't support parsing super let yet)

I've also manually tested this against a few real-world projects (rustls, opentelemetry), and it looks to work well.

@Boshen
Copy link
Owner

Boshen commented Nov 22, 2025

Thank you! The redundant warnings are working great in Oxc and Rolldown.

@Boshen Boshen merged commit 2de5726 into Boshen:main Nov 22, 2025
1 check passed
@Boshen Boshen mentioned this pull request Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants