Rollup merge of #121025 - oli-obk:taint_after_errors, r=petrochenkov
add known-bug tests for derive failure to detect packed repr We only taint if it was a normal item. Modules and imports are untouched. Tainting them needs to be done differently, and it's unclear if that would be useful or desirable. If we just taint them into `Res::Err`, we end up losing some duplicate name messages *in the presence of other resolution errors*. r? `@petrochenkov`
This commit is contained in:
commit
075f1c34d4
27
tests/ui/resolve/auxiliary/proc_macro_generate_packed.rs
Normal file
27
tests/ui/resolve/auxiliary/proc_macro_generate_packed.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//@ force-host
|
||||||
|
//@ no-prefer-dynamic
|
||||||
|
//@ compile-flags: --crate-type proc-macro
|
||||||
|
|
||||||
|
extern crate proc_macro;
|
||||||
|
|
||||||
|
use proc_macro::*;
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn proc_macro_attribute_that_generates_repr_packed(
|
||||||
|
_attr: TokenStream,
|
||||||
|
item: TokenStream,
|
||||||
|
) -> TokenStream {
|
||||||
|
let repr = vec![TokenTree::Ident(Ident::new("packed", Span::call_site()))].into_iter();
|
||||||
|
let attr = vec![
|
||||||
|
TokenTree::Ident(Ident::new("repr", Span::call_site())),
|
||||||
|
TokenTree::Group(Group::new(Delimiter::Parenthesis, repr.collect())),
|
||||||
|
]
|
||||||
|
.into_iter();
|
||||||
|
vec![
|
||||||
|
TokenTree::Punct(Punct::new('#', Spacing::Alone)),
|
||||||
|
TokenTree::Group(Group::new(Delimiter::Bracket, attr.collect())),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.chain(item)
|
||||||
|
.collect()
|
||||||
|
}
|
19
tests/ui/resolve/multiple_definitions_attribute_merging.rs
Normal file
19
tests/ui/resolve/multiple_definitions_attribute_merging.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
//! This test ICEs because the `repr(packed)` attributes
|
||||||
|
//! end up on the `Dealigned` struct's attribute list, but the
|
||||||
|
//! derive didn't see that.
|
||||||
|
|
||||||
|
//@known-bug: #120873
|
||||||
|
//@ failure-status: 101
|
||||||
|
//@ normalize-stderr-test "note: .*\n\n" -> ""
|
||||||
|
//@ normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
||||||
|
//@ normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
|
||||||
|
//@ rustc-env:RUST_BACKTRACE=0
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
struct Dealigned<T>(u8, T);
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
|
#[repr(C)]
|
||||||
|
struct Dealigned<T>(u8, T);
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,26 @@
|
|||||||
|
error[E0428]: the name `Dealigned` is defined multiple times
|
||||||
|
--> $DIR/multiple_definitions_attribute_merging.rs:17:1
|
||||||
|
|
|
||||||
|
LL | struct Dealigned<T>(u8, T);
|
||||||
|
| --------------------------- previous definition of the type `Dealigned` here
|
||||||
|
...
|
||||||
|
LL | struct Dealigned<T>(u8, T);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Dealigned` redefined here
|
||||||
|
|
|
||||||
|
= error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:LL:CC: builtin derive created an unaligned reference
|
||||||
|
--> $DIR/multiple_definitions_attribute_merging.rs:17:25
|
||||||
|
|
|
||||||
|
LL | #[derive(PartialEq)]
|
||||||
|
| --------- in this derive macro expansion
|
||||||
|
LL | #[repr(C)]
|
||||||
|
LL | struct Dealigned<T>(u8, T);
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= Box<dyn Any>
|
||||||
|
query stack during panic:
|
||||||
|
#0 [mir_const] preparing `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq` for borrow checking
|
||||||
|
#1 [mir_promoted] promoting constants in MIR for `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq`
|
||||||
|
end of query stack
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0428`.
|
20
tests/ui/resolve/proc_macro_generated_packed.rs
Normal file
20
tests/ui/resolve/proc_macro_generated_packed.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//! This test ICEs because the `repr(packed)` attribute
|
||||||
|
//! was generated by a proc macro, so `#[derive]` didn't see it.
|
||||||
|
|
||||||
|
//@aux-build: proc_macro_generate_packed.rs
|
||||||
|
//@known-bug: #120873
|
||||||
|
//@ failure-status: 101
|
||||||
|
//@ normalize-stderr-test "note: .*\n\n" -> ""
|
||||||
|
//@ normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
||||||
|
//@ normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
|
||||||
|
//@ rustc-env:RUST_BACKTRACE=0
|
||||||
|
|
||||||
|
extern crate proc_macro_generate_packed;
|
||||||
|
use proc_macro_generate_packed::proc_macro_attribute_that_generates_repr_packed;
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
|
#[repr(C)]
|
||||||
|
#[proc_macro_attribute_that_generates_repr_packed]
|
||||||
|
struct Dealigned<T>(u8, T);
|
||||||
|
|
||||||
|
fn main() {}
|
16
tests/ui/resolve/proc_macro_generated_packed.stderr
Normal file
16
tests/ui/resolve/proc_macro_generated_packed.stderr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:LL:CC: builtin derive created an unaligned reference
|
||||||
|
--> $DIR/proc_macro_generated_packed.rs:18:25
|
||||||
|
|
|
||||||
|
LL | #[derive(PartialEq)]
|
||||||
|
| --------- in this derive macro expansion
|
||||||
|
...
|
||||||
|
LL | struct Dealigned<T>(u8, T);
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= Box<dyn Any>
|
||||||
|
query stack during panic:
|
||||||
|
#0 [mir_const] preparing `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq` for borrow checking
|
||||||
|
#1 [mir_promoted] promoting constants in MIR for `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq`
|
||||||
|
end of query stack
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user