Duplicated items cause lots of confusing knock down errors. This change side-steps some known ICEs, and reduces the verbosity of crates with duplicated types at the cost of not emitting every error that we could.
Update tests that no longer crash:
120873 -> `tests/ui/resolve/multiple_definitions_attribute_merging.rs`
(already existing)
123690 -> `tests/ui/resolve/duplicated-enum-variant.rs`
155482 -> `tests/ui/resolve/duplicated-item-in-const-generics.rs`
Added two cases from the report that still ICE.
turn aligned-in-packed error into lint
Fixes https://github.com/rust-lang/rust/issues/80926:
The aligned-in-packed check ignores the fact that generics exist, so it can trivially be bypassed. Acknowledge that by downgrading the hard error to a lint. The lint also only fires for `repr(C)` types, because that's the only case where that is a problem: the type may not actually match what the C compiler for the target does, if that C compiler is MSVC. This is tied up with https://github.com/rust-lang/rfcs/pull/3845 and the general tension around `repr(C)` as a repr for predictable stable layout vs C compatibility. The error doesn't really help to make fixing the mess any easier though, so let's de-fang it.
Also fixes https://github.com/rust-lang/rfcs/issues/3060; see that issue for a usecase that's made unnecessarily hard by the status quo.
[Three years ago](https://github.com/rust-lang/rust/issues/80926#issuecomment-1716238277), the t-lang vibes seem to have been "yes let's downgrade this to a lint, that's kind of what it already is anyway".
Questions for t-lang:
- Are you still on-board with this?
- How should the lint be called? I went with `aligned_fields_in_packed`.
- When exactly should it fire? I currently require the outer packed type, the inner aligned type, and all the types in between to be `repr(C)`. For Rust types I see no reason at all to forbid this combination, we can just define whatever we want for the layout there and IMO the current behavior makes a lot of sense.
- What should the default lint level be? I went with "deny" since it was a hard error after all.
Cc @rust-lang/opsem
The reason `rustc_ast_ir` and `rustc_pattern_analysis` have nested
`cfg_attr`s is so that they don't mention `cfg(bootstrap)` when nightly
or rustc cargo feature turned on. If you don't do it like that, they stop
compiling on stable (or rather, they emit unexpected cfg warnings...).
also removes E0452 and splits
`tests/rustdoc-ui/lints/renamed-lint-still-applies` into 2 tests
this is because of delayed warn lint being lost on compiler aborting on
error
Cleanup of attribute parsing errors
Removes the specific `UnknownMetaItem` and `IllFormedAttributeInputLint` errors.
Note that `IllFormedAttributeInputLint` is not a lint, contrary to its name
r? ``````@jdonszelmann``````
Externally implementable items
Supersedes https://github.com/rust-lang/rust/pull/140010
Tracking issue: https://github.com/rust-lang/rust/issues/125418
Getting started:
```rust
#![feature(eii)]
#[eii(eii1)]
pub fn decl1(x: u64)
// body optional (it's the default)
{
println!("default {x}");
}
// in another crate, maybe
#[eii1]
pub fn decl2(x: u64) {
println!("explicit {x}");
}
fn main() {
decl1(4);
}
```
- tiny perf regression, underlying issue makes multiple things in the compiler slow, not just EII, planning to solve those separately.
- No codegen_gcc support, they don't have bindings for weak symbols yet but could
- No windows support yet for weak definitions
This PR merges the implementation of EII for just llvm + not windows, doesn't yet contain like a new panic handler implementation or alloc handler. With this implementation, it would support implementing the panic handler in terms of EII already since it requires no default implementation so no weak symbols
The PR has been open in various forms for about a year now, but I feel that having some implementation merged to build upon
remove duplicated columns from `rustc_error_code::error_codes!`
Possible because of rust-lang/rust#146308 ~~, but currently still blocked on the next stage0 bump~~.