rust/compiler/rustc_middle/src/middle
Peter Collingbourne 5873ebeef3 Move linkage type check to HIR analysis and fix semantics issues.
This ensures that the error is printed even for unused variables,
as well as unifying the handling between the LLVM and GCC backends.

This also fixes unusual behavior around exported Rust-defined variables
with linkage attributes. With the previous behavior, it appears to be
impossible to define such a variable such that it can actually be imported
and used by another crate. This is because on the importing side, the
variable is required to be a pointer, but on the exporting side, the
type checker rejects static variables of pointer type because they do
not implement `Sync`. Even if it were possible to import such a type, it
appears that code generation on the importing side would add an unexpected
additional level of pointer indirection, which would break type safety.

This highlighted that the semantics of linkage on Rust-defined variables
is different to linkage on foreign items. As such, we now model the
difference with two different codegen attributes: linkage for Rust-defined
variables, and import_linkage for foreign items.

This change gives semantics to the test
src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was
previously expected to fail to compile. Therefore, convert it into a
test that is expected to successfully compile.

The update to the GCC backend is speculative and untested.
2022-12-05 15:05:43 -08:00
..
codegen_fn_attrs.rs Move linkage type check to HIR analysis and fix semantics issues. 2022-12-05 15:05:43 -08:00
dependency_format.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
exported_symbols.rs Synthesis object file for #[used] and exported symbols 2022-04-18 20:50:56 +01:00
lang_items.rs Add TyCtxt::is_fn_trait 2022-11-27 07:19:29 +00:00
limits.rs Bump the const eval step limit 2022-11-23 16:55:57 +00:00
mod.rs passes: check implied feature exists 2022-07-20 15:50:59 +01:00
privacy.rs effective visibility: Always add table entries for nodes used as parents 2022-11-24 01:28:41 +03:00
region.rs Replace &Vec<_>s with &[_]s 2022-06-03 20:42:42 +04:00
resolve_lifetime.rs separate definitions and HIR owners 2022-09-24 23:21:19 +09:00
stability.rs Refactor rustc lint API 2022-10-01 10:03:06 +00:00