|
| 1 | +use annotate_snippets::Level; |
1 | 2 | use anyhow::{Context as _, anyhow}; |
2 | 3 | use cargo::core::{CliUnstable, features}; |
3 | 4 | use cargo::util::context::TermConfig; |
@@ -318,26 +319,40 @@ To pass the arguments to the subcommand, remove `--`", |
318 | 319 | // a hard error. |
319 | 320 | if super::builtin_aliases_execs(cmd).is_none() { |
320 | 321 | if let Some(path) = super::find_external_subcommand(gctx, cmd) { |
321 | | - gctx.shell().warn(format!( |
322 | | - "\ |
323 | | -user-defined alias `{}` is shadowing an external subcommand found at: `{}` |
324 | | -This was previously accepted but is being phased out; it will become a hard error in a future release. |
325 | | -For more information, see issue #10049 <https://github.com/rust-lang/cargo/issues/10049>.", |
326 | | - cmd, |
327 | | - path.display(), |
328 | | - ))?; |
| 322 | + gctx.shell().print_report( |
| 323 | + &[ |
| 324 | + Level::WARNING.secondary_title(format!( |
| 325 | + "user-defined alias `{}` is shadowing an external subcommand found at `{}`", |
| 326 | + cmd, |
| 327 | + path.display() |
| 328 | + )).element( |
| 329 | + Level::NOTE.message( |
| 330 | + "this was previously accepted but will become a hard error in the future; \ |
| 331 | + see <https://github.com/rust-lang/cargo/issues/10049>" |
| 332 | + ) |
| 333 | + ) |
| 334 | + ], |
| 335 | + false, |
| 336 | + )?; |
329 | 337 | } |
330 | 338 | } |
331 | 339 | if commands::run::is_manifest_command(cmd) { |
332 | 340 | if gctx.cli_unstable().script { |
333 | 341 | return Ok((args, GlobalArgs::default())); |
334 | 342 | } else { |
335 | | - gctx.shell().warn(format_args!( |
336 | | - "\ |
337 | | -user-defined alias `{cmd}` has the appearance of a manifest-command |
338 | | -This was previously accepted but will be phased out when `-Zscript` is stabilized. |
339 | | -For more information, see issue #12207 <https://github.com/rust-lang/cargo/issues/12207>." |
340 | | - ))?; |
| 343 | + gctx.shell().print_report( |
| 344 | + &[ |
| 345 | + Level::WARNING.secondary_title( |
| 346 | + format!("user-defined alias `{cmd}` has the appearance of a manifest-command") |
| 347 | + ).element( |
| 348 | + Level::NOTE.message( |
| 349 | + "this was previously accepted but will be phased out when `-Zscript` is stabilized; \ |
| 350 | + see <https://github.com/rust-lang/cargo/issues/12207>" |
| 351 | + ) |
| 352 | + ) |
| 353 | + ], |
| 354 | + false |
| 355 | + )?; |
341 | 356 | } |
342 | 357 | } |
343 | 358 |
|
@@ -477,12 +492,20 @@ impl Exec { |
477 | 492 | Self::Manifest(cmd) => { |
478 | 493 | let ext_path = super::find_external_subcommand(gctx, &cmd); |
479 | 494 | if !gctx.cli_unstable().script && ext_path.is_some() { |
480 | | - gctx.shell().warn(format_args!( |
481 | | - "\ |
482 | | -external subcommand `{cmd}` has the appearance of a manifest-command |
483 | | -This was previously accepted but will be phased out when `-Zscript` is stabilized. |
484 | | -For more information, see issue #12207 <https://github.com/rust-lang/cargo/issues/12207>.", |
485 | | - ))?; |
| 495 | + gctx.shell().print_report( |
| 496 | + &[ |
| 497 | + Level::WARNING.secondary_title( |
| 498 | + format!("external subcommand `{cmd}` has the appearance of a manifest-command") |
| 499 | + ).element( |
| 500 | + Level::NOTE.message( |
| 501 | + "this was previously accepted but will be phased out when `-Zscript` is stabilized; \ |
| 502 | + see <https://github.com/rust-lang/cargo/issues/12207>" |
| 503 | + ) |
| 504 | + ) |
| 505 | + ], |
| 506 | + false |
| 507 | + )?; |
| 508 | + |
486 | 509 | Self::External(cmd).exec(gctx, subcommand_args) |
487 | 510 | } else { |
488 | 511 | let ext_args: Vec<OsString> = subcommand_args |
|
0 commit comments