Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions clippy_lints/src/transmute/missing_transmute_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ pub(super) fn check<'tcx>(
expr_hir_id: HirId,
) -> bool {
let last = path.segments.last().unwrap();
if last.ident.span.in_external_macro(cx.tcx.sess.source_map()) {
// If it comes from a non-local macro, we ignore it.
if last.ident.span.from_expansion() {
return false;
}
let args = last.args;
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/missing_transmute_annotations.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ extern crate macro_rules;

macro_rules! local_bad_transmute {
($e:expr) => {
std::mem::transmute::<[u16; 2], i32>($e)
//~^ missing_transmute_annotations
// Should not warn!
std::mem::transmute($e)
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/missing_transmute_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ extern crate macro_rules;

macro_rules! local_bad_transmute {
($e:expr) => {
// Should not warn!
std::mem::transmute($e)
//~^ missing_transmute_annotations
};
}

Expand Down
13 changes: 1 addition & 12 deletions tests/ui/missing_transmute_annotations.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ error: transmute used without annotations
LL | bar(std::mem::transmute::<[u16; 2], _>([1u16, 2u16]));
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`

error: transmute used without annotations
--> tests/ui/missing_transmute_annotations.rs:11:19
|
LL | std::mem::transmute($e)
| ^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
...
LL | i = local_bad_transmute!([1u16, 2u16]);
| ---------------------------------- in this macro invocation
|
= note: this error originates in the macro `local_bad_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)

error: transmute used without annotations
--> tests/ui/missing_transmute_annotations.rs:57:23
|
Expand Down Expand Up @@ -78,5 +67,5 @@ error: transmute used without annotations
LL | let x: _ = std::mem::transmute::<_, i32>([1u16, 2u16]);
| ^^^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`

error: aborting due to 12 previous errors
error: aborting due to 11 previous errors