-
Notifications
You must be signed in to change notification settings - Fork 13.5k
tests/ui
: A New Order [8/N]
#142200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Kivooeo
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
Kivooeo:tf8
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
tests/ui
: A New Order [8/N]
#142200
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! Regression test for `#[derive(Debug)]` on enums with uninhabited variants. | ||
//! | ||
//! Ensures there are no special warnings about uninhabited types when deriving | ||
//! Debug on an enum with uninhabited variants, only standard unused warnings. | ||
//! | ||
//! Issue: https://github.com/rust-lang/rust/issues/38885 | ||
|
||
//@ check-pass | ||
//@ compile-flags: -Wunused | ||
|
||
#[derive(Debug)] | ||
enum Void {} | ||
|
||
#[derive(Debug)] | ||
enum Foo { | ||
Bar(#[allow(dead_code)] u8), | ||
Void(Void), //~ WARN variant `Void` is never constructed | ||
} | ||
|
||
fn main() { | ||
let x = Foo::Bar(42); | ||
println!("{:?}", x); | ||
} |
2 changes: 1 addition & 1 deletion
2
...s/ui/derive-uninhabited-enum-38885.stderr → ...ives/derive-debug-uninhabited-enum.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! Test for well-formedness checking of default type parameters. | ||
//! | ||
//! Regression Test for: https://github.com/rust-lang/rust/issues/49344 | ||
|
||
//@ run-pass | ||
|
||
#![allow(dead_code)] | ||
|
||
trait Trait<T> {} | ||
struct Foo<U, V = i32>(U, V) | ||
where | ||
U: Trait<V>; | ||
|
||
trait Marker {} | ||
struct TwoParams<T, U>(T, U); | ||
impl Marker for TwoParams<i32, i32> {} | ||
|
||
// Clauses with more than 1 param are not checked. | ||
struct IndividuallyBogus<T = i32, U = i32>(TwoParams<T, U>) | ||
where | ||
TwoParams<T, U>: Marker; | ||
|
||
struct BogusTogether<T = u32, U = i32>(T, U) | ||
where | ||
TwoParams<T, U>: Marker; | ||
|
||
// Clauses with non-defaulted params are not checked. | ||
struct NonDefaultedInClause<T, U = i32>(TwoParams<T, U>) | ||
where | ||
TwoParams<T, U>: Marker; | ||
|
||
struct DefaultedLhs<U, V = i32>(U, V) | ||
where | ||
V: Trait<U>; | ||
|
||
// Dependent defaults are not checked. | ||
struct Dependent<T, U = T>(T, U) | ||
where | ||
U: Copy; | ||
|
||
trait SelfBound<T: Copy = Self> {} | ||
|
||
// Not even for well-formedness. | ||
struct WellFormedProjection<A, T = <A as Iterator>::Item>(A, T); | ||
|
||
// Issue #49344, predicates with lifetimes should not be checked. | ||
trait Scope<'a> {} | ||
struct Request<'a, S: Scope<'a> = i32>(S, &'a ()); | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//@ run-pass | ||
|
||
#![allow(warnings)] | ||
|
||
//! Tests type inference fallback to `!` (never type) in `Option` context. | ||
//! | ||
//! Regression test for issues: | ||
//! - https://github.com/rust-lang/rust/issues/39808 | ||
//! - https://github.com/rust-lang/rust/issues/39984 | ||
//! | ||
//! Here the type of `c` is `Option<?T>`, where `?T` is unconstrained. | ||
//! Because there is data-flow from the `{ return; }` block, which | ||
//! diverges and hence has type `!`, into `c`, we will default `?T` to | ||
//! `!`, and hence this code compiles rather than failing and requiring | ||
//! a type annotation. | ||
|
||
fn main() { | ||
let c = Some({ | ||
return; | ||
}); | ||
c.unwrap(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! Regression test for destructuring trait references (`&dyn T`/`Box<dyn T>`). | ||
//! Checks cases where number of `&`/`Box` patterns (n) matches/doesn't match references (m). | ||
//! | ||
//! Issue: https://github.com/rust-lang/rust/issues/15031 | ||
|
||
#![feature(box_patterns)] | ||
|
||
trait T { | ||
fn foo(&self) {} | ||
} | ||
|
||
impl T for isize {} | ||
|
||
fn main() { | ||
// Valid cases: n < m (can dereference) | ||
let &x = &(&1isize as &dyn T); | ||
let &x = &&(&1isize as &dyn T); | ||
let &&x = &&(&1isize as &dyn T); | ||
|
||
// Error cases: n == m (cannot dereference trait object) | ||
let &x = &1isize as &dyn T; //~ ERROR type `&dyn T` cannot be dereferenced | ||
let &&x = &(&1isize as &dyn T); //~ ERROR type `&dyn T` cannot be dereferenced | ||
let box x = Box::new(1isize) as Box<dyn T>; //~ ERROR type `Box<dyn T>` cannot be dereferenced | ||
|
||
// Error cases: n > m (type mismatch) | ||
let &&x = &1isize as &dyn T; //~ ERROR mismatched types | ||
let &&&x = &(&1isize as &dyn T); //~ ERROR mismatched types | ||
let box box x = Box::new(1isize) as Box<dyn T>; //~ ERROR mismatched types | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/ui/typeck/inference-method-chain-diverging-fallback.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//! Test type inference in method chains with diverging fallback. | ||
//! Verifies that closure type in `unwrap_or_else` is properly inferred | ||
//! when chained with other combinators and contains a diverging path. | ||
|
||
//@ run-pass | ||
|
||
fn produce<T>() -> Result<&'static str, T> { | ||
Ok("22") | ||
} | ||
|
||
fn main() { | ||
// The closure's error type `T` must unify with `ParseIntError`, | ||
// while the success type must be `usize` (from parse()) | ||
let x: usize = produce() | ||
.and_then(|x| x.parse::<usize>()) // Explicit turbofish for clarity | ||
.unwrap_or_else(|_| panic!()); // Diverging fallback | ||
|
||
assert_eq!(x, 22); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.