@@ -6,7 +6,7 @@ use crate::core::dependency::DepKind;
6
6
use crate :: core:: resolver:: { features:: CliFeatures , ForceAllTargets , HasDevUnits } ;
7
7
use crate :: core:: { Package , PackageId , PackageIdSpec , PackageIdSpecQuery , Workspace } ;
8
8
use crate :: ops:: { self , Packages } ;
9
- use crate :: util:: { CargoResult , GlobalContext } ;
9
+ use crate :: util:: CargoResult ;
10
10
use crate :: { drop_print, drop_println} ;
11
11
use anyhow:: Context as _;
12
12
use graph:: Graph ;
@@ -228,14 +228,14 @@ pub fn build_and_print(ws: &Workspace<'_>, opts: &TreeOptions) -> CargoResult<()
228
228
try to use option `--target all` first, and then narrow your search scope accordingly.",
229
229
) ?;
230
230
} else {
231
- print ( ws. gctx ( ) , opts, root_indexes, & pkgs_to_prune, & graph) ?;
231
+ print ( ws, opts, root_indexes, & pkgs_to_prune, & graph) ?;
232
232
}
233
233
Ok ( ( ) )
234
234
}
235
235
236
236
/// Prints a tree for each given root.
237
237
fn print (
238
- gctx : & GlobalContext ,
238
+ ws : & Workspace < ' _ > ,
239
239
opts : & TreeOptions ,
240
240
roots : Vec < usize > ,
241
241
pkgs_to_prune : & [ PackageIdSpec ] ,
@@ -244,7 +244,7 @@ fn print(
244
244
let format = Pattern :: new ( & opts. format )
245
245
. with_context ( || format ! ( "tree format `{}` not valid" , opts. format) ) ?;
246
246
247
- let symbols = if gctx. shell ( ) . out_unicode ( ) {
247
+ let symbols = if ws . gctx ( ) . shell ( ) . out_unicode ( ) {
248
248
& UTF8_SYMBOLS
249
249
} else {
250
250
& ASCII_SYMBOLS
@@ -256,7 +256,7 @@ fn print(
256
256
257
257
for ( i, root_index) in roots. into_iter ( ) . enumerate ( ) {
258
258
if i != 0 {
259
- drop_println ! ( gctx) ;
259
+ drop_println ! ( ws . gctx( ) ) ;
260
260
}
261
261
262
262
// A stack of bools used to determine where | symbols should appear
@@ -267,7 +267,7 @@ fn print(
267
267
let mut print_stack = vec ! [ ] ;
268
268
269
269
print_node (
270
- gctx ,
270
+ ws ,
271
271
graph,
272
272
root_index,
273
273
& format,
@@ -287,7 +287,7 @@ fn print(
287
287
288
288
/// Prints a package and all of its dependencies.
289
289
fn print_node < ' a > (
290
- gctx : & GlobalContext ,
290
+ ws : & Workspace < ' _ > ,
291
291
graph : & ' a Graph < ' _ > ,
292
292
node_index : usize ,
293
293
format : & Pattern ,
@@ -303,20 +303,20 @@ fn print_node<'a>(
303
303
let new = no_dedupe || visited_deps. insert ( node_index) ;
304
304
305
305
match prefix {
306
- Prefix :: Depth => drop_print ! ( gctx, "{}" , levels_continue. len( ) ) ,
306
+ Prefix :: Depth => drop_print ! ( ws . gctx( ) , "{}" , levels_continue. len( ) ) ,
307
307
Prefix :: Indent => {
308
308
if let Some ( ( last_continues, rest) ) = levels_continue. split_last ( ) {
309
309
for continues in rest {
310
310
let c = if * continues { symbols. down } else { " " } ;
311
- drop_print ! ( gctx, "{} " , c) ;
311
+ drop_print ! ( ws . gctx( ) , "{} " , c) ;
312
312
}
313
313
314
314
let c = if * last_continues {
315
315
symbols. tee
316
316
} else {
317
317
symbols. ell
318
318
} ;
319
- drop_print ! ( gctx, "{0}{1}{1} " , c, symbols. right) ;
319
+ drop_print ! ( ws . gctx( ) , "{0}{1}{1} " , c, symbols. right) ;
320
320
}
321
321
}
322
322
Prefix :: None => { }
@@ -332,7 +332,7 @@ fn print_node<'a>(
332
332
} else {
333
333
" (*)"
334
334
} ;
335
- drop_println ! ( gctx, "{}{}" , format. display( graph, node_index) , star) ;
335
+ drop_println ! ( ws . gctx( ) , "{}{}" , format. display( graph, node_index) , star) ;
336
336
337
337
if !new || in_cycle {
338
338
return ;
@@ -346,7 +346,7 @@ fn print_node<'a>(
346
346
EdgeKind :: Feature ,
347
347
] {
348
348
print_dependencies (
349
- gctx ,
349
+ ws ,
350
350
graph,
351
351
node_index,
352
352
format,
@@ -366,7 +366,7 @@ fn print_node<'a>(
366
366
367
367
/// Prints all the dependencies of a package for the given dependency kind.
368
368
fn print_dependencies < ' a > (
369
- gctx : & GlobalContext ,
369
+ ws : & Workspace < ' _ > ,
370
370
graph : & ' a Graph < ' _ > ,
371
371
node_index : usize ,
372
372
format : & Pattern ,
@@ -396,10 +396,10 @@ fn print_dependencies<'a>(
396
396
if let Some ( name) = name {
397
397
for continues in & * * levels_continue {
398
398
let c = if * continues { symbols. down } else { " " } ;
399
- drop_print ! ( gctx, "{} " , c) ;
399
+ drop_print ! ( ws . gctx( ) , "{} " , c) ;
400
400
}
401
401
402
- drop_println ! ( gctx, "{}" , name) ;
402
+ drop_println ! ( ws . gctx( ) , "{}" , name) ;
403
403
}
404
404
}
405
405
@@ -428,7 +428,7 @@ fn print_dependencies<'a>(
428
428
while let Some ( dependency) = it. next ( ) {
429
429
levels_continue. push ( it. peek ( ) . is_some ( ) ) ;
430
430
print_node (
431
- gctx ,
431
+ ws ,
432
432
graph,
433
433
* dependency,
434
434
format,
0 commit comments