Commit Graph

36 Commits

Author SHA1 Message Date
Irina Popa b63d7e2b1c Rename trans to codegen everywhere. 2018-05-17 15:08:30 +03:00
flip1995 121abd0599
make it compile again 2018-05-02 12:05:13 +02:00
Seiichi Uchida 9b3aea602c
Remove Option from the return type of Attribute::name() 2018-05-02 11:32:34 +02:00
Jorge Aparicio bd4ebf28bd check that #[used] is used only on statics 2018-04-30 07:43:22 +02:00
Amanieu d'Antras 5f2c111165 Allow #[inline] on closures
Fixes #49632
2018-04-27 12:34:01 +02:00
David Wood 138472bdc6
Checking location and syntax of non_exhaustive attribute. 2018-04-02 23:02:29 +01:00
matthew 4957a40d13 Add extra test for expressions and fix typo in message 2018-03-27 08:39:15 -07:00
matthew 48825bcb23 Remove an unnecessary/incorrect match in the expression check function 2018-03-26 19:41:19 -07:00
matthew 816c1b191c Check for known but incorrect attributes
- Change nested_visit_map so it will recusively check functions

- Add visit_stmt and visit_expr for impl Visitor for CheckAttrVisitor and check for incorrect
inline and repr attributes on staements and expressions

- Add regression test for isssue #43988
2018-03-26 08:43:16 -07:00
Alex Crichton d889957dab rustc: Add a `#[wasm_import_module]` attribute
This commit adds a new attribute to the Rust compiler specific to the wasm
target (and no other targets). The `#[wasm_import_module]` attribute is used to
specify the module that a name is imported from, and is used like so:

    #[wasm_import_module = "./foo.js"]
    extern {
        fn some_js_function();
    }

Here the import of the symbol `some_js_function` is tagged with the `./foo.js`
module in the wasm output file. Wasm-the-format includes two fields on all
imports, a module and a field. The field is the symbol name (`some_js_function`
above) and the module has historically unconditionally been `"env"`. I'm not
sure if this `"env"` convention has asm.js or LLVM roots, but regardless we'd
like the ability to configure it!

The proposed ES module integration with wasm (aka a wasm module is "just another
ES module") requires that the import module of wasm imports is interpreted as an
ES module import, meaning that you'll need to encode paths, NPM packages, etc.
As a result, we'll need this to be something other than `"env"`!

Unfortunately neither our version of LLVM nor LLD supports custom import modules
(aka anything not `"env"`). My hope is that by the time LLVM 7 is released both
will have support, but in the meantime this commit adds some primitive
encoding/decoding of wasm files to the compiler. This way rustc postprocesses
the wasm module that LLVM emits to ensure it's got all the imports we'd like to
have in it.

Eventually I'd ideally like to unconditionally require this attribute to be
placed on all `extern { ... }` blocks. For now though it seemed prudent to add
it as an unstable attribute, so for now it's not required (as that'd force usage
of a feature gate). Hopefully it doesn't take too long to "stabilize" this!

cc rust-lang-nursery/rust-wasm#29
2018-03-22 13:16:38 -07:00
Alex Crichton 7df6f4161c rustc: Add a `#[wasm_custom_section]` attribute
This commit is an implementation of adding custom sections to wasm artifacts in
rustc. The intention here is to expose the ability of the wasm binary format to
contain custom sections with arbitrary user-defined data. Currently neither our
version of LLVM nor LLD supports this so the implementation is currently custom
to rustc itself.

The implementation here is to attach a `#[wasm_custom_section = "foo"]`
attribute to any `const` which has a type like `[u8; N]`. Other types of
constants aren't supported yet but may be added one day! This should hopefully
be enough to get off the ground with *some* custom section support.

The current semantics are that any constant tagged with `#[wasm_custom_section]`
section will be *appended* to the corresponding section in the final output wasm
artifact (and this affects dependencies linked in as well, not just the final
crate). This means that whatever is interpreting the contents must be able to
interpret binary-concatenated sections (or each constant needs to be in its own
custom section).

To test this change the existing `run-make` test suite was moved to a
`run-make-fulldeps` folder and a new `run-make` test suite was added which
applies to all targets by default. This test suite currently only has one test
which only runs for the wasm target (using a node.js script to use `WebAssembly`
in JS to parse the wasm output).
2018-03-22 13:16:38 -07:00
Alex Crichton 4bde92c176 rustc: Fix ICE with `#[target_feature]` on module
This commit fixes an ICE in rustc when `#[target_feature]` was applied to items
other than functions due to the way the feature was validated.
2018-03-07 17:09:09 -08:00
Wesley Wiser 07890c5c59 Add target_features to TransFnAttrs
Part of #47320
2018-03-06 20:18:51 -05:00
Robin Kruppe 2be697bc21 Implement repr(transparent) 2018-01-16 08:58:32 +01:00
Alex Crichton 0ecaa67e90 rustc: Refactor attribute checking to operate on HIR
This'll enable running queries that could be cached and overall be more amenable
to the query infastructure.
2018-01-13 16:07:13 -08:00
Robin Kruppe 03936115ef Check all repr hints together when checking for mis-applied attributes
Fixes #47094

Besides fixing that bug, this change has a user-visible effect on the spans in the "incompatible repr hints" warning and another error: they now point at `foo` and/or `bar` in `repr(foo, bar)` instead of the whole attribute. This is sometimes more precise (e.g., `#[repr(C, packed)]` on an enum points at the `packed`) but sometimes not. I moved a compile-fail test to a ui test to illustrate how it now looks in the common case of only one attribute.
2018-01-01 22:05:29 +01:00
Alexis Beingessner 3d7a6fee79 Prevent repr(C, u8) from triggering a warning on non-clike enums 2017-11-20 15:18:48 -05:00
Michael Lamparski dcbedf78a0 Add context to E0084, E00517, E0518
Show both the attribute and the item
2017-11-14 08:24:28 -05:00
Cameron Hart 200c4d0410 Better detection of repr packed and align
Fixes issue #43317.
2017-07-23 17:27:13 +10:00
Cameron Hart ebc2f7d6ed Support repr alignment on unions. 2017-07-17 07:55:49 +10:00
bjorn3 e75937022e Add docs to librustc/hir/check_attr.rs 2017-06-13 18:32:39 +02:00
Oliver Schneider dd87eabd83 Remove need for &format!(...) or &&"" dances in `span_label` calls 2017-05-08 12:56:15 +02:00
Cameron Hart 4358e35fda Implementation of repr struct alignment RFC 1358.
The main changes around rustc::ty::Layout::struct and rustc_trans:adt:
* Added primitive_align field which stores alignment before repr align
* Always emit field padding when generating the LLVM struct fields
* Added methods for adjusting field indexes from the layout index to the
  LLVM struct field index

The main user of this information is rustc_trans::adt::struct_llfields
which determines the LLVM fields to be used by LLVM, including padding
fields.
2017-04-21 07:32:32 +10:00
Jeffrey Seyfried 68c1cc68b4 Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. 2017-03-14 04:03:43 +00:00
Oliver Schneider 5e51edb0de
annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor 2016-12-06 11:28:51 +01:00
Jeffrey Seyfried a2626410d7 Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s. 2016-11-20 11:46:06 +00:00
Gavin Baker cd56d47da3 E0518 Update error format #36111
- Fixes #36111
- Part of #35233
2016-09-06 00:21:04 +10:00
Gavin Baker 8bcd6a33be E0517 Update error format #36109
- Fixes #36109
- Part of #35233
2016-09-06 00:20:56 +10:00
Gavin Baker d53ea97bfc E0516 Update error format #36108
- fixes #36108
- part of #35233
2016-09-05 23:07:50 +10:00
Vadim Petrochenkov 641d8e9e4c Some better support for unions through the compiler 2016-09-03 13:39:34 +03:00
Chris Wong 42b75a5c18 Warn about multiple conflicting #[repr] hints
Closes #34622
2016-08-31 18:54:19 +12:00
Jeffrey Seyfried bfb01bbb26 Refactor away `AttrMetaMethods`. 2016-08-25 20:41:40 +00:00
Jeffrey Seyfried 4eb08bb2ab Refactor away `AttrNestedMetaItemMethods`. 2016-08-25 20:41:32 +00:00
Sergio Benitez 8250a26b5b Implement RFC#1559: allow all literals in attributes. 2016-08-25 13:25:22 -07:00
Jeffrey Seyfried 0644aba0b3 Remove the type parameter from `syntax::visit::Visitor` 2016-06-14 07:40:32 +00:00
Eduard Burtescu 8b0937293b rustc: move rustc_front to rustc::hir. 2016-04-06 09:01:55 +03:00