Skip to content

Commit

Permalink
Add tests for custom Some and None definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
sgued committed Jul 17, 2022
1 parent 4dbba64 commit 477b02a
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/ui/iter_empty.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,30 @@ macro_rules! in_macros {
};
}

// Don't trigger on a `None` that isn't std's option
mod custom_option {
#[allow(unused)]
enum CustomOption {
Some(i32),
None,
}

impl CustomOption {
fn iter(&self) {}
fn iter_mut(&mut self) {}
fn into_iter(self) {}
}
use CustomOption::*;

pub fn custom_option() {
None.iter();
None.iter_mut();
None.into_iter();
}
}

fn main() {
array();
custom_option::custom_option();
in_macros!();
}
23 changes: 23 additions & 0 deletions tests/ui/iter_empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,30 @@ macro_rules! in_macros {
};
}

// Don't trigger on a `None` that isn't std's option
mod custom_option {
#[allow(unused)]
enum CustomOption {
Some(i32),
None,
}

impl CustomOption {
fn iter(&self) {}
fn iter_mut(&mut self) {}
fn into_iter(self) {}
}
use CustomOption::*;

pub fn custom_option() {
None.iter();
None.iter_mut();
None.into_iter();
}
}

fn main() {
array();
custom_option::custom_option();
in_macros!();
}
23 changes: 23 additions & 0 deletions tests/ui/iter_once.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,30 @@ macro_rules! in_macros {
};
}

// Don't trigger on a `Some` that isn't std's option
mod custom_option {
#[allow(unused)]
enum CustomOption {
Some(i32),
None,
}

impl CustomOption {
fn iter(&self) {}
fn iter_mut(&mut self) {}
fn into_iter(self) {}
}
use CustomOption::*;

pub fn custom_option() {
Some(3).iter();
Some(3).iter_mut();
Some(3).into_iter();
}
}

fn main() {
array();
custom_option::custom_option();
in_macros!();
}
23 changes: 23 additions & 0 deletions tests/ui/iter_once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,30 @@ macro_rules! in_macros {
};
}

// Don't trigger on a `Some` that isn't std's option
mod custom_option {
#[allow(unused)]
enum CustomOption {
Some(i32),
None,
}

impl CustomOption {
fn iter(&self) {}
fn iter_mut(&mut self) {}
fn into_iter(self) {}
}
use CustomOption::*;

pub fn custom_option() {
Some(3).iter();
Some(3).iter_mut();
Some(3).into_iter();
}
}

fn main() {
array();
custom_option::custom_option();
in_macros!();
}

0 comments on commit 477b02a

Please sign in to comment.