rust/compiler/rustc_middle/src
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
..
dep_graph Allow query system to recover a HirId. 2022-10-01 15:58:42 +02:00
hir Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillot 2022-12-03 17:37:41 +01:00
infer Add an optional Span to BrAnon and use it to print better error for HRTB error from generator interior 2022-11-07 17:39:29 -05:00
middle Move linkage type check to HIR analysis and fix semantics issues. 2022-12-05 15:05:43 -08:00
mir Use zero based indexing for pass_count 2022-12-02 15:55:24 +00:00
query Fill in def_span when creating def ids. 2022-12-01 10:33:28 +00:00
thir Use boxed slices in PatKind. 2022-09-02 07:26:22 +10:00
traits Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
ty Fill in def_span when creating def ids. 2022-12-01 10:33:28 +00:00
util span: move MultiSpan 2022-04-05 07:01:00 +01:00
arena.rs Cache Predicates' hash within themselves 2022-11-25 16:25:28 +00:00
error.rs Match crate and slug names 2022-11-21 15:24:50 +01:00
lib.rs Only allow feeding a value to newly created definitions. 2022-11-29 18:43:00 +00:00
lint.rs fix: typo 2022-11-06 11:22:29 -05:00
macros.rs add inline to TrivialTypeTraversalImpls 2022-10-17 10:54:03 +02:00
metadata.rs rustc: Parameterize ty::Visibility over used ID 2022-09-07 13:35:41 +04:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Unreserve braced enum variants in value namespace 2022-11-21 22:40:06 +03:00
values.rs Properly synthesize fn sig value during cycle 2022-12-01 23:56:57 -05:00