about summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
2024-07-25Rollup merge of #127528 - estebank:ascii-control-chars, r=oli-obkMatthias Krüger-160/+42
Replace ASCII control chars with Unicode Control Pictures Replace ASCII control chars like `CR` with Unicode Control Pictures like `␍`: ``` error: bare CR not allowed in doc-comment --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32 | LL | /// doc comment with bare CR: '␍' | ^ ``` Centralize the checking of unicode char width for the purposes of CLI display in one place. Account for the new replacements. Remove unneeded tracking of "zero-width" unicode chars, as we calculate these in the `SourceMap` as needed now.
2024-07-22Rollup merge of #127506 - liushuyu:s390x-target-features, r=davidtwcoTrevor Gross-0/+1
rustc_target: add known safe s390x target features This pull request adds known safe target features for s390x (aka IBM Z systems). Currently, these features are unstable since stabilizing the target features requires submitting proposals. The `vector` feature was added in IBM Z13 (`arch11`), and this is a SIMD feature for the newer IBM Z systems. The `backchain` attribute is the IBM Z way of adding frame pointers like unwinding capabilities (the "frame-pointer" switch on IBM Z and IBM POWER platforms will add _emulated_ frame pointers to the binary, which profilers can't use for unwinding the stack). Both attributes can be applied at the LLVM module or function levels. However, the `backchain` attribute has to be enabled for all the functions in the call stack to get a successful unwind process.
2024-07-21Auto merge of #127722 - BoxyUwU:new_adt_const_params_limitations, ↵bors-0/+4
r=compiler-errors Forbid borrows and unsized types from being used as the type of a const generic under `adt_const_params` Fixes #112219 Fixes #112124 Fixes #112125 ### Motivation Currently the `adt_const_params` feature allows writing `Foo<const N: [u8]>` this is entirely useless as it is not possible to write an expression which evaluates to a type that is not `Sized`. In order to actually use unsized types in const generics they are typically written as `const N: &[u8]` which *is* possible to provide a value of. Unfortunately allowing the types of const parameters to contain references is non trivial (#120961) as it introduces a number of difficult questions about how equality of references in the type system should behave. References in the types of const generics is largely only useful for using unsized types in const generics. This PR introduces a new feature gate `unsized_const_parameters` and moves support for `const N: [u8]` and `const N: &...` from `adt_const_params` into it. The goal here hopefully is to experiment with allowing `const N: [u8]` to work without references and then eventually completely forbid references in const generics. Splitting this out into a new feature gate means that stabilization of `adt_const_params` does not have to resolve #120961 which is the only remaining "big" blocker for the feature. Remaining issues after this are a few ICEs and naming bikeshed for `ConstParamTy`. ### Implementation The implementation is slightly subtle here as we would like to ensure that a stabilization of `adt_const_params` is forwards compatible with any outcome of `unsized_const_parameters`. This is inherently tricky as we do not support unstable trait implementations and we determine whether a type is valid as the type of a const parameter via a trait bound. There are a few constraints here: - We would like to *allow for the possibility* of adding a `Sized` supertrait to `ConstParamTy` in the event that we wind up opting to not support unsized types and instead requiring people to write the 'sized version', e.g. `const N: [u8; M]` instead of `const N: [u8]`. - Crates should be able to enable `unsized_const_parameters` and write trait implementations of `ConstParamTy` for `!Sized` types without downstream crates that only enable `adt_const_params` being able to observe this (required for std to be able to `impl<T> ConstParamTy for [T]` Ultimately the way this is accomplished is via having two traits (sad), `ConstParamTy` and `UnsizedConstParamTy`. Depending on whether `unsized_const_parameters` is enabled or not we change which trait is used to check whether a type is allowed to be a const parameter. Long term (when stabilizing `UnsizedConstParamTy`) it should be possible to completely merge these traits (and derive macros), only having a single `trait ConstParamTy` and `macro ConstParamTy`. Under `adt_const_params` it is now illegal to directly refer to `ConstParamTy` it is only used as an internal impl detail by `derive(ConstParamTy)` and checking const parameters are well formed. This is necessary in order to ensure forwards compatibility with all possible future directions for `feature(unsized_const_parameters)`. Generally the intuition here should be that `ConstParamTy` is the stable trait that everything uses, and `UnsizedConstParamTy` is that plus unstable implementations (well, I suppose `ConstParamTy` isn't stable yet :P).
2024-07-18Make unicode text flow control chars visible as �Esteban Küber-1/+2
We already point these out quite aggressively, telling people not to use them, but would normally be rendered as nothing. Having them visible will make it easier for people to actually deal with them. ``` error: unicode codepoint changing visible direction of text present in literal --> $DIR/unicode-control-codepoints.rs:26:22 | LL | println!("{:?}", '�'); | ^-^ | || | |'\u{202e}' | this literal contains an invisible unicode text flow control codepoint | = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen = help: if their presence wasn't intentional, you can remove them help: if you want to keep them but make them visible in your source code, you can escape them | LL | println!("{:?}", '\u{202e}'); | ~~~~~~~~ ``` vs the previous ``` error: unicode codepoint changing visible direction of text present in literal --> $DIR/unicode-control-codepoints.rs:26:22 | LL | println!("{:?}", ''); | ^- | || | |'\u{202e}' | this literal contains an invisible unicode text flow control codepoint | = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen = help: if their presence wasn't intentional, you can remove them help: if you want to keep them but make them visible in your source code, you can escape them | LL | println!("{:?}", '\u{202e}'); | ~~~~~~~~ ```
2024-07-18Be more accurate about calculating `display_col` from a `BytePos`Esteban Küber-160/+41
No longer track "zero-width" chars in `SourceMap`, read directly from the line when calculating the `display_col` of a `BytePos`. Move `char_width` to `rustc_span` and use it from the emitter. This change allows the following to properly align in terminals (depending on the font, the replaced control codepoints are rendered as 1 or 2 width, on my terminal they are rendered as 1, on VSCode text they are rendered as 2): ``` error: this file contains an unclosed delimiter --> $DIR/issue-68629.rs:5:17 | LL | ␜␟ts␀![{i | -- unclosed delimiter | | | unclosed delimiter LL | ␀␀ fn rݻoa>rݻm | ^ ```
2024-07-18Rollup merge of #127854 - fmease:glob-import-type_ir_inherent-lint, ↵Matthias Krüger-0/+1
r=compiler-errors Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent` https://github.com/rust-lang/rust/pull/127627#issuecomment-2225295951 r? compiler-errors
2024-07-18Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`León Orell Valerian Liehr-0/+1
2024-07-17Split part of `adt_const_params` into `unsized_const_params`Boxy-0/+4
2024-07-17rustc_target: add known safe s390x target featuresliushuyu-0/+1
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-9/+9
2024-07-16fmtMichael Goulet-42/+49
2024-07-12rustc_span: derivative -> derive-wherePavel Grigorenko-4/+5
2024-07-12Added the `xop` target feature and `xop_target_feature` gatesayantn-0/+1
2024-07-11Add the feature gate and target-featuressayantn-0/+1
2024-07-05Auto merge of #127008 - Jules-Bertholet:tc-ergonomics, r=Nadrierilbors-0/+1
Match ergonomics 2024: Implement TC's match ergonomics proposal Under gate `ref_pat_eat_one_layer_2024_structural`. Enabling `ref_pat_eat_one_layer_2024` at the same time allows the union of what the individual gates allow. `@traviscross` r? `@Nadrieril` cc https://github.com/rust-lang/rust/issues/123076 `@rustbot` label A-edition-2024 A-patterns
2024-07-05use old ctx if has same expand environment during decode spanbohan-0/+8
2024-06-30add `rustc_dump_def_parents` attributeBoxy-0/+1
2024-06-28address review commentsDeadbeef-2/+2
2024-06-28implement new effects desugaringDeadbeef-0/+9
2024-06-28Rollup merge of #124741 - nebulark:patchable-function-entries-pr, ↵Matthias Krüger-0/+3
r=estebank,workingjubilee patchable-function-entry: Add unstable compiler flag and attribute Tracking issue: #123115 Add the -Z patchable-function-entry compiler flag and the #[patchable_function_entry(prefix_nops = m, entry_nops = n)] attribute. Rebased and adjusted the canditate implementation to match changes in the RFC.
2024-06-27Implement TC's match ergonomics 2024 proposalJules Bertholet-0/+1
Under gate `ref_pat_eat_one_layer_2024_structural`. Enabling `ref_pat_eat_one_layer_2024` at the same time allows the union of what the individual gates allow.
2024-06-25Updated code for changes to RFC, added additional error handling, addedFlorian Schmiderer-2/+2
tests
2024-06-25Support `#[patchable_function_entries]`Matthew Maurer-0/+3
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
2024-06-25Auto merge of #126326 - eggyal:ununsafe-StableOrd, r=michaelwoeristerbors-2/+4
Un-unsafe the `StableOrd` trait Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc. [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Policy.20of.20.60unsafe.60.20within.20the.20compiler). cc [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), #105175, `@michaelwoerister` r? `@Nilstrieb`
2024-06-24Rollup merge of #125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwcoMichael Goulet-0/+8
SmartPointer derive-macro <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Possibly replacing #123472 for continued upkeep of the proposal rust-lang/rfcs#3621 and implementation of the tracking issue #123430. cc `@Darksonn` `@wedsonaf`
2024-06-24Rollup merge of #125241 - Veykril:tool-rust-analyzer, r=davidtwcoMatthias Krüger-0/+1
Add `rust_analyzer` as a predefined tool Given all the other rust-lang tools have it, I'd expect r-a to have it too. (we have a few ideas for using this https://github.com/rust-lang/rust-analyzer/issues/11556).
2024-06-24SmartPointer derive-macroXiangfei Ding-0/+8
Co-authored-by: Wedson Almeida Filho <walmeida@microsoft.com>
2024-06-22Allow "C-unwind" fn to have C variadicsJubilee Young-0/+1
2024-06-22Rollup merge of #126686 - fmease:dump-preds-n-item-bounds, r=compiler-errorsGuillaume Gomez-0/+2
Add `#[rustc_dump_{predicates,item_bounds}]` Conflicts with #126668. As discussed r? compiler-errors CC ``@fee1-dead``
2024-06-22Ensure careful consideration is given by implsAlan Egerton-1/+3
Added an associated `const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED` to the `StableOrd` trait to ensure that implementors carefully consider whether the trait's contract is upheld, as incorrect implementations can cause miscompilations.
2024-06-22Add `#[rustc_dump_{predicates,item_bounds}]`León Orell Valerian Liehr-0/+2
2024-06-21Rollup merge of #126530 - beetrees:f16-inline-asm-riscv, r=AmanieuJubilee-0/+2
Add `f16` inline ASM support for RISC-V This PR adds `f16` inline ASM support for RISC-V. A `FIXME` is left for `f128` support as LLVM does not support the required `Q` (Quad-Precision Floating-Point) extension yet. Relevant issue: #125398 Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2024-06-21Add `f16` inline ASM support for RISC-Vbeetrees-0/+2
2024-06-21Auto merge of #123165 - oli-obk:no_ord_def_id3, r=cjgillotbors-32/+15
Stop sorting `Span`s' `SyntaxContext`, as that is incompatible with incremental work towards https://github.com/rust-lang/rust/issues/90317 Luckily no one actually needed these to be sorted, so it didn't even affect diagnostics. I'm guessing they'd have been sorted by creation time anyway, so it wouldn't really have mattered. r? `@cjgillot`
2024-06-21Add `rust_analyzer` as a predefined toolLukas Wirth-0/+1
2024-06-20[GVN] Add tests for generic pointees with PtrMetadataScott McMurray-0/+1
2024-06-20rustc_span: Optimize span parent get/set methodsVadim Petrochenkov-35/+70
2024-06-19Rollup merge of #126668 - fmease:rm-rustc_dump_program_clauses-attrs, ↵fee1-dead-2/+0
r=fee1-dead Remove now NOP attrs `#[rustc_dump{,_env}_program_clauses]` Likely NOP since #113303. r? `@fee1-dead`
2024-06-19Remove now NOP attrs `#[rustc_dump{,_env}_program_clauses]`León Orell Valerian Liehr-2/+0
2024-06-19Rollup merge of #125293 - dingxiangfei2009:tail-expr-temp-lifetime, ↵许杰友 Jieyou Xu (Joe)-0/+1
r=estebank,davidtwco Place tail expression behind terminating scope This PR implements #123739 so that we can do further experiments in nightly. A little rewrite has been applied to `for await` lowering. It was previously `unsafe { Pin::unchecked_new(into_async_iter(..)) }`. Under the edition 2024 rule, however, `into_async_iter` gets dropped at the end of the `unsafe` block. This presumably the first Edition 2024 migration rule goes by hoisting `into_async_iter(..)` into `match` one level above, so it now looks like the following. ```rust match into_async_iter($iter_expr) { ref mut iter => match unsafe { Pin::unchecked_new(iter) } { ... } } ```
2024-06-18tail expression behind terminating scopeDing Xiang Fei-0/+1
2024-06-17[perf] More span update benchmarkingVadim Petrochenkov-30/+11
2024-06-16Auto merge of #126543 - petrochenkov:upctxt4, r=cjgillotbors-15/+25
rustc_span: Optimize more hygiene operations using `Span::map_ctxt` I missed these in https://github.com/rust-lang/rust/pull/125017.
2024-06-16rustc_span: Minor improvementsVadim Petrochenkov-10/+14
Introduce `{IndexNewtype,SyntaxContext}::from_u16` for convenience because small indices are sometimes encoded as `u16`. Use `SpanData::span` instead of `Span::new` where appropriate. Add a clarifying comment about decoding span parents.
2024-06-16rustc_span: Optimize more hygiene operations using `Span::map_ctxt`Vadim Petrochenkov-15/+25
2024-06-15Rollup merge of #125829 - petrochenkov:upctxt2, r=michaelwoeristerMatthias Krüger-113/+178
rustc_span: Add conveniences for working with span formats This is the refactoring part of https://github.com/rust-lang/rust/pull/125017.
2024-06-14Auto merge of #118958 - c410-f3r:concat-again, r=petrochenkovbors-0/+1
Add a new concat metavar expr Revival of #111930 Giving it another try now that #117050 was merged. With the new rules, meta-variable expressions must be referenced with a dollar sign (`$`) and this can cause misunderstands with `$concat`. ```rust macro_rules! foo { ( $bar:ident ) => { const ${concat(VAR, bar)}: i32 = 1; }; } // Will produce `VARbar` instead of `VAR_123` foo!(_123); ``` In other words, forgetting the dollar symbol can produce undesired outputs. cc #29599 cc https://github.com/rust-lang/rust/issues/124225
2024-06-13Add a new concat metavar exprCaio-0/+1
2024-06-13rustc_span: Remove transmutes from span encodingVadim Petrochenkov-15/+37
2024-06-13rustc_span: By-value interface for ctxt updateVadim Petrochenkov-28/+22