-
Notifications
You must be signed in to change notification settings - Fork 13.5k
tests/ui
: A New Order [24/N]
#143299
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
base: master
Are you sure you want to change the base?
tests/ui
: A New Order [24/N]
#143299
Changes from all commits
986f1c9
9be4bcd
3df48f6
4b82fe0
7cb0de1
dcb061a
ef026d2
5a8f69b
646fc84
fcfead1
33a7363
0bf3ac7
556939a
bca9973
d7e4a86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
// Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of | ||
// checking the `PhantomData<T>` type itself (which almost always implements an auto trait). | ||
//! Test that auto trait checks examine `T` in `PhantomData<T>` fields. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like useful context to keep |
||
#![feature(auto_traits)] | ||
|
||
use std::marker::{PhantomData}; | ||
use std::marker::PhantomData; | ||
|
||
unsafe auto trait Zen {} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! Test evaluation order in binary operations with primitive types. | ||
|
||
//@ run-pass | ||
|
||
fn main() { | ||
let x = Box::new(0); | ||
assert_eq!( | ||
0, | ||
*x + { | ||
drop(x); | ||
let _ = Box::new(main); | ||
0 | ||
} | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! Tests basic pointer coercions between: | ||
//! - `&mut T` -> `&T` | ||
//! - `&T` -> `*const T` | ||
//! - `&mut T` -> `*const T` | ||
//! - `*mut T` -> `*const T` | ||
Comment on lines
+2
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not needed, since it's commented in the file. Better that if something else gets added here, it only needs to get updated in one place. |
||
|
||
//@ run-pass | ||
|
||
pub fn main() { | ||
// &mut -> & | ||
let x: &mut isize = &mut 42; | ||
let _: &isize = x; | ||
let _: &isize = &mut 42; | ||
|
||
// & -> *const | ||
let x: &isize = &42; | ||
let _: *const isize = x; | ||
let _: *const isize = &42; | ||
|
||
// &mut -> *const | ||
let x: &mut isize = &mut 42; | ||
let _: *const isize = x; | ||
let _: *const isize = &mut 42; | ||
|
||
// *mut -> *const | ||
let _: *mut isize = &mut 42; | ||
let _: *const isize = x; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//! Test closure parameter type inference and type mismatch errors. | ||
//! | ||
//! Related to <https://github.com/rust-lang/rust/issues/2093>. | ||
|
||
//@ dont-require-annotations: NOTE | ||
|
||
fn let_in<T, F>(x: T, f: F) | ||
where | ||
F: FnOnce(T), | ||
{ | ||
} | ||
|
||
fn main() { | ||
let_in(3u32, |i| { | ||
assert!(i == 3i32); | ||
//~^ ERROR mismatched types | ||
//~| NOTE expected `u32`, found `i32` | ||
}); | ||
|
||
let_in(3i32, |i| { | ||
assert!(i == 3u32); | ||
//~^ ERROR mismatched types | ||
//~| NOTE expected `i32`, found `u32` | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/closure-parameter-type-inference-mismatch.rs:15:22 | ||
| | ||
LL | assert!(i == 3i32); | ||
| - ^^^^ expected `u32`, found `i32` | ||
| | | ||
| expected because this is `u32` | ||
| | ||
help: change the type of the numeric literal from `i32` to `u32` | ||
| | ||
LL - assert!(i == 3i32); | ||
LL + assert!(i == 3u32); | ||
| | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/closure-parameter-type-inference-mismatch.rs:21:22 | ||
| | ||
LL | assert!(i == 3u32); | ||
| - ^^^^ expected `i32`, found `u32` | ||
| | | ||
| expected because this is `i32` | ||
| | ||
help: change the type of the numeric literal from `u32` to `i32` | ||
| | ||
LL - assert!(i == 3u32); | ||
LL + assert!(i == 3i32); | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//! Tests correct parsing of doc comments on generic parameters in traits. | ||
//! Checks that compiler doesn't panic when processing this. | ||
|
||
//@ check-pass | ||
|
||
#![crate_type = "lib"] | ||
|
||
pub trait Layer< | ||
/// Documentation for generic parameter. | ||
Input, | ||
> | ||
{ | ||
} | ||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bit unusual format, did this come from rustfmt? It's fine, just surprising |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Tests how we behave when the user attempts to mutate an immutable | ||
//! binding that was introduced by either `ref` or `ref mut` | ||
//! patterns. | ||
//! | ||
//! Such bindings cannot be made mutable via the mere addition of the | ||
//! `mut` keyword, and thus we want to check that the compiler does not | ||
//! suggest doing so. | ||
|
||
fn main() { | ||
let (mut one_two, mut three_four) = ((1, 2), (3, 4)); | ||
|
||
// Bind via pattern: | ||
// - `a` as immutable reference (`ref`) | ||
// - `b` as mutable reference (`ref mut`) | ||
let &mut (ref a, ref mut b) = &mut one_two; | ||
|
||
// Attempt to reassign immutable `ref`-bound variable | ||
a = &three_four.0; | ||
//~^ ERROR cannot assign twice to immutable variable `a` | ||
|
||
// Attempt to reassign mutable `ref mut`-bound variable | ||
b = &mut three_four.1; | ||
//~^ ERROR cannot assign twice to immutable variable `b` | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//! Test that `--print calling-conventions` outputs all supported calling conventions. | ||
|
||
//@ compile-flags: --print calling-conventions | ||
//@ build-pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffer overflow is typically an OOB write, but this was an OOB read right?