| Age | Commit message (Collapse) | Author | Lines | |
|---|---|---|---|---|
| 2020-05-29 | Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, ↵ | Ralf Jung | -0/+3 | |
| r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: #71668 r? @RalfJung cc @nikomatsakis | ||||
| 2020-05-29 | Whitelist #[allow_internal_unstable] | Jonas Schievink | -1/+1 | |
| This should hopefully work around https://github.com/rust-lang/rust/issues/65023, which currently makes almost every bootstrap fail for me. | ||||
| 2020-05-27 | Implement RFC 2585 | LeSeulArtichaut | -0/+3 | |
| 2020-05-20 | Implement `#[ffi_const]` and `#[ffi_pure]` function attributes | Matthias Schiffer | -0/+8 | |
| Introduce function attribute corresponding to the `const`/`pure` attributes supported by GCC, clang and other compilers. Based on the work of gnzlbg <gonzalobg88@gmail.com>. | ||||
| 2020-05-19 | Auto merge of #69171 - Amanieu:new-asm, r=nagisa,nikomatsakis | bors | -0/+1 | |
| Implement new asm! syntax from RFC 2850 This PR implements the new `asm!` syntax proposed in https://github.com/rust-lang/rfcs/pull/2850. # Design A large part of this PR revolves around taking an `asm!` macro invocation and plumbing it through all of the compiler layers down to LLVM codegen. Throughout the various stages, an `InlineAsm` generally consists of 3 components: - The template string, which is stored as an array of `InlineAsmTemplatePiece`. Each piece represents either a literal or a placeholder for an operand (just like format strings). ```rust pub enum InlineAsmTemplatePiece { String(String), Placeholder { operand_idx: usize, modifier: Option<char>, span: Span }, } ``` - The list of operands to the `asm!` (`in`, `[late]out`, `in[late]out`, `sym`, `const`). These are represented differently at each stage of lowering, but follow a common pattern: - `in`, `out` and `inout` all have an associated register class (`reg`) or explicit register (`"eax"`). - `inout` has 2 forms: one with a single expression that is both read from and written to, and one with two separate expressions for the input and output parts. - `out` and `inout` have a `late` flag (`lateout` / `inlateout`) to indicate that the register allocator is allowed to reuse an input register for this output. - `out` and the split variant of `inout` allow `_` to be specified for an output, which means that the output is discarded. This is used to allocate scratch registers for assembly code. - `sym` is a bit special since it only accepts a path expression, which must point to a `static` or a `fn`. - The options set at the end of the `asm!` macro. The only one that is particularly of interest to rustc is `NORETURN` which makes `asm!` return `!` instead of `()`. ```rust bitflags::bitflags! { pub struct InlineAsmOptions: u8 { const PURE = 1 << 0; const NOMEM = 1 << 1; const READONLY = 1 << 2; const PRESERVES_FLAGS = 1 << 3; const NORETURN = 1 << 4; const NOSTACK = 1 << 5; } } ``` ## AST `InlineAsm` is represented as an expression in the AST: ```rust pub struct InlineAsm { pub template: Vec<InlineAsmTemplatePiece>, pub operands: Vec<(InlineAsmOperand, Span)>, pub options: InlineAsmOptions, } pub enum InlineAsmRegOrRegClass { Reg(Symbol), RegClass(Symbol), } pub enum InlineAsmOperand { In { reg: InlineAsmRegOrRegClass, expr: P<Expr>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<P<Expr>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: P<Expr>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: P<Expr>, out_expr: Option<P<Expr>>, }, Const { expr: P<Expr>, }, Sym { expr: P<Expr>, }, } ``` The `asm!` macro is implemented in librustc_builtin_macros and outputs an `InlineAsm` AST node. The template string is parsed using libfmt_macros, positional and named operands are resolved to explicit operand indicies. Since target information is not available to macro invocations, validation of the registers and register classes is deferred to AST lowering. ## HIR `InlineAsm` is represented as an expression in the HIR: ```rust pub struct InlineAsm<'hir> { pub template: &'hir [InlineAsmTemplatePiece], pub operands: &'hir [InlineAsmOperand<'hir>], pub options: InlineAsmOptions, } pub enum InlineAsmRegOrRegClass { Reg(InlineAsmReg), RegClass(InlineAsmRegClass), } pub enum InlineAsmOperand<'hir> { In { reg: InlineAsmRegOrRegClass, expr: Expr<'hir>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<Expr<'hir>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: Expr<'hir>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: Expr<'hir>, out_expr: Option<Expr<'hir>>, }, Const { expr: Expr<'hir>, }, Sym { expr: Expr<'hir>, }, } ``` AST lowering is where `InlineAsmRegOrRegClass` is converted from `Symbol`s to an actual register or register class. If any modifiers are specified for a template string placeholder, these are validated against the set allowed for that operand type. Finally, explicit registers for inputs and outputs are checked for conflicts (same register used for different operands). ## Type checking Each register class has a whitelist of types that it may be used with. After the types of all operands have been determined, the `intrinsicck` pass will check that these types are in the whitelist. It also checks that split `inout` operands have compatible types and that `const` operands are integers or floats. Suggestions are emitted where needed if a template modifier should be used for an operand based on the type that was passed into it. ## HAIR `InlineAsm` is represented as an expression in the HAIR: ```rust crate enum ExprKind<'tcx> { // [..] InlineAsm { template: &'tcx [InlineAsmTemplatePiece], operands: Vec<InlineAsmOperand<'tcx>>, options: InlineAsmOptions, }, } crate enum InlineAsmOperand<'tcx> { In { reg: InlineAsmRegOrRegClass, expr: ExprRef<'tcx>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<ExprRef<'tcx>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: ExprRef<'tcx>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: ExprRef<'tcx>, out_expr: Option<ExprRef<'tcx>>, }, Const { expr: ExprRef<'tcx>, }, SymFn { expr: ExprRef<'tcx>, }, SymStatic { expr: ExprRef<'tcx>, }, } ``` The only significant change compared to HIR is that `Sym` has been lowered to either a `SymFn` whose `expr` is a `Literal` ZST of the `fn`, or a `SymStatic` whose `expr` is a `StaticRef`. ## MIR `InlineAsm` is represented as a `Terminator` in the MIR: ```rust pub enum TerminatorKind<'tcx> { // [..] /// Block ends with an inline assembly block. This is a terminator since /// inline assembly is allowed to diverge. InlineAsm { /// The template for the inline assembly, with placeholders. template: &'tcx [InlineAsmTemplatePiece], /// The operands for the inline assembly, as `Operand`s or `Place`s. operands: Vec<InlineAsmOperand<'tcx>>, /// Miscellaneous options for the inline assembly. options: InlineAsmOptions, /// Destination block after the inline assembly returns, unless it is /// diverging (InlineAsmOptions::NORETURN). destination: Option<BasicBlock>, }, } pub enum InlineAsmOperand<'tcx> { In { reg: InlineAsmRegOrRegClass, value: Operand<'tcx>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, place: Option<Place<'tcx>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, in_value: Operand<'tcx>, out_place: Option<Place<'tcx>>, }, Const { value: Operand<'tcx>, }, SymFn { value: Box<Constant<'tcx>>, }, SymStatic { value: Box<Constant<'tcx>>, }, } ``` As part of HAIR lowering, `InOut` and `SplitInOut` operands are lowered to a split form with a separate `in_value` and `out_place`. Semantically, the `InlineAsm` terminator is similar to the `Call` terminator except that it has multiple output places where a `Call` only has a single return place output. The constant promotion pass is used to ensure that `const` operands are actually constants (using the same logic as `#[rustc_args_required_const]`). ## Codegen Operands are lowered one more time before being passed to LLVM codegen: ```rust pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> { In { reg: InlineAsmRegOrRegClass, value: OperandRef<'tcx, B::Value>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, place: Option<PlaceRef<'tcx, B::Value>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, in_value: OperandRef<'tcx, B::Value>, out_place: Option<PlaceRef<'tcx, B::Value>>, }, Const { string: String, }, SymFn { instance: Instance<'tcx>, }, SymStatic { def_id: DefId, }, } ``` The operands are lowered to LLVM operands and constraint codes as follow: - `out` and the output part of `inout` operands are added first, as required by LLVM. Late output operands have a `=` prefix added to their constraint code, non-late output operands have a `=&` prefix added to their constraint code. - `in` operands are added normally. - `inout` operands are tied to the matching output operand. - `sym` operands are passed as function pointers or pointers, using the `"s"` constraint. - `const` operands are formatted to a string and directly inserted in the template string. The template string is converted to LLVM form: - `$` characters are escaped as `$$`. - `const` operands are converted to strings and inserted directly. - Placeholders are formatted as `${X:M}` where `X` is the operand index and `M` is the modifier character. Modifiers are converted from the Rust form to the LLVM form. The various options are converted to clobber constraints or LLVM attributes, refer to the [RFC](https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md#mapping-to-llvm-ir) for more details. Note that LLVM is sometimes rather picky about what types it accepts for certain constraint codes so we sometimes need to insert conversions to/from a supported type. See the target-specific ISelLowering.cpp files in LLVM for details. # Adding support for new architectures Adding inline assembly support to an architecture is mostly a matter of defining the registers and register classes for that architecture. All the definitions for register classes are located in `src/librustc_target/asm/`. Additionally you will need to implement lowering of these register classes to LLVM constraint codes in `src/librustc_codegen_llvm/asm.rs`. | ||||
| 2020-05-18 | Minor fixes | Amanieu d'Antras | -1/+1 | |
| 2020-05-18 | Add RISC-V target features | Amanieu d'Antras | -0/+1 | |
| 2020-05-03 | Stabilize fn-like proc macros in expression, pattern and statement positions | Vadim Petrochenkov | -2/+1 | |
| 2020-05-03 | Implement RFC 2523, `#[cfg(version(..))]` | mibac138 | -0/+4 | |
| 2020-05-01 | Allow `#[target_feature]` on safe functions | LeSeulArtichaut | -0/+3 | |
| 2020-03-29 | #[link]: mention wasm_import_module instead of cfg | Jonas Schievink | -1/+1 | |
| 2020-03-29 | Auto merge of #70370 - petrochenkov:nosmatch, r=Centril | bors | -5/+2 | |
| Remove attribute `#[structural_match]` and any references to it A small remaining part of https://github.com/rust-lang/rust/issues/63438. | ||||
| 2020-03-26 | bump negative impls version to 1.44.0 | Niko Matsakis | -1/+1 | |
| 2020-03-26 | create a tracking issue and link to it | Niko Matsakis | -3/+3 | |
| 2020-03-26 | introduce `negative_impls` feature gate and document | Niko Matsakis | -0/+3 | |
| They used to be covered by `optin_builtin_traits` but negative impls are now applicable to all traits, not just auto traits. This also adds docs in the unstable book for the current state of auto traits. | ||||
| 2020-03-24 | Remove attribute `#[structural_match]` and any references to it | Vadim Petrochenkov | -5/+2 | |
| 2020-03-22 | remove redundant closures (clippy::redundant_closure) | Matthias Krüger | -1/+1 | |
| 2020-03-17 | Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasper | Mazdak Farrokhzad | -7/+1 | |
| expand: Implement something similar to `#[cfg(accessible(path))]` cc https://github.com/rust-lang/rust/issues/64797 The feature is implemented as a `#[cfg_accessible(path)]` attribute macro rather than as `#[cfg(accessible(path))]` because it needs to wait until `path` becomes resolvable, and `cfg` cannot wait, but macros can wait. Later we can think about desugaring or not desugaring `#[cfg(accessible(path))]` into `#[cfg_accessible(path)]`. This implementation is also incomplete in the sense that it never returns "false" from `cfg_accessible(path)`, it requires some tweaks to resolve, which is not quite ready to answer queries like this during early resolution. However, the most important part of this PR is not `cfg_accessible` itself, but expansion infrastructure for retrying expansions. Before this PR we could say "we cannot resolve this macro path, let's try it later", with this PR we can say "we cannot expand this macro, let's try it later" as well. This is a pre-requisite for - turning `#[derive(...)]` into a regular attribute macro, - properly supporting eager expansion for macros that cannot yet be resolved like ``` fn main() { println!(not_available_yet!()); } macro_rules! make_available { () => { #[macro_export] macro_rules! not_available_yet { () => { "Hello world!" } }} } make_available!(); ``` | ||||
| 2020-03-15 | Add attributes to allow specializing on traits | Matthew Jasper | -0/+8 | |
| 2020-03-15 | Add `min_specialization` feature | Matthew Jasper | -0/+5 | |
| Currently the only difference between it and `specialization` is that it only allows specializing functions. | ||||
| 2020-03-10 | Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnison | Mazdak Farrokhzad | -3/+0 | |
| Remove spotlight I had a few comments saying that this feature was at best misunderstood or not even used so I decided to organize a poll about on [twitter](https://twitter.com/imperioworld_/status/1232769353503956994). After 87 votes, the result is very clear: it's not useful. Considering the amount of code we have just to run it, I think it's definitely worth it to remove it. r? @kinnison cc @ollie27 | ||||
| 2020-03-09 | expand/builtin_macros: Minor cleanup | Vadim Petrochenkov | -7/+1 | |
| 2020-03-08 | Rollup merge of #69561 - JohnTitor:clean-up-unstable-book, r=Mark-Simulacrum | Mazdak Farrokhzad | -3/+3 | |
| Clean up unstable book - #58402's feature was renamed to `tidy_test_never_used_anywhere_else` and it is now used for tidy only - `read_initializer` link is wrong and the doc should be auto-generated so removed - Add dummy doc for `link_cfg` - Stop generating `compiler_builtins_lib` doc in favor of b8ccc0f8a60ac16fdc00f4b2e36e1a5db8b78295 - Make `rustc_attrs` tracking issue "None" | ||||
| 2020-03-07 | Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkov | Mazdak Farrokhzad | -2/+2 | |
| fix various typos | ||||
| 2020-03-07 | Rollup merge of #69667 - JohnTitor:no-debug, r=nikomatsakis | Mazdak Farrokhzad | -13/+2 | |
| Remove the `no_debug` feature Context: https://github.com/rust-lang/rust/issues/29721#issuecomment-367642779 r? @nikomatsakis | ||||
| 2020-03-06 | fix various typos | Matthias Krüger | -2/+2 | |
| 2020-03-05 | Bumped version number for const_eval_limit in active.rs | Christoph Schmidler | -3/+3 | |
| and renamed 'recursion_limit' in limits.rs to simple 'limit' because it does handle other limits too. | ||||
| 2020-03-05 | Add a new test to reach const_limit setting, although with wrong WARNINGs yet | Christoph Schmidler | -3/+3 | |
| rename feature to const_eval_limit | ||||
| 2020-03-05 | Prepare const_limit feature gate and attribute | Christoph Schmidler | -0/+7 | |
| 2020-03-03 | Remove the `no_debug` feature | Yuki Okushi | -13/+2 | |
| 2020-03-01 | Make `rustc_attrs` tracking issue None | Yuki Okushi | -3/+3 | |
| 2020-02-27 | Remove "important traits" feature | Guillaume Gomez | -3/+0 | |
| 2020-02-27 | Revert "Mark attributes consumed by `check_mod_attrs` as normal" | Tomasz Miąsko | -6/+6 | |
| This reverts commit d78b22f35ec367368643fe7d6f7e87d01762692b. Those changes were incompatible with incremental compilation since the effect `check_mod_attrs` has with respect to marking the attributes as used is neither persisted nor recomputed. | ||||
| 2020-02-23 | Mark attributes consumed by `check_mod_attrs` as normal | Tomasz Miąsko | -6/+6 | |
| Take advantage of the fact that `check_mod_attrs` marks attributes as used and change their type to normal, so that any remaining uses will be warned about by the unused attribute lint. | ||||
| 2020-02-10 | Add `#[repr(no_niche)]`. | Felix S. Klock II | -0/+4 | |
| This repr-hint makes a struct/enum hide any niche within from its surrounding type-construction context. It is meant (at least initially) as an implementation detail for resolving issue 68303. We will not stabilize the repr-hint unless someone finds motivation for doing so. (So, declaration of `no_niche` feature lives in section of file where other internal implementation details are grouped, and deliberately leaves out the tracking issue number.) incorporated review feedback, and fixed post-rebase. | ||||
| 2020-02-09 | Auto merge of #68376 - Centril:move-ref-patterns, r=matthewjasper | bors | -0/+4 | |
| Initial implementation of `#![feature(move_ref_pattern)]` Following up on #45600, under the gate `#![feature(move_ref_pattern)]`, `(ref x, mut y)` is allowed subject to restrictions necessary for soundness. The match checking implementation and tests for `#![feature(bindings_after_at)]` is also adjusted as necessary. Closes #45600. Tracking issue: #68354. r? @matthewjasper | ||||
| 2020-02-05 | Selectively disable sanitizer instrumentation | Tomasz Miąsko | -0/+8 | |
| Add `no_sanitize` attribute that allows to opt out from sanitizer instrumentation in an annotated function. | ||||
| 2020-02-04 | Remove the `overlapping_marker_traits` feature | Aaron Hill | -4/+3 | |
| See #29864 This has been replaced by `#[feature(marker_trait_attr)]` A few notes: * Due to PR #68057 not yet being in the bootstrap compiler, it's necessary to continue using `#![feature(overlapping_marker_traits)]` under `#[cfg(bootstrap)]` to work around type inference issues. * I've updated tests that used `overlapping_marker_traits` to now use `marker_trait_attr` where applicable The test `src/test/ui/overlap-marker-trait.rs` doesn't make any sense now that `overlapping_marker_traits`, so I removed it. The test `src/test/ui/traits/overlap-permitted-for-marker-traits-neg.rs` now fails, since it's no longer possible to have multiple overlapping negative impls of `Send`. I believe that this is the behavior we want (assuming that `Send` is not going to become a `#[marker]` trait, so I renamed the test to `overlap-permitted-for-marker-traits-neg` | ||||
| 2020-02-02 | introduce `#![feature(move_ref_pattern)]` | Mazdak Farrokhzad | -0/+4 | |
| 2020-02-01 | Remove or_patterns from INCOMPLETE_FEATURES | Matthew Jasper | -1/+0 | |
| 2020-01-20 | stabilize transparent_enums | Mazdak Farrokhzad | -3/+2 | |
| 2020-01-18 | stabilize slice_patterns | Mazdak Farrokhzad | -3/+2 | |
| 2020-01-16 | Fix issue number of `repr128` | Yuki Okushi | -1/+1 | |
| 2020-01-16 | Fix issue number of `member_constraints` | Yuki Okushi | -1/+1 | |
| 2020-01-13 | Fix crate paths in comments | Yuki Okushi | -1/+2 | |
| 2020-01-10 | Auto merge of #65241 - tmiasko:no-std-san, r=alexcrichton | bors | -8/+2 | |
| build-std compatible sanitizer support ### Motivation When using `-Z sanitizer=*` feature it is essential that both user code and standard library is instrumented. Otherwise the utility of sanitizer will be limited, or its use will be impractical like in the case of memory sanitizer. The recently introduced cargo feature build-std makes it possible to rebuild standard library with arbitrary rustc flags. Unfortunately, those changes alone do not make it easy to rebuild standard library with sanitizers, since runtimes are dependencies of std that have to be build in specific environment, generally not available outside rustbuild process. Additionally rebuilding them requires presence of llvm-config and compiler-rt sources. The goal of changes proposed here is to make it possible to avoid rebuilding sanitizer runtimes when rebuilding the std, thus making it possible to instrument standard library for use with sanitizer with simple, although verbose command: ``` env CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-Zsanitizer=thread cargo test -Zbuild-std --target x86_64-unknown-linux-gnu ``` ### Implementation * Sanitizer runtimes are no long packed into crates. Instead, libraries build from compiler-rt are used as is, after renaming them into `librusc_rt.*`. * rustc obtains runtimes from target libdir for default sysroot, so that they are not required in custom build sysroots created with build-std. * The runtimes are only linked-in into executables to address issue #64629. (in previous design it was hard to avoid linking runtimes into static libraries produced by rustc as demonstrated by sanitizer-staticlib-link test, which still passes despite changes made in #64780). cc @kennytm, @japaric, @firstyear, @choller | ||||
| 2020-01-10 | Introduce `#![feature(half_open_range_patterns)]`. | Mazdak Farrokhzad | -0/+3 | |
| This feature adds `X..`, `..X`, and `..=X` patterns. | ||||
| 2020-01-09 | Add `const_trait_bound_opt_out` feature gate | Dylan MacKenzie | -0/+4 | |
| 2020-01-09 | Add `const_trait_impl` feature gate | Dylan MacKenzie | -0/+4 | |
| 2020-01-09 | Remove sanitizer_runtime attribute | Tomasz Miąsko | -8/+2 | |
