Skip to content
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

Rollup of 10 pull requests #75383

Merged
merged 47 commits into from
Aug 11, 2020
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ef29161
make parts of rustc_typeck public
Ryan1729 Aug 3, 2020
5565c1a
run cargo dev new_lint then move transmutes_expressible_as_ptr_casts …
Ryan1729 Aug 3, 2020
0c37239
make InheritedBuilder::enter public
Ryan1729 Aug 3, 2020
b4e6e70
initial compiling version of TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS
Ryan1729 Aug 3, 2020
7061b1c
write currently failing test for transmutes_expressible_as_ptr_casts
Ryan1729 Aug 3, 2020
b4ecee9
accidentally cause an ICE by putting the TRANSMUTES_EXPRESSIBLE_AS_PT…
Ryan1729 Aug 3, 2020
1e5c14d
try putting the can_be_expressed_as_pointer_cast at the top and find …
Ryan1729 Aug 3, 2020
7a818c0
get the expected number of errors by acknowledging that other lints a…
Ryan1729 Aug 3, 2020
ab93133
address some review comments
Ryan1729 Aug 4, 2020
6fdd1db
add description to assert
Ryan1729 Aug 4, 2020
8ba4101
add documentation to functions that call `do_check` and add a test ag…
Ryan1729 Aug 6, 2020
afd4909
add extra error message to the expected stderr for transmutes_express…
Ryan1729 Aug 6, 2020
5447247
change filter to assert, and update comments
Ryan1729 Aug 6, 2020
e3170bb
add newline to transmutes_expressible_as_ptr_casts.rs
Ryan1729 Aug 6, 2020
4027f15
run ./x.py fmt
Ryan1729 Aug 6, 2020
007dc94
run clippy_dev update_lints
Ryan1729 Aug 6, 2020
32691da
run clippy_dev fmt
Ryan1729 Aug 6, 2020
d897fd2
Apply suggestions from code review
Ryan1729 Aug 6, 2020
c04c4cb
copy over *.fixed file
Ryan1729 Aug 7, 2020
48a6c21
Only add a border for the rust logo
GuillaumeGomez Aug 7, 2020
b21a3de
Don't try to use wasm intrinsics on vectors
alexcrichton Aug 9, 2020
b02bf05
update stderr for transmutes_expressible_as_ptr_casts
Ryan1729 Aug 9, 2020
0fbf450
add a test example of where transmutes_expressible_as_ptr_casts shoul…
Ryan1729 Aug 9, 2020
58b8b11
fix unary minus on usize and unused variable errors in .fixed file
Ryan1729 Aug 9, 2020
d2e7293
add allow unused_unsafe and allow dead_code
Ryan1729 Aug 9, 2020
2627eed
Avoid deleting temporary files on error
Mark-Simulacrum Aug 9, 2020
bff69c9
move const_eval error reporting logic into rustc_mir::const_eval::error
RalfJung Aug 9, 2020
fd41bde
instance: only polymorphize upvar substs
davidtwco Aug 9, 2020
a0e0575
evaluate required_consts when pushing stack frame in Miri engine
RalfJung Aug 9, 2020
1fa7203
bless MIR
RalfJung Aug 9, 2020
7dba693
Use intra-doc links
denisvasilik Aug 9, 2020
fd3851a
add test for unused erroneous const in CTFE
RalfJung Aug 10, 2020
4ed0c6a
Use existing `infcx` when emitting trait impl diagnostic
Aaron1011 Aug 10, 2020
a34bc79
Add help button
GuillaumeGomez Aug 10, 2020
d7e7271
Remove AsRef link as it is in the prelude
denisvasilik Aug 10, 2020
f260462
Remove links that are in scope
denisvasilik Aug 10, 2020
eea8581
Use intra-doc links
denisvasilik Aug 10, 2020
63d1e37
Rollup merge of #75098 - Ryan1729:clippy-pointer-cast-lint-experiment…
Dylan-DPC Aug 10, 2020
2ad7c16
Rollup merge of #75249 - GuillaumeGomez:rust-logo-border, r=Manishearth
Dylan-DPC Aug 10, 2020
992988b
Rollup merge of #75315 - Mark-Simulacrum:save-temps, r=ecstatic-morse
Dylan-DPC Aug 10, 2020
2932638
Rollup merge of #75316 - alexcrichton:fix-wasm-simd, r=oli-obk
Dylan-DPC Aug 10, 2020
1e41af3
Rollup merge of #75337 - davidtwco:polymorphization-75255-fixes, r=eddyb
Dylan-DPC Aug 10, 2020
9edec57
Rollup merge of #75339 - RalfJung:eval-required, r=oli-obk
Dylan-DPC Aug 10, 2020
dff868e
Rollup merge of #75363 - Aaron1011:fix/diag-infcx, r=lcnr
Dylan-DPC Aug 10, 2020
51ed33d
Rollup merge of #75366 - GuillaumeGomez:help-button, r=jyn514
Dylan-DPC Aug 10, 2020
d00c703
Rollup merge of #75369 - denisvasilik:intra-doc-links-core-borrow, r=…
Dylan-DPC Aug 10, 2020
0a738d4
Rollup merge of #75379 - denisvasilik:intra-docs-links-core-cmp, r=Dy…
Dylan-DPC Aug 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.fixed
Original file line number Diff line number Diff line change
@@ -15,54 +15,54 @@ fn main() {
// the casts, since the casts are the recommended fixes.

// e is an integer and U is *U_0, while U_0: Sized; addr-ptr-cast
let ptr_i32_transmute = unsafe {
-1 as *const i32
let _ptr_i32_transmute = unsafe {
usize::MAX as *const i32
};
let ptr_i32 = -1isize as *const i32;
let ptr_i32 = usize::MAX as *const i32;

// e has type *T, U is *U_0, and either U_0: Sized ...
let ptr_i8_transmute = unsafe {
let _ptr_i8_transmute = unsafe {
ptr_i32 as *const i8
};
let ptr_i8 = ptr_i32 as *const i8;
let _ptr_i8 = ptr_i32 as *const i8;

let slice_ptr = &[0,1,2,3] as *const [i32];

// ... or pointer_kind(T) = pointer_kind(U_0); ptr-ptr-cast
let ptr_to_unsized_transmute = unsafe {
let _ptr_to_unsized_transmute = unsafe {
slice_ptr as *const [u16]
};
let ptr_to_unsized = slice_ptr as *const [u16];
let _ptr_to_unsized = slice_ptr as *const [u16];
// TODO: We could try testing vtable casts here too, but maybe
// we should wait until std::raw::TraitObject is stabilized?

// e has type *T and U is a numeric type, while T: Sized; ptr-addr-cast
let usize_from_int_ptr_transmute = unsafe {
let _usize_from_int_ptr_transmute = unsafe {
ptr_i32 as usize
};
let usize_from_int_ptr = ptr_i32 as usize;
let _usize_from_int_ptr = ptr_i32 as usize;

let array_ref: &[i32; 4] = &[1,2,3,4];

// e has type &[T; n] and U is *const T; array-ptr-cast
let array_ptr_transmute = unsafe {
let _array_ptr_transmute = unsafe {
array_ref as *const [i32; 4]
};
let array_ptr = array_ref as *const [i32; 4];
let _array_ptr = array_ref as *const [i32; 4];

fn foo(_: usize) -> u8 { 42 }

// e is a function pointer type and U has type *T, while T: Sized; fptr-ptr-cast
let usize_ptr_transmute = unsafe {
let _usize_ptr_transmute = unsafe {
foo as *const usize
};
let usize_ptr_transmute = foo as *const usize;
let _usize_ptr_transmute = foo as *const usize;

// e is a function pointer type and U is an integer; fptr-addr-cast
let usize_from_fn_ptr_transmute = unsafe {
let _usize_from_fn_ptr_transmute = unsafe {
foo as usize
};
let usize_from_fn_ptr = foo as *const usize;
let _usize_from_fn_ptr = foo as *const usize;
}

// If a ref-to-ptr cast of this form where the pointer type points to a type other
30 changes: 15 additions & 15 deletions src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.rs
Original file line number Diff line number Diff line change
@@ -15,54 +15,54 @@ fn main() {
// the casts, since the casts are the recommended fixes.

// e is an integer and U is *U_0, while U_0: Sized; addr-ptr-cast
let ptr_i32_transmute = unsafe {
transmute::<isize, *const i32>(-1)
let _ptr_i32_transmute = unsafe {
transmute::<usize, *const i32>(usize::MAX)
};
let ptr_i32 = -1isize as *const i32;
let ptr_i32 = usize::MAX as *const i32;

// e has type *T, U is *U_0, and either U_0: Sized ...
let ptr_i8_transmute = unsafe {
let _ptr_i8_transmute = unsafe {
transmute::<*const i32, *const i8>(ptr_i32)
};
let ptr_i8 = ptr_i32 as *const i8;
let _ptr_i8 = ptr_i32 as *const i8;

let slice_ptr = &[0,1,2,3] as *const [i32];

// ... or pointer_kind(T) = pointer_kind(U_0); ptr-ptr-cast
let ptr_to_unsized_transmute = unsafe {
let _ptr_to_unsized_transmute = unsafe {
transmute::<*const [i32], *const [u16]>(slice_ptr)
};
let ptr_to_unsized = slice_ptr as *const [u16];
let _ptr_to_unsized = slice_ptr as *const [u16];
// TODO: We could try testing vtable casts here too, but maybe
// we should wait until std::raw::TraitObject is stabilized?

// e has type *T and U is a numeric type, while T: Sized; ptr-addr-cast
let usize_from_int_ptr_transmute = unsafe {
let _usize_from_int_ptr_transmute = unsafe {
transmute::<*const i32, usize>(ptr_i32)
};
let usize_from_int_ptr = ptr_i32 as usize;
let _usize_from_int_ptr = ptr_i32 as usize;

let array_ref: &[i32; 4] = &[1,2,3,4];

// e has type &[T; n] and U is *const T; array-ptr-cast
let array_ptr_transmute = unsafe {
let _array_ptr_transmute = unsafe {
transmute::<&[i32; 4], *const [i32; 4]>(array_ref)
};
let array_ptr = array_ref as *const [i32; 4];
let _array_ptr = array_ref as *const [i32; 4];

fn foo(_: usize) -> u8 { 42 }

// e is a function pointer type and U has type *T, while T: Sized; fptr-ptr-cast
let usize_ptr_transmute = unsafe {
let _usize_ptr_transmute = unsafe {
transmute::<fn(usize) -> u8, *const usize>(foo)
};
let usize_ptr_transmute = foo as *const usize;
let _usize_ptr_transmute = foo as *const usize;

// e is a function pointer type and U is an integer; fptr-addr-cast
let usize_from_fn_ptr_transmute = unsafe {
let _usize_from_fn_ptr_transmute = unsafe {
transmute::<fn(usize) -> u8, usize>(foo)
};
let usize_from_fn_ptr = foo as *const usize;
let _usize_from_fn_ptr = foo as *const usize;
}

// If a ref-to-ptr cast of this form where the pointer type points to a type other
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: transmute from an integer to a pointer
--> $DIR/transmutes_expressible_as_ptr_casts.rs:19:9
|
LL | transmute::<isize, *const i32>(-1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-1 as *const i32`
LL | transmute::<usize, *const i32>(usize::MAX)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::MAX as *const i32`
|
= note: `-D clippy::useless-transmute` implied by `-D warnings`