Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJung

Rollup of 9 pull requests

Successful merges:

 - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes)
 - #71095 (impl From<[T; N]> for Box<[T]>)
 - #71500 (Make pointer offset methods/intrinsics const)
 - #71804 (linker: Support `-static-pie` and `-static -shared`)
 - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn)
 - #72103 (borrowck `DefId` -> `LocalDefId`)
 - #72407 (Various minor improvements to Ipv6Addr::Display)
 - #72413 (impl Step for char (make Range*<char> iterable))
 - #72439 (NVPTX support for new asm!)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-05-29 23:43:20 +00:00
commit 0e9e408310
89 changed files with 1894 additions and 473 deletions

View file

@ -14,16 +14,16 @@ note: ...so that the expression is assignable
|
LL | bar(foo, x)
| ^
= note: expected `Type<'_>`
found `Type<'a>`
= note: expected `Type<'_>`
found `Type<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the expression is assignable
--> $DIR/project-fn-ret-invariant.rs:48:4
|
LL | bar(foo, x)
| ^^^^^^^^^^^
= note: expected `Type<'static>`
found `Type<'_>`
= note: expected `Type<'static>`
found `Type<'_>`
error: aborting due to previous error

View file

@ -18,6 +18,10 @@ pub fn yes_array_into_vec<T>() -> Vec<T> {
[].into()
}
pub fn yes_array_into_box<T>() -> Box<[T]> {
[].into()
}
use std::collections::VecDeque;
pub fn yes_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 32]>

View file

@ -12,6 +12,8 @@ pub fn no_box() {
let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
//~^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From<std::boxed::Box<[i32]>>` is not satisfied
//~^^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom<std::boxed::Box<[i32]>>` is not satisfied
let boxed_slice = <Box<[i32]>>::from([0; 33]);
//~^ 15:42: 15:49: arrays only have std trait implementations for lengths 0..=32 [E0277]
}
pub fn no_rc() {

View file

@ -18,10 +18,23 @@ LL | let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<&str>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::borrow::Cow<'a, str>>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::string::String>>
and 21 others
and 22 others
= note: required because of the requirements on the impl of `std::convert::Into<std::boxed::Box<[i32; 33]>>` for `std::boxed::Box<[i32]>`
= note: required because of the requirements on the impl of `std::convert::TryFrom<std::boxed::Box<[i32]>>` for `std::boxed::Box<[i32; 33]>`
error[E0277]: arrays only have std trait implementations for lengths 0..=32
--> $DIR/alloc-types-no-impls-length-33.rs:15:42
|
LL | let boxed_slice = <Box<[i32]>>::from([0; 33]);
| ^^^^^^^
| |
| expected an implementor of trait `std::convert::From<[{integer}; 33]>`
| help: consider borrowing here: `&[0; 33]`
|
= note: the trait bound `[i32; 33]: std::convert::From<[{integer}; 33]>` is not satisfied
= note: required because of the requirements on the impl of `std::convert::From<[i32; 33]>` for `std::boxed::Box<[i32]>`
= note: required by `std::convert::From::from`
error[E0277]: the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom<std::boxed::Box<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:12:23
|
@ -32,7 +45,7 @@ LL | let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
<std::boxed::Box<[T; N]> as std::convert::TryFrom<std::boxed::Box<[T]>>>
error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From<std::rc::Rc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:19:23
--> $DIR/alloc-types-no-impls-length-33.rs:21:23
|
LL | let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::rc::Rc<[i32]>>` is not implemented for `std::rc::Rc<[i32; 33]>`
@ -47,7 +60,7 @@ LL | let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
= note: required because of the requirements on the impl of `std::convert::TryFrom<std::rc::Rc<[i32]>>` for `std::rc::Rc<[i32; 33]>`
error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom<std::rc::Rc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:19:23
--> $DIR/alloc-types-no-impls-length-33.rs:21:23
|
LL | let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::rc::Rc<[i32]>>` is not implemented for `std::rc::Rc<[i32; 33]>`
@ -56,7 +69,7 @@ LL | let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
<std::rc::Rc<[T; N]> as std::convert::TryFrom<std::rc::Rc<[T]>>>
error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From<std::sync::Arc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:26:23
--> $DIR/alloc-types-no-impls-length-33.rs:28:23
|
LL | let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::sync::Arc<[i32]>>` is not implemented for `std::sync::Arc<[i32; 33]>`
@ -71,7 +84,7 @@ LL | let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
= note: required because of the requirements on the impl of `std::convert::TryFrom<std::sync::Arc<[i32]>>` for `std::sync::Arc<[i32; 33]>`
error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom<std::sync::Arc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:26:23
--> $DIR/alloc-types-no-impls-length-33.rs:28:23
|
LL | let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::sync::Arc<[i32]>>` is not implemented for `std::sync::Arc<[i32; 33]>`
@ -79,6 +92,6 @@ LL | let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
= help: the following implementations were found:
<std::sync::Arc<[T; N]> as std::convert::TryFrom<std::sync::Arc<[T]>>>
error: aborting due to 7 previous errors
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -2,8 +2,7 @@
#![feature(core_intrinsics)]
#![allow(const_err)]
// A test demonstrating that we prevent doing even trivial
// pointer arithmetic or comparison during CTFE.
// During CTFE, we prevent pointer comparison and pointer-to-int casts.
static CMP: () = {
let x = &0 as *const _;
@ -19,11 +18,4 @@ static INT_PTR_ARITH: () = unsafe {
//~| NOTE pointer-to-integer cast
};
static PTR_ARITH: () = unsafe {
let x = &0 as *const _;
let _v = core::intrinsics::offset(x, 0);
//~^ ERROR could not evaluate static initializer
//~| NOTE calling intrinsic `offset`
};
fn main() {}

View file

@ -1,39 +1,28 @@
error[E0080]: could not evaluate static initializer
--> $DIR/ptr_arith.rs:10:14
--> $DIR/ptr_arith.rs:9:14
|
LL | let _v = x == x;
| ^^^^^^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
error[E0080]: could not evaluate static initializer
--> $DIR/ptr_arith.rs:17:14
--> $DIR/ptr_arith.rs:16:14
|
LL | let _v = x + 0;
| ^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
error[E0080]: could not evaluate static initializer
--> $DIR/ptr_arith.rs:24:14
|
LL | let _v = core::intrinsics::offset(x, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "calling intrinsic `offset`" needs an rfc before being allowed inside constants
warning: skipping const checks
|
help: skipping check for `const_compare_raw_pointers` feature
--> $DIR/ptr_arith.rs:10:14
--> $DIR/ptr_arith.rs:9:14
|
LL | let _v = x == x;
| ^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/ptr_arith.rs:16:20
--> $DIR/ptr_arith.rs:15:20
|
LL | let x: usize = std::mem::transmute(&0);
| ^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/ptr_arith.rs:24:14
|
LL | let _v = core::intrinsics::offset(x, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0080`.

View file

@ -0,0 +1,115 @@
// run-pass
#![feature(const_ptr_offset)]
#![feature(const_ptr_offset_from)]
#![feature(ptr_offset_from)]
use std::ptr;
#[repr(C)]
struct Struct {
a: u32,
b: u32,
c: u32,
}
static S: Struct = Struct { a: 0, b: 0, c: 0 };
// For these tests we use offset_from to check that two pointers are equal.
// Rust doesn't currently support comparing pointers in const fn.
static OFFSET_NO_CHANGE: bool = unsafe {
let p1 = &S.b as *const u32;
let p2 = p1.offset(2).offset(-2);
p1.offset_from(p2) == 0
};
static OFFSET_MIDDLE: bool = unsafe {
let p1 = (&S.a as *const u32).offset(1);
let p2 = (&S.c as *const u32).offset(-1);
p1.offset_from(p2) == 0
};
// Pointing to the end of the allocation is OK
static OFFSET_END: bool = unsafe {
let p1 = (&S.a as *const u32).offset(3);
let p2 = (&S.c as *const u32).offset(1);
p1.offset_from(p2) == 0
};
// Casting though a differently sized type is OK
static OFFSET_U8_PTR: bool = unsafe {
let p1 = (&S.a as *const u32 as *const u8).offset(5);
let p2 = (&S.c as *const u32 as *const u8).offset(-3);
p1.offset_from(p2) == 0
};
// Any offset with a ZST does nothing
const OFFSET_ZST: bool = unsafe {
let pz = &() as *const ();
// offset_from can't work with ZSTs, so cast to u8 ptr
let p1 = pz.offset(5) as *const u8;
let p2 = pz.offset(isize::MIN) as *const u8;
p1.offset_from(p2) == 0
};
const OFFSET_ZERO: bool = unsafe {
let p = [0u8; 0].as_ptr();
p.offset(0).offset_from(p) == 0
};
const OFFSET_ONE: bool = unsafe {
let p = &42u32 as *const u32;
p.offset(1).offset_from(p) == 1
};
const OFFSET_DANGLING: bool = unsafe {
let p = ptr::NonNull::<u8>::dangling().as_ptr();
p.offset(0).offset_from(p) == 0
};
const OFFSET_UNALIGNED: bool = unsafe {
let arr = [0u8; 32];
let p1 = arr.as_ptr();
let p2 = (p1.offset(2) as *const u32).offset(1);
(p2 as *const u8).offset_from(p1) == 6
};
const WRAP_OFFSET_NO_CHANGE: bool = unsafe {
let p1 = &42u32 as *const u32;
let p2 = p1.wrapping_offset(1000).wrapping_offset(-1000);
let p3 = p1.wrapping_offset(-1000).wrapping_offset(1000);
(p1.offset_from(p2) == 0) & (p1.offset_from(p3) == 0)
};
const WRAP_ADDRESS_SPACE: bool = unsafe {
let p1 = &42u8 as *const u8;
let p2 = p1.wrapping_offset(isize::MIN).wrapping_offset(isize::MIN);
p1.offset_from(p2) == 0
};
// Wrap on the count*size_of::<T>() calculation.
const WRAP_SIZE_OF: bool = unsafe {
// Make sure that if p1 moves backwards, we are still in range
let arr = [0u32; 2];
let p = &arr[1] as *const u32;
// With wrapping arithmetic, isize::MAX * 4 == -4
let wrapped = p.wrapping_offset(isize::MAX);
let backward = p.wrapping_offset(-1);
wrapped.offset_from(backward) == 0
};
const WRAP_INTEGER_POINTER: bool = unsafe {
let p1 = (0x42 as *const u32).wrapping_offset(4);
let p2 = 0x52 as *const u32;
p1.offset_from(p2) == 0
};
const WRAP_NULL: bool = unsafe {
let p1 = ptr::null::<u32>().wrapping_offset(1);
let p2 = 0x4 as *const u32;
p1.offset_from(p2) == 0
};
fn main() {
assert!(OFFSET_NO_CHANGE);
assert!(OFFSET_MIDDLE);
assert!(OFFSET_END);
assert!(OFFSET_U8_PTR);
assert!(OFFSET_ZST);
assert!(OFFSET_ZERO);
assert!(OFFSET_ONE);
assert!(OFFSET_DANGLING);
assert!(OFFSET_UNALIGNED);
assert!(WRAP_OFFSET_NO_CHANGE);
assert!(WRAP_ADDRESS_SPACE);
assert!(WRAP_SIZE_OF);
assert!(WRAP_INTEGER_POINTER);
assert!(WRAP_NULL);
}

View file

@ -0,0 +1,25 @@
// ignore-tidy-linelength
#![feature(const_ptr_offset)]
use std::ptr;
// normalize-stderr-test "alloc\d+" -> "allocN"
pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; //~NOTE
pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; //~NOTE
pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; //~NOTE
pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; //~NOTE
pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; //~NOTE
pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; //~NOTE
pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; //~NOTE
pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; //~NOTE
pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; //~NOTE
// Right now, a zero offset from null is UB
pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) }; //~NOTE
// Make sure that we don't panic when computing abs(offset*size_of::<T>())
pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; //~NOTE
fn main() {}

View file

@ -0,0 +1,169 @@
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| overflowing in-bounds pointer arithmetic
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `BEFORE_START` at $DIR/offset_ub.rs:7:46
|
::: $DIR/offset_ub.rs:7:1
|
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
| ------------------------------------------------------------------------------
|
= note: `#[deny(const_err)]` on by default
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| inbounds test failed: pointer must be in-bounds at offset 2, but is outside bounds of allocN which has size 1
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `AFTER_END` at $DIR/offset_ub.rs:8:43
|
::: $DIR/offset_ub.rs:8:1
|
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
| --------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| inbounds test failed: pointer must be in-bounds at offset 101, but is outside bounds of allocN which has size 100
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `AFTER_ARRAY` at $DIR/offset_ub.rs:9:45
|
::: $DIR/offset_ub.rs:9:1
|
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
| ------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| overflowing in-bounds pointer arithmetic
| inside `std::ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `OVERFLOW` at $DIR/offset_ub.rs:11:43
|
::: $DIR/offset_ub.rs:11:1
|
LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) };
| ----------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| overflowing in-bounds pointer arithmetic
| inside `std::ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `UNDERFLOW` at $DIR/offset_ub.rs:12:44
|
::: $DIR/offset_ub.rs:12:1
|
LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) };
| -----------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| overflowing in-bounds pointer arithmetic
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `OVERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:13:56
|
::: $DIR/offset_ub.rs:13:1
|
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
| ---------------------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| overflowing in-bounds pointer arithmetic
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `UNDERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:14:57
|
::: $DIR/offset_ub.rs:14:1
|
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
| --------------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| inbounds test failed: pointer must be in-bounds at offset 1, but is outside bounds of allocN which has size 0
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:16:50
|
::: $DIR/offset_ub.rs:16:1
|
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
| -------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/mut_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count) as *mut T
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unable to turn bytes into a pointer
| inside `std::ptr::mut_ptr::<impl *mut u8>::offset` at $SRC_DIR/libcore/ptr/mut_ptr.rs:LL:COL
| inside `DANGLING` at $DIR/offset_ub.rs:17:42
|
::: $DIR/offset_ub.rs:17:1
|
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
| ---------------------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| inbounds test failed: 0x0 is not a valid pointer
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:20:50
|
::: $DIR/offset_ub.rs:20:1
|
LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) };
| -------------------------------------------------------------------------------
error: any use of this value will cause an error
--> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
|
LL | intrinsics::offset(self, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unable to turn bytes into a pointer
| inside `std::ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
| inside `UNDERFLOW_ABS` at $DIR/offset_ub.rs:23:47
|
::: $DIR/offset_ub.rs:23:1
|
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
| ---------------------------------------------------------------------------------------------
error: aborting due to 11 previous errors

View file

@ -58,8 +58,8 @@ note: ...so that the expression is assignable
|
LL | let x: &'a _ = &y;
| ^^
= note: expected `&'a &()`
found `&'a &'b ()`
= note: expected `&'a &()`
found `&'a &'b ()`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 1:6...
--> $DIR/E0490.rs:1:6
|

View file

@ -0,0 +1,6 @@
#![deny(unsafe_op_in_unsafe_fn)]
//~^ ERROR the `unsafe_op_in_unsafe_fn` lint is unstable
//~| ERROR the `unsafe_op_in_unsafe_fn` lint is unstable
//~| ERROR the `unsafe_op_in_unsafe_fn` lint is unstable
fn main() {}

View file

@ -0,0 +1,30 @@
error[E0658]: the `unsafe_op_in_unsafe_fn` lint is unstable
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:1
|
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #71668 <https://github.com/rust-lang/rust/issues/71668> for more information
= help: add `#![feature(unsafe_block_in_unsafe_fn)]` to the crate attributes to enable
error[E0658]: the `unsafe_op_in_unsafe_fn` lint is unstable
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:1
|
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #71668 <https://github.com/rust-lang/rust/issues/71668> for more information
= help: add `#![feature(unsafe_block_in_unsafe_fn)]` to the crate attributes to enable
error[E0658]: the `unsafe_op_in_unsafe_fn` lint is unstable
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:1
|
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #71668 <https://github.com/rust-lang/rust/issues/71668> for more information
= help: add `#![feature(unsafe_block_in_unsafe_fn)]` to the crate attributes to enable
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -14,16 +14,16 @@ note: ...so that the expression is assignable
|
LL | static_val(x);
| ^
= note: expected `std::boxed::Box<dyn std::fmt::Debug>`
found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
= note: expected `std::boxed::Box<dyn std::fmt::Debug>`
found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the types are compatible
--> $DIR/dyn-trait.rs:20:5
|
LL | static_val(x);
| ^^^^^^^^^^
= note: expected `StaticTrait`
found `StaticTrait`
= note: expected `StaticTrait`
found `StaticTrait`
error: aborting due to previous error

View file

@ -2,15 +2,17 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl-2.rs:8:5
|
LL | fn deref(&self) -> &dyn Trait {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&Struct) -> &dyn Trait
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Struct) -> &dyn Trait`
|
::: $SRC_DIR/libcore/ops/deref.rs:LL:COL
|
LL | fn deref(&self) -> &Self::Target;
| --------------------------------- expected fn(&Struct) -> &(dyn Trait + 'static)
| --------------------------------- expected `fn(&Struct) -> &(dyn Trait + 'static)`
|
= note: expected `fn(&Struct) -> &(dyn Trait + 'static)`
found `fn(&Struct) -> &dyn Trait`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
error: aborting due to previous error

View file

@ -2,13 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl.rs:9:5
|
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
| ---------------------------------------------- expected fn(&i32, &'a u32, &u32) -> &'a u32
| ---------------------------------------------- expected `fn(&i32, &'a u32, &u32) -> &'a u32`
...
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&i32, &u32, &u32) -> &u32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &u32, &u32) -> &u32`
|
= note: expected `fn(&i32, &'a u32, &u32) -> &'a u32`
found `fn(&i32, &u32, &u32) -> &u32`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
error: aborting due to previous error

View file

@ -2,13 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl.rs:9:5
|
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
| ---------------------------------------------- expected fn(&i32, &'a u32, &u32) -> &'a u32
| ---------------------------------------------- expected `fn(&i32, &'a u32, &u32) -> &'a u32`
...
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&i32, &u32, &u32) -> &u32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &u32, &u32) -> &u32`
|
= note: expected `fn(&i32, &'a u32, &u32) -> &'a u32`
found `fn(&i32, &u32, &u32) -> &u32`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
error[E0623]: lifetime mismatch
--> $DIR/mismatched_trait_impl.rs:10:9

View file

@ -26,8 +26,8 @@ note: ...so that the types are compatible
|
LL | self.a();
| ^
= note: expected `&'a Self`
found `&Self`
= note: expected `&'a Self`
found `&Self`
error: aborting due to previous error

View file

@ -27,8 +27,8 @@ note: ...so that the types are compatible
|
LL | self.foo();
| ^^^
= note: expected `&'a Self`
found `&Self`
= note: expected `&'a Self`
found `&Self`
error: aborting due to previous error

View file

@ -87,8 +87,8 @@ note: ...so that the types are compatible
|
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `Publisher<'_>`
found `Publisher<'_>`
= note: expected `Publisher<'_>`
found `Publisher<'_>`
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/issue-20831-debruijn.rs:28:33
@ -117,8 +117,8 @@ note: ...so that the types are compatible
|
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `Publisher<'_>`
found `Publisher<'_>`
= note: expected `Publisher<'_>`
found `Publisher<'_>`
error: aborting due to 4 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | match (&t,) {
| ^^^^^
= note: expected `(&&(T,),)`
found `(&&'a (T,),)`
= note: expected `(&&(T,),)`
found `(&&'a (T,),)`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 1:27...
--> $DIR/issue-52213.rs:1:27
|

View file

@ -20,8 +20,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(self.out_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/issue-55796.rs:21:9
@ -45,8 +45,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(self.in_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
error: aborting due to 2 previous errors

View file

@ -2,13 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/lifetime-mismatch-between-trait-and-impl.rs:6:5
|
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
| ------------------------------------------- expected fn(&i32, &'a i32) -> &'a i32
| ------------------------------------------- expected `fn(&i32, &'a i32) -> &'a i32`
...
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&i32, &i32) -> &i32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &i32) -> &i32`
|
= note: expected `fn(&i32, &'a i32) -> &'a i32`
found `fn(&i32, &i32) -> &i32`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
error: aborting due to previous error

View file

@ -26,8 +26,8 @@ note: ...so that the expression is assignable
|
LL | Foo { bar }
| ^^^^^^^^^^^
= note: expected `Foo<'_>`
found `Foo<'_>`
= note: expected `Foo<'_>`
found `Foo<'_>`
error: aborting due to previous error

View file

@ -19,8 +19,8 @@ note: ...so that the types are compatible
|
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `Visitor<'d>`
found `Visitor<'_>`
= note: expected `Visitor<'d>`
found `Visitor<'_>`
error: aborting due to previous error

View file

@ -16,8 +16,8 @@ note: ...so that the expression is assignable
|
LL | C { f: b }
| ^
= note: expected `std::boxed::Box<std::boxed::Box<&isize>>`
found `std::boxed::Box<std::boxed::Box<&isize>>`
= note: expected `std::boxed::Box<std::boxed::Box<&isize>>`
found `std::boxed::Box<std::boxed::Box<&isize>>`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 15:6...
--> $DIR/type-alias-free-regions.rs:15:6
|
@ -28,8 +28,8 @@ note: ...so that the expression is assignable
|
LL | C { f: b }
| ^^^^^^^^^^
= note: expected `C<'a>`
found `C<'_>`
= note: expected `C<'a>`
found `C<'_>`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/type-alias-free-regions.rs:27:16
@ -49,8 +49,8 @@ note: ...so that the expression is assignable
|
LL | C { f: Box::new(b.0) }
| ^^^
= note: expected `std::boxed::Box<&isize>`
found `std::boxed::Box<&isize>`
= note: expected `std::boxed::Box<&isize>`
found `std::boxed::Box<&isize>`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 25:6...
--> $DIR/type-alias-free-regions.rs:25:6
|
@ -61,8 +61,8 @@ note: ...so that the expression is assignable
|
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^^^^^^^^^^
= note: expected `C<'a>`
found `C<'_>`
= note: expected `C<'a>`
found `C<'_>`
error: aborting due to 2 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | <Foo<'a>>::C
| ^^^^^^^^^^^^
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> $DIR/constant-in-expr-inherent-1.rs:8:5

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | T::C
| ^^^^
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> $DIR/constant-in-expr-trait-item-3.rs:10:5

View file

@ -24,8 +24,8 @@ note: ...so that the expression is assignable
|
LL | ss
| ^^
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/object-lifetime-default-elision.rs:71:5
@ -53,8 +53,8 @@ note: ...so that the expression is assignable
|
LL | ss
| ^^
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
error: aborting due to 2 previous errors

View file

@ -39,8 +39,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(v)
| ^
= note: expected `&[u8]`
found `&'a [u8]`
= note: expected `&[u8]`
found `&'a [u8]`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 25:9...
--> $DIR/region-object-lifetime-in-coercion.rs:25:9
|
@ -51,8 +51,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(v)
| ^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn Foo + 'b)>`
found `std::boxed::Box<dyn Foo>`
= note: expected `std::boxed::Box<(dyn Foo + 'b)>`
found `std::boxed::Box<dyn Foo>`
error: aborting due to 4 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | impl<'a> Foo<'static> for &'a i32 {
| ^^^^^^^^^^^^
= note: expected `Foo<'static>`
found `Foo<'static>`
= note: expected `Foo<'static>`
found `Foo<'static>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the type `&i32` will meet its required lifetime bounds
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
@ -39,8 +39,8 @@ note: ...so that the types are compatible
|
LL | impl<'a,'b> Foo<'b> for &'a i64 {
| ^^^^^^^
= note: expected `Foo<'b>`
found `Foo<'_>`
= note: expected `Foo<'b>`
found `Foo<'_>`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9...
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9
|

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | impl<'a> Foo for &'a i32 {
| ^^^
= note: expected `Foo`
found `Foo`
= note: expected `Foo`
found `Foo`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the type `&i32` will meet its required lifetime bounds
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10

View file

@ -20,8 +20,8 @@ note: ...so that the expression is assignable
|
LL | box B(&*v) as Box<dyn X>
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
error: aborting due to previous error

View file

@ -20,8 +20,8 @@ note: ...so that the expression is assignable
|
LL | box B(&*v) as Box<dyn X>
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
error: aborting due to previous error

View file

@ -24,8 +24,8 @@ note: ...so that the expression is assignable
|
LL | box v as Box<dyn SomeTrait + 'a>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn SomeTrait + 'c)>`
found `std::boxed::Box<dyn SomeTrait>`
= note: expected `std::boxed::Box<(dyn SomeTrait + 'c)>`
found `std::boxed::Box<dyn SomeTrait>`
error: aborting due to previous error

View file

@ -14,8 +14,8 @@ note: ...so that the expression is assignable
|
LL | Ast::Add(x, y)
| ^
= note: expected `&Ast<'_>`
found `&Ast<'a>`
= note: expected `&Ast<'_>`
found `&Ast<'a>`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 6:19...
--> $DIR/regions-creating-enums4.rs:6:19
|
@ -26,8 +26,8 @@ note: ...so that the expression is assignable
|
LL | Ast::Add(x, y)
| ^^^^^^^^^^^^^^
= note: expected `Ast<'b>`
found `Ast<'_>`
= note: expected `Ast<'b>`
found `Ast<'_>`
error: aborting due to previous error

View file

@ -39,8 +39,8 @@ LL | | if false { return ay; }
LL | | return z;
LL | | }));
| |_____^
= note: expected `&isize`
found `&isize`
= note: expected `&isize`
found `&isize`
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/regions-nested-fns.rs:14:27

View file

@ -29,8 +29,8 @@ LL | | where <() as Project<'a, 'b>>::Item : Eq
LL | | {
LL | | }
| |_^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/regions-normalize-in-where-clause-list.rs:22:1
@ -63,8 +63,8 @@ LL | | where <() as Project<'a, 'b>>::Item : Eq
LL | | {
LL | | }
| |_^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/regions-normalize-in-where-clause-list.rs:22:4
@ -87,8 +87,8 @@ note: ...so that the types are compatible
|
LL | fn bar<'a, 'b>()
| ^^^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
error: aborting due to 3 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the expression is assignable
|
LL | with(|o| o)
| ^
= note: expected `&isize`
found `&isize`
= note: expected `&isize`
found `&isize`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 9:14...
--> $DIR/regions-ret-borrowed-1.rs:9:14
|

View file

@ -14,8 +14,8 @@ note: ...so that the expression is assignable
|
LL | with(|o| o)
| ^
= note: expected `&isize`
found `&isize`
= note: expected `&isize`
found `&isize`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 12:14...
--> $DIR/regions-ret-borrowed.rs:12:14
|

View file

@ -41,8 +41,8 @@ note: ...so that the expression is assignable
|
LL | x
| ^
= note: expected `&'b mut (dyn Dummy + 'b)`
found `&mut (dyn Dummy + 'b)`
= note: expected `&'b mut (dyn Dummy + 'b)`
found `&mut (dyn Dummy + 'b)`
error[E0308]: mismatched types
--> $DIR/regions-trait-object-subtyping.rs:22:5

View file

@ -118,8 +118,8 @@ note: ...so that the types are compatible
|
LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `W<'l1, 'l2>`
found `W<'_, '_>`
= note: expected `W<'l1, 'l2>`
found `W<'_, '_>`
error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the enum it is implemented for does not
--> $DIR/reject-specialized-drops-8142.rs:61:14

View file

@ -0,0 +1,53 @@
use std::error::Error;
use std::fmt;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ValueRef<'a> {
Null,
Integer(i64),
Real(f64),
Text(&'a [u8]),
Blob(&'a [u8]),
}
impl<'a> ValueRef<'a> {
pub fn as_str(&self) -> FromSqlResult<&'a str, &'a &'a str> {
match *self {
ValueRef::Text(t) => {
std::str::from_utf8(t).map_err(|_| FromSqlError::InvalidType).map(|x| (x, &x))
}
_ => Err(FromSqlError::InvalidType),
}
}
}
#[derive(Debug)]
#[non_exhaustive]
pub enum FromSqlError {
InvalidType
}
impl fmt::Display for FromSqlError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "InvalidType")
}
}
impl Error for FromSqlError {}
pub type FromSqlResult<T, K> = Result<(T, K), FromSqlError>;
pub trait FromSql: Sized {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
}
impl FromSql for &str {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
//~^ ERROR `impl` item signature doesn't match `trait` item signature
value.as_str()
}
}
pub fn main() {
println!("{}", "Hello World");
}

View file

@ -0,0 +1,19 @@
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/self-without-lifetime-constraint.rs:45:5
|
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
| -------------------------------------------------------------------- expected `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), FromSqlError>`
...
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), FromSqlError>`
|
= note: expected `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), _>`
found `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), _>`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/self-without-lifetime-constraint.rs:41:60
|
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
| ^^^^ consider borrowing this type parameter in the trait
error: aborting due to previous error

View file

@ -19,8 +19,8 @@ note: ...so that the types are compatible
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
| ^^^^^^^^^^
= note: expected `T1<'a>`
found `T1<'_>`
= note: expected `T1<'a>`
found `T1<'_>`
error: aborting due to previous error

View file

@ -0,0 +1,20 @@
struct Article {
proof_reader: ProofReader,
}
struct ProofReader {
name: String,
}
pub trait HaveRelationship<To> {
fn get_relation(&self) -> To;
}
impl HaveRelationship<&ProofReader> for Article {
fn get_relation(&self) -> &ProofReader {
//~^ ERROR `impl` item signature doesn't match `trait` item signature
&self.proof_reader
}
}
fn main() {}

View file

@ -0,0 +1,19 @@
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/trait-param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/trait-param-without-lifetime-constraint.rs:10:31
|
LL | fn get_relation(&self) -> To;
| ^^ consider borrowing this type parameter in the trait
error: aborting due to previous error

View file

@ -23,8 +23,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(items.iter())
| ^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>`
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>`
error: aborting due to previous error

View file

@ -0,0 +1,67 @@
#![feature(unsafe_block_in_unsafe_fn)]
#[repr(packed)]
pub struct Packed {
data: &'static u32,
}
const PACKED: Packed = Packed { data: &0 };
#[allow(safe_packed_borrows)]
#[allow(unsafe_op_in_unsafe_fn)]
unsafe fn allow_allow() {
&PACKED.data; // allowed
}
#[allow(safe_packed_borrows)]
#[warn(unsafe_op_in_unsafe_fn)]
unsafe fn allow_warn() {
&PACKED.data; // allowed
}
#[allow(safe_packed_borrows)]
#[deny(unsafe_op_in_unsafe_fn)]
unsafe fn allow_deny() {
&PACKED.data; // allowed
}
#[warn(safe_packed_borrows)]
#[allow(unsafe_op_in_unsafe_fn)]
unsafe fn warn_allow() {
&PACKED.data; // allowed
}
#[warn(safe_packed_borrows)]
#[warn(unsafe_op_in_unsafe_fn)]
unsafe fn warn_warn() {
&PACKED.data; //~ WARN
//~| WARNING this was previously accepted by the compiler but is being phased out
}
#[warn(safe_packed_borrows)]
#[deny(unsafe_op_in_unsafe_fn)]
unsafe fn warn_deny() {
&PACKED.data; //~ WARN
//~| WARNING this was previously accepted by the compiler but is being phased out
}
#[deny(safe_packed_borrows)]
#[allow(unsafe_op_in_unsafe_fn)]
unsafe fn deny_allow() {
&PACKED.data; // allowed
}
#[deny(safe_packed_borrows)]
#[warn(unsafe_op_in_unsafe_fn)]
unsafe fn deny_warn() {
&PACKED.data; //~ WARN
}
#[deny(safe_packed_borrows)]
#[deny(unsafe_op_in_unsafe_fn)]
unsafe fn deny_deny() {
&PACKED.data; //~ ERROR
//~| WARNING this was previously accepted by the compiler but is being phased out
}
fn main() {}

View file

@ -0,0 +1,60 @@
warning: borrow of packed field is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:37:5
|
LL | &PACKED.data;
| ^^^^^^^^^^^^ borrow of packed field
|
note: the lint level is defined here
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:34:8
|
LL | #[warn(safe_packed_borrows)]
| ^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
= note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
warning: borrow of packed field is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:44:5
|
LL | &PACKED.data;
| ^^^^^^^^^^^^ borrow of packed field
|
note: the lint level is defined here
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:41:8
|
LL | #[warn(safe_packed_borrows)]
| ^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
= note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
warning: borrow of packed field is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:57:5
|
LL | &PACKED.data;
| ^^^^^^^^^^^^ borrow of packed field
|
note: the lint level is defined here
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:55:8
|
LL | #[warn(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^
= note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
error: borrow of packed field is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:63:5
|
LL | &PACKED.data;
| ^^^^^^^^^^^^ borrow of packed field
|
note: the lint level is defined here
--> $DIR/rfc-2585-safe_packed_borrows-in-unsafe-fn.rs:60:8
|
LL | #[deny(safe_packed_borrows)]
| ^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
= note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
error: aborting due to previous error; 3 warnings emitted

View file

@ -0,0 +1,76 @@
#![feature(unsafe_block_in_unsafe_fn)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(unused_unsafe)]
unsafe fn unsf() {}
const PTR: *const () = std::ptr::null();
static mut VOID: () = ();
unsafe fn deny_level() {
unsf();
//~^ ERROR call to unsafe function is unsafe and requires unsafe block
*PTR;
//~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
VOID = ();
//~^ ERROR use of mutable static is unsafe and requires unsafe block
}
// Check that `unsafe_op_in_unsafe_fn` works starting from the `warn` level.
#[warn(unsafe_op_in_unsafe_fn)]
#[deny(warnings)]
unsafe fn warning_level() {
unsf();
//~^ ERROR call to unsafe function is unsafe and requires unsafe block
*PTR;
//~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
VOID = ();
//~^ ERROR use of mutable static is unsafe and requires unsafe block
}
unsafe fn explicit_block() {
// no error
unsafe {
unsf();
*PTR;
VOID = ();
}
}
unsafe fn two_explicit_blocks() {
unsafe { unsafe { unsf() } }
//~^ ERROR unnecessary `unsafe` block
}
#[allow(unsafe_op_in_unsafe_fn)]
unsafe fn allow_level() {
// lint allowed -> no error
unsf();
*PTR;
VOID = ();
unsafe { unsf() }
//~^ ERROR unnecessary `unsafe` block
}
unsafe fn nested_allow_level() {
#[allow(unsafe_op_in_unsafe_fn)]
{
// lint allowed -> no error
unsf();
*PTR;
VOID = ();
unsafe { unsf() }
//~^ ERROR unnecessary `unsafe` block
}
}
fn main() {
unsf();
//~^ ERROR call to unsafe function is unsafe and requires unsafe block
#[allow(unsafe_op_in_unsafe_fn)]
{
unsf();
//~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
}
}

View file

@ -0,0 +1,104 @@
error: call to unsafe function is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:10:5
|
LL | unsf();
| ^^^^^^ call to unsafe function
|
note: the lint level is defined here
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:2:9
|
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^
= note: consult the function's documentation for information on how to avoid undefined behavior
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:12:5
|
LL | *PTR;
| ^^^^ dereference of raw pointer
|
= note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:14:5
|
LL | VOID = ();
| ^^^^^^^^^ use of mutable static
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
error: call to unsafe function is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:22:5
|
LL | unsf();
| ^^^^^^ call to unsafe function
|
note: the lint level is defined here
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:20:8
|
LL | #[deny(warnings)]
| ^^^^^^^^
= note: `#[deny(unsafe_op_in_unsafe_fn)]` implied by `#[deny(warnings)]`
= note: consult the function's documentation for information on how to avoid undefined behavior
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:24:5
|
LL | *PTR;
| ^^^^ dereference of raw pointer
|
= note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:26:5
|
LL | VOID = ();
| ^^^^^^^^^ use of mutable static
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
error: unnecessary `unsafe` block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:40:14
|
LL | unsafe { unsafe { unsf() } }
| ------ ^^^^^^ unnecessary `unsafe` block
| |
| because it's nested under this `unsafe` block
|
note: the lint level is defined here
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:3:9
|
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^
error: unnecessary `unsafe` block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:51:5
|
LL | unsafe { unsf() }
| ^^^^^^ unnecessary `unsafe` block
error: unnecessary `unsafe` block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:63:9
|
LL | unsafe { unsf() }
| ^^^^^^ unnecessary `unsafe` block
error[E0133]: call to unsafe function is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:69:5
|
LL | unsf();
| ^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:73:9
|
LL | unsf();
| ^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 11 previous errors
For more information about this error, try `rustc --explain E0133`.