Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dtolnay/trybuild
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.91
Choose a base ref
...
head repository: dtolnay/trybuild
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.0.92
Choose a head ref
  • 9 commits
  • 8 files changed
  • 2 contributors

Commits on Mar 30, 2024

  1. Use 2015 as the default edition if not found in Cargo.toml

    dtolnay committed Mar 30, 2024
    Copy the full SHA
    c74de40 View commit details
  2. Resolve derivable_impls clippy lint

        warning: this `impl` can be derived
          --> src/env.rs:10:1
           |
        10 | / impl Default for Update {
        11 | |     fn default() -> Self {
        12 | |         Update::Wip
        13 | |     }
        14 | | }
           | |_^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
           = note: `#[warn(clippy::derivable_impls)]` on by default
           = help: remove the manual implementation...
        help: ...and instead derive it...
           |
        5  + #[derive(Default)]
        6  | pub(crate) enum Update {
           |
        help: ...and mark the default variant
           |
        6  ~     #[default]
        7  ~     Wip,
           |
    
        warning: this `impl` can be derived
          --> src/manifest.rs:78:1
           |
        78 | / impl Default for Edition {
        79 | |     fn default() -> Self {
        80 | |         Edition::E2015
        81 | |     }
        82 | | }
           | |_^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
           = note: `#[warn(clippy::derivable_impls)]` on by default
           = help: remove the manual implementation...
        help: ...and instead derive it...
           |
        42 + #[derive(Default)]
        43 | pub(crate) enum Edition {
           |
        help: ...and mark the default variant
           |
        44 ~     #[default]
        45 ~     E2015,
           |
    dtolnay committed Mar 30, 2024
    Copy the full SHA
    a6c3e51 View commit details
  3. Resolve manual_let_else clippy lints

        warning: this could be rewritten as `let...else`
          --> src/env.rs:13:9
           |
        13 | /         let var = match env::var_os("TRYBUILD") {
        14 | |             Some(var) => var,
        15 | |             None => return Ok(Update::default()),
        16 | |         };
           | |__________^ help: consider writing: `let Some(var) = env::var_os("TRYBUILD") else { return Ok(Update::default()) };`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
           = note: `-W clippy::manual-let-else` implied by `-W clippy::pedantic`
           = help: to override `-W clippy::pedantic` add `#[allow(clippy::manual_let_else)]`
    
        warning: this could be rewritten as `let...else`
           --> src/flock.rs:118:9
            |
        118 | /         let modified = match metadata.modified() {
        119 | |             Ok(modified) => modified,
        120 | |             Err(_) => return None,
        121 | |         };
            | |__________^ help: consider writing: `let Ok(modified) = metadata.modified() else { return None };`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
            = note: `-W clippy::manual-let-else` implied by `-W clippy::pedantic`
            = help: to override `-W clippy::pedantic` add `#[allow(clippy::manual_let_else)]`
    
        warning: this could be rewritten as `let...else`
           --> src/normalize.rs:519:9
            |
        519 | /         let next_line = match ahead.next() {
        520 | |             Some(line) => line,
        521 | |             None => continue,
        522 | |         };
            | |__________^ help: consider writing: `let Some(next_line) = ahead.next() else { continue };`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
    
        warning: this could be rewritten as `let...else`
           --> src/run.rs:267:17
            |
        267 | /                 let dep_name = match en.strip_prefix("dep:") {
        268 | |                     Some(dep_name) => dep_name,
        269 | |                     None => return false,
        270 | |                 };
            | |__________________^ help: consider writing: `let Some(dep_name) = en.strip_prefix("dep:") else { return false };`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
    
        warning: this could be rewritten as `let...else`
           --> src/run.rs:625:9
            |
        625 | /         let begin = match remaining.find("{\"reason\":") {
        626 | |             Some(begin) => begin,
        627 | |             None => break,
        628 | |         };
            | |__________^ help: consider writing: `let Some(begin) = remaining.find("{\"reason\":") else { break };`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
    
        warning: this could be rewritten as `let...else`
           --> src/run.rs:646:17
            |
        646 | /                 let (name, test) = match path_map.get(&de.target.src_path) {
        647 | |                     Some(test) => test,
        648 | |                     None => continue,
        649 | |                 };
            | |__________________^ help: consider writing: `let Some((name, test)) = path_map.get(&de.target.src_path) else { continue };`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
    dtolnay committed Mar 30, 2024
    Copy the full SHA
    8010acb View commit details
  4. Ignore uninlined_format_args pedantic clippy lint

        warning: variables can be used directly in the `format!` string
          --> src/error.rs:36:25
           |
        36 |             Cargo(e) => write!(f, "failed to execute cargo: {}", e),
           |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
           = note: `-W clippy::uninlined-format-args` implied by `-W clippy::pedantic`
           = help: to override `-W clippy::pedantic` add `#[allow(clippy::uninlined_format_args)]`
        help: change this to
           |
        36 -             Cargo(e) => write!(f, "failed to execute cargo: {}", e),
        36 +             Cargo(e) => write!(f, "failed to execute cargo: {e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:39:24
           |
        39 |             Glob(e) => write!(f, "{}", e),
           |                        ^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        39 -             Glob(e) => write!(f, "{}", e),
        39 +             Glob(e) => write!(f, "{e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:40:22
           |
        40 |             Io(e) => write!(f, "{}", e),
           |                      ^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        40 -             Io(e) => write!(f, "{}", e),
        40 +             Io(e) => write!(f, "{e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:41:28
           |
        41 |             Metadata(e) => write!(f, "failed to read cargo metadata: {}", e),
           |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        41 -             Metadata(e) => write!(f, "failed to read cargo metadata: {}", e),
        41 +             Metadata(e) => write!(f, "failed to read cargo metadata: {e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:45:27
           |
        45 |             Pattern(e) => write!(f, "{}", e),
           |                           ^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        45 -             Pattern(e) => write!(f, "{}", e),
        45 +             Pattern(e) => write!(f, "{e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:47:30
           |
        47 |             ReadStderr(e) => write!(f, "failed to read stderr file: {}", e),
           |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        47 -             ReadStderr(e) => write!(f, "failed to read stderr file: {}", e),
        47 +             ReadStderr(e) => write!(f, "failed to read stderr file: {e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:52:26
           |
        52 |             TomlDe(e) => write!(f, "{}", e),
           |                          ^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        52 -             TomlDe(e) => write!(f, "{}", e),
        52 +             TomlDe(e) => write!(f, "{e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:53:27
           |
        53 |             TomlSer(e) => write!(f, "{}", e),
           |                           ^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        53 -             TomlSer(e) => write!(f, "{}", e),
        53 +             TomlSer(e) => write!(f, "{e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/error.rs:59:31
           |
        59 |             WriteStderr(e) => write!(f, "failed to write stderr file: {}", e),
           |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        59 -             WriteStderr(e) => write!(f, "failed to write stderr file: {}", e),
        59 +             WriteStderr(e) => write!(f, "failed to write stderr file: {e}"),
           |
    
        warning: variables can be used directly in the `format!` string
          --> src/expand.rs:59:25
           |
        59 |         let name = Name(format!("trybuild{:03}", index));
           |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
           |
        59 -         let name = Name(format!("trybuild{:03}", index));
        59 +         let name = Name(format!("trybuild{index:03}"));
           |
    
        warning: variables can be used directly in the `format!` string
           --> src/normalize.rs:205:47
            |
        205 | ...                   let replacement = format!("$OUT_DIR[{}]", out_dir_crate_name);
            |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
            |
        205 -                             let replacement = format!("$OUT_DIR[{}]", out_dir_crate_name);
        205 +                             let replacement = format!("$OUT_DIR[{out_dir_crate_name}]");
            |
    
        warning: variables can be used directly in the `format!` string
           --> src/run.rs:153:28
            |
        153 |         let project_name = format!("{}-tests", crate_name);
            |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
            |
        153 -         let project_name = format!("{}-tests", crate_name);
        153 +         let project_name = format!("{crate_name}-tests");
            |
    
        warning: variables can be used directly in the `format!` string
           --> src/run.rs:283:35
            |
        283 |                 enables.insert(0, format!("{}/{}", crate_name, feature));
            |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        help: change this to
            |
        283 -                 enables.insert(0, format!("{}/{}", crate_name, feature));
        283 +                 enables.insert(0, format!("{crate_name}/{feature}"));
            |
    dtolnay committed Mar 30, 2024
    Copy the full SHA
    348f552 View commit details
  5. Merge pull request #263 from dtolnay/clippy

    Resolve new clippy lints from Rust 1.57 through 1.70
    dtolnay authored Mar 30, 2024
    Copy the full SHA
    3eb5c5a View commit details

Commits on Apr 11, 2024

  1. Fix typo in readme

    dtolnay committed Apr 11, 2024
    Copy the full SHA
    59ef19a View commit details

Commits on May 3, 2024

  1. Fix trimming verbose type paths as the message has slightly changed with

    rust 1.78
    weiznich committed May 3, 2024
    Copy the full SHA
    8f99e5a View commit details

Commits on May 4, 2024

  1. Copy the full SHA
    bbe5be0 View commit details
  2. Release 1.0.92

    dtolnay committed May 4, 2024
    Copy the full SHA
    5fb7cae View commit details
Showing with 23 additions and 36 deletions.
  1. +1 −1 Cargo.toml
  2. +1 −1 README.md
  3. +4 −10 src/env.rs
  4. +2 −3 src/flock.rs
  5. +2 −1 src/lib.rs
  6. +2 −7 src/manifest.rs
  7. +5 −4 src/normalize.rs
  8. +6 −9 src/run.rs
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trybuild"
version = "1.0.91"
version = "1.0.92"
authors = ["David Tolnay <dtolnay@gmail.com>"]
categories = ["development-tools::testing"]
description = "Test harness for ui tests of compiler diagnostics"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ To test just one source file, use:
```
cargo test -- ui trybuild=example.rs
```
where `ui` is the name of the `#[test]` funtion that invokes `trybuild`, and
where `ui` is the name of the `#[test]` function that invokes `trybuild`, and
`example.rs` is the name of the file to test.

<br>
14 changes: 4 additions & 10 deletions src/env.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
use crate::error::{Error, Result};
use std::env;

#[derive(PartialEq, Debug)]
#[derive(PartialEq, Default, Debug)]
pub(crate) enum Update {
#[default]
Wip,
Overwrite,
}

impl Default for Update {
fn default() -> Self {
Update::Wip
}
}

impl Update {
pub fn env() -> Result<Self> {
let var = match env::var_os("TRYBUILD") {
Some(var) => var,
None => return Ok(Update::default()),
let Some(var) = env::var_os("TRYBUILD") else {
return Ok(Update::default());
};

match var.as_os_str().to_str() {
5 changes: 2 additions & 3 deletions src/flock.rs
Original file line number Diff line number Diff line change
@@ -115,9 +115,8 @@ fn create(path: &Path) -> Option<File> {
},
};

let modified = match metadata.modified() {
Ok(modified) => modified,
Err(_) => return None,
let Ok(modified) = metadata.modified() else {
return None;
};

let now = SystemTime::now();
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -208,7 +208,7 @@
//! makes error messages that we care about substantially worse, it is also
//! important to catch and report as a compiler issue.
#![doc(html_root_url = "https://docs.rs/trybuild/1.0.91")]
#![doc(html_root_url = "https://docs.rs/trybuild/1.0.92")]
#![allow(
clippy::collapsible_if,
clippy::default_trait_access,
@@ -231,6 +231,7 @@
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref,
clippy::uninhabited_references,
clippy::uninlined_format_args,
clippy::unused_self,
clippy::while_let_on_iterator,
)]
9 changes: 2 additions & 7 deletions src/manifest.rs
Original file line number Diff line number Diff line change
@@ -38,8 +38,9 @@ pub(crate) struct Package {
pub publish: bool,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub(crate) enum Edition {
#[default]
#[serde(rename = "2015")]
E2015,
#[serde(rename = "2018")]
@@ -75,12 +76,6 @@ pub(crate) struct Workspace {
pub dependencies: Map<String, Dependency>,
}

impl Default for Edition {
fn default() -> Self {
Edition::E2018
}
}

impl AsRef<OsStr> for Name {
fn as_ref(&self) -> &OsStr {
self.0.as_ref()
9 changes: 5 additions & 4 deletions src/normalize.rs
Original file line number Diff line number Diff line change
@@ -401,7 +401,9 @@ impl<'a> Filter<'a> {
let trimmed_line = trimmed_line
.strip_prefix("= note: ")
.unwrap_or(trimmed_line);
if trimmed_line.starts_with("the full type name has been written to") {
if trimmed_line.starts_with("the full type name has been written to")
|| trimmed_line.starts_with("the full name for the type has been written to")
{
return None;
}
}
@@ -516,9 +518,8 @@ fn unindent(diag: String, normalization: Normalization) -> String {
}

let mut ahead = lines.clone();
let next_line = match ahead.next() {
Some(line) => line,
None => continue,
let Some(next_line) = ahead.next() else {
continue;
};

if let IndentedLineKind::Code(indent) = indented_line_kind(next_line, normalization) {
15 changes: 6 additions & 9 deletions src/run.rs
Original file line number Diff line number Diff line change
@@ -264,9 +264,8 @@ impl Runner {
let mut features = source_manifest.features;
for (feature, enables) in &mut features {
enables.retain(|en| {
let dep_name = match en.strip_prefix("dep:") {
Some(dep_name) => dep_name,
None => return false,
let Some(dep_name) = en.strip_prefix("dep:") else {
return false;
};
if let Some(Dependency { optional: true, .. }) = dependencies.get(dep_name) {
return true;
@@ -622,9 +621,8 @@ fn parse_cargo_json(
let mut remaining = &*String::from_utf8_lossy(stdout);
let mut seen = Set::new();
while !remaining.is_empty() {
let begin = match remaining.find("{\"reason\":") {
Some(begin) => begin,
None => break,
let Some(begin) = remaining.find("{\"reason\":") else {
break;
};
let (nonmessage, rest) = remaining.split_at(begin);
nonmessage_stdout.push_str(nonmessage);
@@ -643,9 +641,8 @@ fn parse_cargo_json(
}
if let Ok(de) = serde_json::from_str::<CargoMessage>(message) {
if de.message.level != "failure-note" {
let (name, test) = match path_map.get(&de.target.src_path) {
Some(test) => test,
None => continue,
let Some((name, test)) = path_map.get(&de.target.src_path) else {
continue;
};
let entry = map
.entry(de.target.src_path)