1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
#![allow(deprecated)]
#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))]
#![deny(clippy::expect_used)]
#![deny(clippy::unwrap_used)]
#![deny(clippy::panic)]

use anyhow::{anyhow, bail, ensure, Context, Result};
use cargo_metadata::MetadataCommand;
use dylint_internal::{
    driver as dylint_driver, env, parse_path_filename, rustup::SanitizeEnvironment, CommandExt,
};
use once_cell::sync::Lazy;
use std::{
    collections::BTreeMap,
    env::{consts, current_dir},
    ffi::OsStr,
    fmt::Debug,
    fs::OpenOptions,
    path::{Path, PathBuf, MAIN_SEPARATOR},
};

type Object = serde_json::Map<String, serde_json::Value>;

// smoelius: See note in dylint/src/metadata/mod.rs.
#[cfg(all(feature = "__metadata_cargo", not(feature = "__metadata_cli")))]
pub(crate) use cargo::{core, sources, util};

pub mod driver_builder;

mod error;
use error::warn;
#[doc(hidden)]
pub use error::warn as __warn;
pub use error::{ColorizedError, ColorizedResult};

mod name_toolchain_map;
pub use name_toolchain_map::{Lazy as NameToolchainMap, ToolchainMap};
use name_toolchain_map::{LazyToolchainMap, MaybeLibrary};

#[cfg(__metadata)]
pub(crate) mod metadata;

#[cfg(feature = "package_options")]
mod package_options;

static REQUIRED_FORM: Lazy<String> = Lazy::new(|| {
    format!(
        r#""{}" LIBRARY_NAME "@" TOOLCHAIN "{}""#,
        consts::DLL_PREFIX,
        consts::DLL_SUFFIX
    )
});

#[allow(clippy::struct_excessive_bools)]
#[derive(Clone, Debug, Default)]
// smoelius: Please keep the fields `names` and `args` last. Please keep all other fields sorted.
pub struct Dylint {
    pub all: bool,

    #[deprecated]
    pub allow_downgrade: bool,

    #[deprecated]
    pub bisect: bool,

    pub fix: bool,

    #[deprecated]
    pub force: bool,

    #[deprecated]
    pub isolate: bool,

    pub keep_going: bool,

    pub libs: Vec<String>,

    #[deprecated]
    pub list: bool,

    pub manifest_path: Option<String>,

    #[deprecated]
    pub new_path: Option<String>,

    pub no_build: bool,

    pub no_deps: bool,

    pub no_metadata: bool,

    pub packages: Vec<String>,

    pub paths: Vec<String>,

    pub pipe_stderr: Option<String>,

    pub pipe_stdout: Option<String>,

    pub quiet: bool,

    #[deprecated]
    pub rust_version: Option<String>,

    #[deprecated]
    pub upgrade_path: Option<String>,

    pub workspace: bool,

    #[deprecated]
    pub names: Vec<String>,

    pub args: Vec<String>,
}

pub fn run(opts: &Dylint) -> Result<()> {
    let opts = {
        if opts.force {
            warn(
                opts,
                "`--force` is deprecated and its meaning may change in the future. Use \
                 `--allow-downgrade`.",
            );
        }
        Dylint {
            allow_downgrade: opts.allow_downgrade || opts.force,
            ..opts.clone()
        }
    };

    if opts.allow_downgrade && opts.upgrade_path.is_none() {
        bail!("`--allow-downgrade` can be used only with `--upgrade`");
    }

    if opts.bisect {
        #[cfg(not(unix))]
        bail!("`--bisect` is supported only on Unix platforms");

        #[cfg(unix)]
        warn(&opts, "`--bisect` is experimental");
    }

    if opts.bisect && opts.upgrade_path.is_none() {
        bail!("`--bisect` can be used only with `--upgrade`");
    }

    if opts.isolate && opts.new_path.is_none() {
        bail!("`--isolate` can be used only with `--new`");
    }

    if opts.pipe_stderr.is_some() {
        warn(&opts, "`--pipe-stderr` is experimental");
    }

    if opts.pipe_stdout.is_some() {
        warn(&opts, "`--pipe-stdout` is experimental");
    }

    if opts.rust_version.is_some() && opts.upgrade_path.is_none() {
        bail!("`--rust-version` can be used only with `--upgrade`");
    }

    #[cfg(feature = "package_options")]
    if let Some(path) = &opts.new_path {
        return package_options::new_package(&opts, Path::new(path));
    }

    #[cfg(feature = "package_options")]
    if let Some(path) = &opts.upgrade_path {
        return package_options::upgrade_package(&opts, Path::new(path));
    }

    let name_toolchain_map = NameToolchainMap::new(&opts);

    run_with_name_toolchain_map(&opts, &name_toolchain_map)
}

fn run_with_name_toolchain_map(opts: &Dylint, name_toolchain_map: &NameToolchainMap) -> Result<()> {
    if opts.libs.is_empty() && opts.paths.is_empty() && opts.names.is_empty() && !opts.all {
        if opts.list {
            warn_if_empty(opts, name_toolchain_map)?;
            return list_libs(name_toolchain_map);
        }

        warn(opts, "Nothing to do. Did you forget `--all`?");
        return Ok(());
    }

    let resolved = resolve(opts, name_toolchain_map)?;

    if resolved.is_empty() {
        assert!(opts.libs.is_empty());
        assert!(opts.paths.is_empty());
        assert!(opts.names.is_empty());

        let name_toolchain_map_is_empty = warn_if_empty(opts, name_toolchain_map)?;

        // smoelius: If `name_toolchain_map` is NOT empty, then it had better be the case that
        // `--all` was not passed.
        assert!(name_toolchain_map_is_empty || !opts.all);
    }

    if opts.list {
        list_lints(opts, &resolved)
    } else {
        check_or_fix(opts, &resolved)
    }
}

fn warn_if_empty(opts: &Dylint, name_toolchain_map: &NameToolchainMap) -> Result<bool> {
    let name_toolchain_map = name_toolchain_map.get_or_try_init()?;

    Ok(if name_toolchain_map.is_empty() {
        warn(opts, "No libraries were found.");
        true
    } else {
        false
    })
}

fn list_libs(name_toolchain_map: &NameToolchainMap) -> Result<()> {
    let name_toolchain_map = name_toolchain_map.get_or_try_init()?;

    let name_width = name_toolchain_map
        .keys()
        .map(String::len)
        .max()
        .unwrap_or_default();

    let toolchain_width = name_toolchain_map
        .values()
        .flat_map(LazyToolchainMap::keys)
        .map(String::len)
        .max()
        .unwrap_or_default();

    for (name, toolchain_map) in name_toolchain_map {
        for (toolchain, maybe_libraries) in toolchain_map {
            for maybe_library in maybe_libraries {
                let location = display_location(&maybe_library.path())?;
                println!("{name:<name_width$}  {toolchain:<toolchain_width$}  {location}",);
            }
        }
    }

    Ok(())
}

#[cfg_attr(
    dylint_lib = "question_mark_in_expression",
    allow(question_mark_in_expression)
)]
fn resolve(opts: &Dylint, name_toolchain_map: &NameToolchainMap) -> Result<ToolchainMap> {
    let mut toolchain_map = ToolchainMap::new();

    if opts.all {
        let name_toolchain_map = name_toolchain_map.get_or_try_init()?;

        for other in name_toolchain_map.values() {
            for (toolchain, maybe_libraries) in other {
                let paths = maybe_libraries
                    .iter()
                    .map(|maybe_library| maybe_library.build(opts))
                    .collect::<Result<Vec<_>>>()?;
                toolchain_map
                    .entry(toolchain.clone())
                    .or_default()
                    .extend(paths);
            }
        }
    }

    for name in &opts.libs {
        ensure!(!opts.all, "`--lib` cannot be used with `--all`");
        let (toolchain, maybe_library) =
            name_as_lib(name_toolchain_map, name, true)?.unwrap_or_else(|| unreachable!());
        let path = maybe_library.build(opts)?;
        toolchain_map.entry(toolchain).or_default().insert(path);
    }

    for name in &opts.paths {
        let (toolchain, path) = name_as_path(name, true)?.unwrap_or_else(|| unreachable!());
        toolchain_map.entry(toolchain).or_default().insert(path);
    }

    let mut not_found = Vec::new();

    for name in &opts.names {
        if let Some((toolchain, maybe_library)) = name_as_lib(name_toolchain_map, name, false)? {
            ensure!(
                !opts.all,
                "`{}` is a library name and cannot be used with `--all`; if a path was meant, use \
                 `--path {}`",
                name,
                name
            );
            let path = maybe_library.build(opts)?;
            toolchain_map.entry(toolchain).or_default().insert(path);
        } else if let Some((toolchain, path)) = name_as_path(name, false)? {
            toolchain_map.entry(toolchain).or_default().insert(path);
        } else {
            not_found.push(name);
        }
    }

    #[allow(clippy::format_collect)]
    if !not_found.is_empty() {
        not_found.sort_unstable();
        bail!(
            "Could not find the following libraries:{}",
            not_found
                .iter()
                .map(|name| format!("\n    {name}"))
                .collect::<String>()
        );
    }

    Ok(toolchain_map)
}

pub fn name_as_lib(
    name_toolchain_map: &NameToolchainMap,
    name: &str,
    as_lib_only: bool,
) -> Result<Option<(String, MaybeLibrary)>> {
    if !is_valid_lib_name(name) {
        ensure!(!as_lib_only, "`{}` is not a valid library name", name);
        return Ok(None);
    }

    let name_toolchain_map = name_toolchain_map.get_or_try_init()?;

    if let Some(toolchain_map) = name_toolchain_map.get(name) {
        let mut toolchain_maybe_libraries = flatten_toolchain_map(toolchain_map);

        return match toolchain_maybe_libraries.len() {
            0 => Ok(None),
            1 => Ok(Some(toolchain_maybe_libraries.remove(0))),
            _ => Err(anyhow!(
                "Found multiple libraries matching `{}`: {:?}",
                name,
                toolchain_maybe_libraries
                    .iter()
                    .map(|(_, path)| path)
                    .collect::<Vec<_>>()
            )),
        };
    }

    ensure!(!as_lib_only, "Could not find `--lib {}`", name);

    Ok(None)
}

fn is_valid_lib_name(name: &str) -> bool {
    Path::new(name).file_name() == Some(OsStr::new(name))
}

fn flatten_toolchain_map<I, T>(toolchain_map: &BTreeMap<String, I>) -> Vec<(String, T)>
where
    for<'a> &'a I: IntoIterator<Item = &'a T>,
    T: Clone,
{
    toolchain_map
        .iter()
        .flat_map(|(toolchain, values)| {
            values
                .into_iter()
                .map(|value| (toolchain.clone(), value.clone()))
                .collect::<Vec<_>>()
        })
        .collect()
}

fn name_as_path(name: &str, as_path_only: bool) -> Result<Option<(String, PathBuf)>> {
    if let Ok(path) = PathBuf::from(name).canonicalize() {
        if let Some((_, toolchain)) = parse_path_filename(&path) {
            return Ok(Some((toolchain, path)));
        }

        ensure!(
            !as_path_only,
            "`--path {}` was used, but the filename does not have the required form: {}",
            name,
            *REQUIRED_FORM
        );

        // smoelius: If `name` contains a path separator, then it was clearly meant to be a
        // path.
        ensure!(
            !name.contains(MAIN_SEPARATOR),
            "`{}` is a valid path, but the filename does not have the required form: {}",
            name,
            *REQUIRED_FORM
        );

        ensure!(
            !as_path_only,
            "`--path {}` was used, but it is invalid",
            name
        );
    }

    ensure!(!as_path_only, "Could not find `--path {}`", name);

    Ok(None)
}

fn list_lints(opts: &Dylint, resolved: &ToolchainMap) -> Result<()> {
    for (toolchain, paths) in resolved {
        for path in paths {
            let driver = driver_builder::get(opts, toolchain)?;
            let dylint_libs = serde_json::to_string(&[path])?;
            let (name, _) =
                parse_path_filename(path).ok_or_else(|| anyhow!("Could not parse path"))?;

            print!("{name}");
            if resolved.keys().len() >= 2 {
                print!("@{toolchain}");
            }
            if paths.len() >= 2 {
                let location = display_location(path)?;
                print!(" ({location})");
            }
            println!();

            // smoelius: `-W help` is the normal way to list lints, so we can be sure it
            // gets the lints loaded. However, we don't actually use it to list the lints.
            let mut command = dylint_driver(toolchain, &driver)?;
            command
                .envs([
                    (env::DYLINT_LIBS, dylint_libs.as_str()),
                    (env::DYLINT_LIST, "1"),
                ])
                .args(["rustc", "-W", "help"])
                .success()?;

            println!();
        }
    }

    Ok(())
}

fn display_location(path: &Path) -> Result<String> {
    let current_dir = current_dir().with_context(|| "Could not get current directory")?;
    let Ok(path_buf) = path.canonicalize() else {
        return Ok("<unbuilt>".to_owned());
    };
    let parent = path_buf
        .parent()
        .ok_or_else(|| anyhow!("Could not get parent directory"))?;
    Ok(parent
        .strip_prefix(&current_dir)
        .unwrap_or(parent)
        .to_string_lossy()
        .to_string())
}

fn check_or_fix(opts: &Dylint, resolved: &ToolchainMap) -> Result<()> {
    let clippy_disable_docs_links = clippy_disable_docs_links()?;

    let mut failures = Vec::new();

    for (toolchain, paths) in resolved {
        let target_dir = target_dir(opts, toolchain)?;
        let target_dir_str = target_dir.to_string_lossy();
        let driver = driver_builder::get(opts, toolchain)?;
        let dylint_libs = serde_json::to_string(&paths)?;
        #[cfg(not(__metadata))]
        let dylint_metadata = None;
        #[cfg(__metadata)]
        let dylint_metadata = metadata::dylint_metadata(opts)?;
        let dylint_metadata_str = dylint_metadata
            .map(|object: &Object| serde_json::Value::from(object.clone()))
            .unwrap_or_default()
            .to_string();
        let description = format!("with toolchain `{toolchain}`");
        let mut command = if opts.fix {
            dylint_internal::cargo::fix(&description)
        } else {
            dylint_internal::cargo::check(&description)
        }
        .build();
        let mut args = vec!["--target-dir", &target_dir_str];
        if let Some(path) = &opts.manifest_path {
            args.extend(["--manifest-path", path]);
        }
        for spec in &opts.packages {
            args.extend(["-p", spec]);
        }
        if opts.workspace {
            args.extend(["--workspace"]);
        }
        args.extend(opts.args.iter().map(String::as_str));

        // smoelius: Set CLIPPY_DISABLE_DOCS_LINKS to prevent lints from accidentally linking to the
        // Clippy repository. But set it to the JSON-encoded original value so that the Clippy
        // library can unset the variable.
        // smoelius: This doesn't work if another library is loaded alongside Clippy.
        // smoelius: This was fixed in `clippy_utils`:
        // https://github.com/rust-lang/rust-clippy/commit/1a206fc4abae0b57a3f393481367cf3efca23586
        // But I am going to continue to set CLIPPY_DISABLE_DOCS_LINKS because it doesn't seem to
        // hurt and it provides a small amount of backward compatibility.
        command
            .sanitize_environment()
            .envs([
                (
                    env::CLIPPY_DISABLE_DOCS_LINKS,
                    clippy_disable_docs_links.as_str(),
                ),
                (env::DYLINT_LIBS, &dylint_libs),
                (env::DYLINT_METADATA, &dylint_metadata_str),
                (env::DYLINT_NO_DEPS, if opts.no_deps { "1" } else { "0" }),
                (env::RUSTC_WORKSPACE_WRAPPER, &*driver.to_string_lossy()),
                (env::RUSTUP_TOOLCHAIN, toolchain),
            ])
            .args(args);

        if let Some(stderr_path) = &opts.pipe_stderr {
            let file = OpenOptions::new()
                .append(true)
                .create(true)
                .open(stderr_path)
                .with_context(|| format!("Failed to open `{stderr_path}` for stderr usage"))?;
            command.stderr(file);
        }

        if let Some(stdout_path) = &opts.pipe_stdout {
            let file = OpenOptions::new()
                .append(true)
                .create(true)
                .open(stdout_path)
                .with_context(|| format!("Failed to open `{stdout_path}` for stdout usage"))?;
            command.stdout(file);
        }

        let result = command.success();
        if result.is_err() {
            if !opts.keep_going {
                return result
                    .with_context(|| format!("Compilation failed with toolchain `{toolchain}`"));
            };
            failures.push(toolchain);
        }
    }

    if failures.is_empty() {
        Ok(())
    } else {
        Err(anyhow!(
            "Compilation failed with the following toolchains: {:?}",
            failures
        ))
    }
}

fn target_dir(opts: &Dylint, toolchain: &str) -> Result<PathBuf> {
    let mut command = MetadataCommand::new();
    if let Some(path) = &opts.manifest_path {
        command.manifest_path(path);
    }
    let metadata = command.no_deps().exec()?;
    Ok(metadata
        .target_directory
        .join("dylint/target")
        .join(toolchain)
        .into())
}

fn clippy_disable_docs_links() -> Result<String> {
    let val = env::var(env::CLIPPY_DISABLE_DOCS_LINKS).ok();
    serde_json::to_string(&val).map_err(Into::into)
}

#[cfg(test)]
mod test {
    #![allow(clippy::unwrap_used)]

    use super::*;
    use dylint_internal::examples;
    use once_cell::sync::Lazy;
    use std::{
        env::{join_paths, set_var},
        sync::Mutex,
    };

    // smoelius: With the upgrade to nightly-2023-03-10, I started running into this:
    // https://github.com/rust-lang/rustup/issues/988
    // The easiest solution is to just not run the tests concurrently.
    static MUTEX: Mutex<()> = Mutex::new(());

    static OPTS: Lazy<Dylint> = Lazy::new(|| Dylint {
        no_metadata: true,
        ..Dylint::default()
    });

    fn name_toolchain_map() -> NameToolchainMap<'static> {
        examples::build().unwrap();
        let metadata = dylint_internal::cargo::current_metadata().unwrap();
        // smoelius: As of version 0.1.14, `cargo-llvm-cov` no longer sets `CARGO_TARGET_DIR`.
        // So `dylint_library_path` no longer requires a `cfg!(coverage)` special case.
        let dylint_library_path = join_paths([
            metadata.target_directory.join("examples/debug"),
            metadata.target_directory.join("straggler/debug"),
        ])
        .unwrap();

        #[rustfmt::skip]
        // smoelius: Following the upgrade nightly-2023-08-24, I started seeing the following error:
        //
        //   error: internal compiler error: encountered incremental compilation error with shallow_lint_levels_on(dylint_internal[...]::cargo::{use#15})
        //     |
        //     = help: This is a known issue with the compiler. Run `cargo clean -p dylint_internal` or `cargo clean` to allow your project to compile
        //     = note: Please follow the instructions below to create a bug report with the provided information
        //     = note: See <https://github.com/rust-lang/rust/issues/84970> for more information
        set_var(env::CARGO_INCREMENTAL, "0");
        set_var(env::DYLINT_LIBRARY_PATH, dylint_library_path);

        NameToolchainMap::new(&OPTS)
    }

    #[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
    #[test]
    fn multiple_libraries_multiple_toolchains() {
        let _lock = MUTEX.lock().unwrap();

        let name_toolchain_map = name_toolchain_map();

        let inited = name_toolchain_map.get_or_try_init().unwrap();

        let question_mark_in_expression = inited.get("question_mark_in_expression").unwrap();
        let straggler = inited.get("straggler").unwrap();

        assert_ne!(
            question_mark_in_expression.keys().collect::<Vec<_>>(),
            straggler.keys().collect::<Vec<_>>()
        );

        let opts = Dylint {
            libs: vec![
                "question_mark_in_expression".to_owned(),
                "straggler".to_owned(),
            ],
            ..Dylint::default()
        };

        run_with_name_toolchain_map(&opts, &name_toolchain_map).unwrap();
    }

    // smoelius: Check that loading multiple libraries with the same Rust toolchain works. At one
    // point, I was getting this error from `libloading`:
    //
    //   cannot allocate memory in static TLS block
    //
    // The culprit turned out to be the `rand` crate, which uses a lot of thread local storage.
    // `rand` is used by `tempfile`, which is used by various Rust compiler crates. Essentially,
    // each library had its own copy of the Rust compiler, and therefore its own copy of the `rand`
    // crate, and this was eating up all the thread local storage.
    //
    // The solution was to add `extern crate rustc_driver` to each library. This causes the library
    // to link against `librust_driver.so`, which dylint-driver also links against. So, essentially,
    // each library now uses dylint-driver's copy of the `rand` crate.
    //
    // This thread was very helpful in diagnosing the problem:
    //
    //   https://bugzilla.redhat.com/show_bug.cgi?id=1722181
    //
    #[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
    #[test]
    fn multiple_libraries_one_toolchain() {
        let _lock = MUTEX.lock().unwrap();

        let name_toolchain_map = name_toolchain_map();

        let inited = name_toolchain_map.get_or_try_init().unwrap();

        let clippy = inited.get("clippy").unwrap();
        let question_mark_in_expression = inited.get("question_mark_in_expression").unwrap();

        assert_eq!(
            clippy.keys().collect::<Vec<_>>(),
            question_mark_in_expression.keys().collect::<Vec<_>>()
        );

        let opts = Dylint {
            libs: vec![
                "clippy".to_owned(),
                "question_mark_in_expression".to_owned(),
            ],
            ..Dylint::default()
        };

        run_with_name_toolchain_map(&opts, &name_toolchain_map).unwrap();
    }
}