summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
2024-03-15Add `rustc_never_type_mode = "no_fallback"`Maybe Waffle-0/+1
2024-03-15Add `rustc_never_type_mode` crate-level attribute to allow experimentingMaybe Waffle-0/+4
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-0/+1
2024-03-11Rollup merge of #121840 - oli-obk:freeze, r=dtolnayJacob Pratt-0/+1
Expose the Freeze trait again (unstably) and forbid implementing it manually non-emoji version of https://github.com/rust-lang/rust/pull/121501 cc #60715 This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue. It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: https://github.com/google/zerocopy/issues/941 cc ```@RalfJung``` T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
2024-03-11Rename `DecorateLint` as `LintDiagnostic`.Nicholas Nethercote-1/+1
To match `derive(LintDiagnostic)`.
2024-03-11Rename `AddToDiagnostic` as `Subdiagnostic`.Nicholas Nethercote-1/+1
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-1/+1
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-09fix legacy numeric constant diag itemsPeter Jaszkowiak-0/+10
- missed syms for usize/isize - missed diag items on unsigned integers
2024-03-10Auto merge of #121662 - saethlin:precondition-unification, r=RalfJungbors-0/+2
Distinguish between library and lang UB in assert_unsafe_precondition As described in https://github.com/rust-lang/rust/pull/121583#issuecomment-1963168186, `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do). `debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation. Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR. r? RalfJung
2024-03-09Rollup merge of #122233 - RalfJung:custom-alloc-box, r=oli-obkMatthias Krüger-0/+1
miri: do not apply aliasing restrictions to Box with custom allocator This is the Miri side of https://github.com/rust-lang/rust/pull/122018. The "intrinsics with body" made this much more pleasant. :) Fixes https://github.com/rust-lang/miri/issues/3341. r? `@oli-obk`
2024-03-09miri: do not apply aliasing restrictions to Box with custom allocatorRalf Jung-0/+1
2024-03-09Auto merge of #122102 - Urgau:optimize-symbol-integer, r=cjgillotbors-2/+4
Optimize `Symbol::integer` by utilizing in-place formatting This PR optimize `Symbol::integer` by utilizing `itoa` in-place formatting instead of going through a dynamically allocated `String` and the format machinery. <details> For some context: I was profiling `rustc --check-cfg` with callgrind and due to the way we currently setup all the targets and we end-up calling `Symbol::integer` multiple times for all the targets. Using `itoa` reduced the number of instructions. </details>
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-0/+2
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-0/+1
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-06Optimize Symbol::integer by utilizing itoa in-place formattingUrgau-2/+4
2024-03-05only set noalias on Box with the global allocatorRalf Jung-0/+1
2024-03-05Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwcobors-2/+2
Diagnostic renaming 2 A sequel to #121489. r? `@davidtwco`
2024-03-05Rename `SubdiagnosticMessage` as `SubdiagMessage`.Nicholas Nethercote-1/+1
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-1/+1
2024-03-04Add a scheme for moving away from `extern "rust-intrinsic"` entirelyOli Scherer-0/+1
2024-03-03Rollup merge of #121917 - GuillaumeGomez:pattern-complexity_limit.rs, ↵Guillaume Gomez-0/+1
r=Nadrieril Add new `pattern_complexity` attribute to add possibility to limit and check recursion in pattern matching Needed for https://github.com/rust-lang/rust-analyzer/issues/9528. This PR adds a new attribute only available when running rust testsuite called `pattern_complexity` which allows to set the maximum recursion for the pattern matching. It is quite useful to ensure the complexity doesn't grow, like in `tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs`. r? `@Nadrieril`
2024-03-03Add new `pattern_complexity` attribute to add possibility to limit and check ↵Guillaume Gomez-0/+1
recursion in pattern matching
2024-03-01Add `f16` and `f128` LLVM intrinsicsTrevor Gross-0/+46
2024-03-01Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errorsbors-0/+2
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
2024-02-29Forbid implementing `Freeze` even if the trait is stabilizedOli Scherer-0/+1
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+2
Make changes necessary to support these types in the compiler.
2024-02-28Rollup merge of #121686 - compiler-errors:rpitit-printing, r=lcnrGuillaume Gomez-0/+1
Adjust printing for RPITITs 1. Call RPITITs `{synthetic#N}` instead of `{opaque#N}`. 2. Fall back to printing the RPITIT like an opaque even when printed as an `AliasTy`, just like we do for `ty::Alias`. You could argue that (2.) is misleading, but I believe it's more consistent than naming `{synthetic#N}`, which I assume approximately nobody knows where that def path name comes from. r? lcnr
2024-02-27rename RPITIT from opaque to syntheticMichael Goulet-0/+1
2024-02-27Rename wasm32-wasi-preview2 to wasm32-wasip2Ryan Levick-1/+1
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27Add the wasm32-wasi-preview2 targetRyan Levick-0/+1
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27Auto merge of #121667 - pitaj:diag_items-legacy_numeric_constants, r=Nilstriebbors-0/+78
syms for legacy numeric constants diag items Missed these in #121272 and #121361, woops. For https://github.com/rust-lang/rust-clippy/pull/12312 r? `@Nilstrieb`
2024-02-26syms for legacy numeric constants diag itemsPeter Jaszkowiak-0/+78
2024-02-26rename 'try' intrinsic to 'catch_unwind'Ralf Jung-0/+1
2024-02-24Add `#[rustc_no_mir_inline]` for standard library UB checksNilstrieb-0/+1
Co-authored-by: Ben Kimock <kimockb@gmail.com>
2024-02-24Add asm label support to AST and HIRGary Guo-0/+1
2024-02-21remove simd_reduce_{min,max}_nanlessRalf Jung-2/+0
2024-02-21Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercotebors-0/+5
Add "algebraic" fast-math intrinsics, based on fast-math ops that cannot return poison Setting all of LLVM's fast-math flags makes our fast-math intrinsics very dangerous, because some inputs are UB. This set of flags permits common algebraic transformations, but according to the [LangRef](https://llvm.org/docs/LangRef.html#fastmath), only the flags `nnan` (no nans) and `ninf` (no infs) can produce poison. And this uses the algebraic float ops to fix https://github.com/rust-lang/rust/issues/120720 cc `@orlp`
2024-02-20Add "algebraic" versions of the fast-math intrinsicsBen Kimock-0/+5
2024-02-18Auto merge of #119673 - petrochenkov:dialoc5, r=compiler-errors,cjgillotbors-14/+59
macro_rules: Preserve all metavariable spans in a global side table This PR preserves spans of `tt` metavariables used to pass tokens to declarative macros. Such metavariable spans can then be used in span combination operations like `Span::to` to improve all kinds of diagnostics. Spans of non-`tt` metavariables are currently kept in nonterminal tokens, but the long term plan is remove all nonterminal tokens from rustc parser and rely on the proc macro model with invisible delimiters (#114647, #67062). In particular, `NtIdent` nonterminal (corresponding to `ident` metavariables) becomes easy to remove when this PR lands (#119412 does it). The metavariable spans are kept in a global side table keyed by `Span`s of original tokens. The alternative to the side table is keeping them in `SpanData` instead, but the performance regressions would be large because any spans from tokens passed to declarative macros would stop being inline and would work through span interner instead, and the penalty would be paid even if we never use the metavar span for the given original span. (But also see the comment on `fn maybe_use_metavar_location` describing the map collision issues with the side table approach.) There are also other alternatives - keeping the metavar span in `Token` or `TokenTree`, but associating it with `Span` itsel is the most natural choice because metavar spans are used in span combining operations, and those operations are not necessarily tied to tokens.
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-2/+0
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2024-02-18macro_rules: Preserve all metavariable spans in a global side tableVadim Petrochenkov-14/+59
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-0/+1
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-12Rollup merge of #120965 - ChrisDenton:sahf, r=michaelwoeristerMatthias Krüger-0/+2
Add lahfsahf and prfchw target feature This adds target features for LAHF/SAHF and PrefetchW. These came up. along with the existing CMPXCHG16b. as [baseline features](https://download.microsoft.com/download/c/1/5/c150e1ca-4a55-4a7e-94c5-bfc8c2e785c5/Windows%2010%20Minimum%20Hardware%20Requirements.pdf) required for x86_64 Windows 10+.
2024-02-12Auto merge of #120980 - matthiaskrgr:rollup-dsjsqql, r=matthiaskrgrbors-1/+1
Rollup of 11 pull requests Successful merges: - #120765 (Reorder diagnostics API) - #120833 (More internal emit diagnostics cleanups) - #120899 (Gracefully handle non-WF alias in `assemble_alias_bound_candidates_recur`) - #120917 (Remove a bunch of dead parameters in functions) - #120928 (Add test for recently fixed issue) - #120933 (check_consts: fix duplicate errors, make importance consistent) - #120936 (improve `btree_cursors` functions documentation) - #120944 (Check that the ABI of the instance we are inlining is correct) - #120956 (Clean inlined type alias with correct param-env) - #120962 (Add myself to library/std review) - #120972 (fix ICE for deref coercions with type errors) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-12Add lahfsahf and prfchw target featureChris Denton-0/+2
2024-02-12Implement intrinsics with fallback bodiesOli Scherer-0/+1
2024-02-12Tweak delayed bug mentions.Nicholas Nethercote-1/+1
Now that we have both `delayed_bug` and `span_delayed_bug`, it makes sense to use the generic term "delayed bug" more.
2024-02-12Lower anonymous structs or unions to HIRFrank King-0/+1
2024-02-11Rollup merge of #120272 - ↵Matthias Krüger-0/+7
long-long-float:suppress-suggestions-in-derive-macro, r=oli-obk Suppress suggestions in derive macro close #118809 I suppress warnings inside derive macros. For example, the compiler emits following error by a program described in https://github.com/rust-lang/rust/issues/118809#issuecomment-1852256687 with a suggestion that indicates invalid syntax. ``` error[E0308]: `?` operator has incompatible types --> src/main.rs:3:17 | 3 | #[derive(Debug, Deserialize)] | ^^^^^^^^^^^ expected `u32`, found `u64` | = note: `?` operator cannot convert from `u64` to `u32` = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit | 3 | #[derive(Debug, Deserialize.try_into().unwrap())] | ++++++++++++++++++++ For more information about this error, try `rustc --explain E0308`. error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors ``` In this PR, suggestions to cast are suppressed. ``` error[E0308]: `?` operator has incompatible types --> src/main.rs:3:17 | 3 | #[derive(Debug, Deserialize)] | ^^^^^^^^^^^ expected `u32`, found `u64` | = note: `?` operator cannot convert from `u64` to `u32` = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0308`. error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors ```
2024-02-10unstably allow constants to refer to statics and read from immutable staticsRalf Jung-0/+1