about summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
2025-03-01Implment `#[cfg]` and `#[cfg_attr]` in `where` clausesFrank King-0/+1
2025-02-28Introduce `feature(generic_const_parameter_types)`Boxy-0/+1
2025-02-26Support raw-dylib link kind on ELFNoratrieb-0/+1
raw-dylib is a link kind that allows rustc to link against a library without having any library files present. This currently only exists on Windows. rustc will take all the symbols from raw-dylib link blocks and put them in an import library, where they can then be resolved by the linker. While import libraries don't exist on ELF, it would still be convenient to have this same functionality. Not having the libraries present at build-time can be convenient for several reasons, especially cross-compilation. With raw-dylib, code linking against a library can be cross-compiled without needing to have these libraries available on the build machine. If the libc crate makes use of this, it would allow cross-compilation without having any libc available on the build machine. This is not yet possible with this implementation, at least against libc's like glibc that use symbol versioning. The raw-dylib kind could be extended with support for symbol versioning in the future. This implementation is very experimental and I have not tested it very well. I have tested it for a toy example and the lz4-sys crate, where it was able to successfully link a binary despite not having a corresponding library at build-time.
2025-02-25Auto merge of #137608 - fmease:rollup-h4siso6, r=fmeasebors-2/+0
Rollup of 8 pull requests Successful merges: - #137370 (adjust_abi: make fallback logic for ABIs a bit easier to read) - #137444 (Improve behavior of `IF_LET_RESCOPE` around temporaries and place expressions) - #137464 (Fix invalid suggestion from type error for derive macro) - #137539 ( Add rustdoc-gui regression test for #137082 ) - #137576 (Don't doc-comment BTreeMap<K, SetValZST, A>) - #137595 (remove `simd_fpow` and `simd_fpowi`) - #137600 (type_ir: remove redundant part of comment) - #137602 (feature: fix typo in attribute description) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-25Rollup merge of #137360 - real-eren:rustc_span/use-chunks-exact, r=NoratriebLeón Orell Valerian Liehr-7/+5
Use `as_chunks` in `analyze_source_file_sse2` Follow-up to #136460. Uses a slightly cleaner method of iterating over chunks of bytes.
2025-02-25Rollup merge of #137595 - folkertdev:remove-simd-pow-powi, r=RalfJungLeón Orell Valerian Liehr-2/+0
remove `simd_fpow` and `simd_fpowi` Discussed in https://github.com/rust-lang/rust/issues/137555 These functions are not exposed from `std::intrinsics::simd`, and not used anywhere outside of the compiler. They also don't lower to particularly good code at least on the major ISAs (I checked x86_64, aarch64, s390x, powerpc), where the vector is just spilled to the stack and scalar functions are used for the actual logic. r? `@RalfJung`
2025-02-25remove `simd_fpow` and `simd_fpowi`Folkert de Vries-2/+0
2025-02-25Auto merge of #137573 - compiler-errors:rollup-noq9yhp, r=compiler-errorsbors-2/+1
Rollup of 11 pull requests Successful merges: - #136522 (Remove `feature(dyn_compatible_for_dispatch)` from the compiler) - #137289 (Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`) - #137321 (Correct doc about `temp_dir()` behavior on Android) - #137417 (rustc_target: Add more RISC-V atomic-related features) - #137489 (remove `#[rustc_intrinsic_must_be_overridde]`) - #137530 (DWARF mixed versions with LTO on MIPS) - #137543 (std: Fix another new symlink test on Windows) - #137548 (Pass correct `TypingEnv` to `InlineAsmCtxt`) - #137550 (Don't immediately panic if dropck fails without returning errors) - #137552 (Update books) - #137556 (rename simd_shuffle_generic → simd_shuffle_const_generic) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-24Rollup merge of #137556 - RalfJung:simd_shuffle_const_generic, r=oli-obkMichael Goulet-1/+1
rename simd_shuffle_generic → simd_shuffle_const_generic I've been confused by this name one time too often. ;) r? `@oli-obk`
2025-02-24rename simd_shuffle_generic → simd_shuffle_const_genericRalf Jung-1/+1
2025-02-24span: add a "future" editionDavid Wood-2/+28
It's hard to implement edition migrations without having a perma-unstable "future" edition to target.
2025-02-24Introduce new-style attribute parsers for several attributesJana Dönszelmann-0/+6
note: compiler compiles but librustdoc and clippy don't
2025-02-24remove support for rustc_intrinsic_must_be_overridden from the compilerRalf Jung-1/+0
2025-02-23Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35Trevor Gross-12/+4
intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic LLVM has three intrinsics here that all do the same thing (when used in the default FP environment). There's no reason Rust needs to copy that historically-grown mess -- let's just have one intrinsic and leave it up to the LLVM backend to decide how to lower that. Suggested by `@hanna-kruppe` in https://github.com/rust-lang/rust/issues/136459; Cc `@tgross35` try-job: test-various
2025-02-23Use `as_chunks` in `analyze_source_file_sse2`real-eren-7/+5
2025-02-23Auto merge of #137237 - cuviper:stage0, r=Mark-Simulacrumbors-126/+0
Master bootstrap update https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday r? `@Mark-Simulacrum`
2025-02-22Fix binding mode problemsMichael Goulet-2/+2
2025-02-19Restrict bevy hackMichael Goulet-0/+2
2025-02-18update `cfg(bootstrap)`Josh Stone-126/+0
2025-02-18add last std diagnostic items for clippycyrgani-0/+7
2025-02-17Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgrbors-5/+6
Rollup of 7 pull requests Successful merges: - #137095 (Replace some u64 hashes with Hash64) - #137100 (HIR analysis: Remove unnecessary abstraction over list of clauses) - #137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.) - #137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows) - #137125 (Re-add missing empty lines in the releases notes) - #137145 (use add-core-stubs / minicore for a few more tests) - #137149 (Remove SSE ABI from i586-pc-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-17Rollup merge of #137140 - Noratrieb:const-move, r=jieyouxu,compiler-errorsMatthias Krüger-0/+2
Fix const items not being allowed to be called `r#move` or `r#static` Because of an ambiguity with const closures, the parser needs to ensure that for a const item, the `const` keyword isn't followed by a `move` or `static` keyword, as that would indicate a const closure: ```rust fn main() { const move // ... } ``` This check did not take raw identifiers into account, therefore being unable to distinguish between `const move` and `const r#move`. The latter is obviously not a const closure, so it should be allowed as a const item. This fixes the check in the parser to only treat `const ...` as a const closure if it's followed by the *proper keyword*, and not a raw identifier. Additionally, this adds a large test that tests for all raw identifiers in all kinds of positions, including `const`, to prevent issues like this one from occurring again. fixes #137128
2025-02-17Rollup merge of #137101 - GrigorenkoPV:str-inherent-lint, r=UrgauMatthias Krüger-0/+4
`invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing https://github.com/rust-lang/rust/issues/131114#issuecomment-2646663535 Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
2025-02-17Rename `pattern_complexity` attr as `pattern_complexity_limit`.Nicholas Nethercote-1/+1
For consistency with `recursion_limit`, `move_size_limit`, and `type_length_limit`.
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-5/+6
with rust-analyzer
2025-02-16Fix const items not being allowed to be called `r#move` or `r#static`Noratrieb-0/+2
Because of an ambiguity with const closures, the parser needs to ensure that for a const item, the `const` keyword isn't followed by a `move` or `static` keyword, as that would indicate a const closure: ```rust fn main() { const move // ... } ``` This check did not take raw identifiers into account, therefore being unable to distinguish between `const move` and `const r#move`. The latter is obviously not a const closure, so it should be allowed as a const item. This fixes the check in the parser to only treat `const ...` as a const closure if it's followed by the *proper keyword*, and not a raw identifier. Additionally, this adds a large test that tests for all raw identifiers in all kinds of positions, including `const`, to prevent issues like this one from occurring again.
2025-02-16invalid_from_utf8[_unchecked]: also lint inherent methodsPavel Grigorenko-0/+4
2025-02-13Rollup merge of #136460 - real-eren:simplify-rustc_span-analyze, r=NoratriebJubilee-132/+55
Simplify `rustc_span` `analyze_source_file` Simplifies the logic to what the code *actually* does, which is to just record newlines and multibyte characters. Checking for other ASCII control characters is unnecessary because the generic fallback doesn't do anything for those cases. Also uses a simpler (and more efficient) means of iterating the set bits of the mask.
2025-02-13Auto merge of #136965 - jhpratt:rollup-bsnqvmf, r=jhprattbors-0/+2
Rollup of 8 pull requests Successful merges: - #134999 (Add cygwin target.) - #136559 (Resolve named regions when reporting type test failures in NLL) - #136660 (Use a trait to enforce field validity for union fields + `unsafe` fields + `unsafe<>` binder types) - #136858 (Parallel-compiler-related cleanup) - #136881 (cg_llvm: Reduce visibility of all functions in the llvm module) - #136888 (Always perform discr read for never pattern in EUV) - #136948 (Split out the `extern_system_varargs` feature) - #136949 (Fix import in bench for wasm) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-13Rollup merge of #136948 - workingjubilee:split-off-extern-system-varargs, ↵Jacob Pratt-0/+1
r=compiler-errors Split out the `extern_system_varargs` feature After the stabilization PR was opened, `extern "system"` functions were added to `extended_varargs_abi_support`. This has a number of questions regarding it that were not discussed and were somewhat surprising. It deserves to be considered as its own feature, separate from `extended_varargs_abi_support`. Tracking issue: - https://github.com/rust-lang/rust/issues/136946
2025-02-13Rollup merge of #136660 - compiler-errors:BikeshedGuaranteedNoDrop, r=lcnrJacob Pratt-0/+1
Use a trait to enforce field validity for union fields + `unsafe` fields + `unsafe<>` binder types This PR introduces a new, internal-only trait called `BikeshedGuaranteedNoDrop`[^1] to faithfully model the field check that used to be implemented manually by `allowed_union_or_unsafe_field`. https://github.com/rust-lang/rust/blob/942db6782f4a28c55b0b75b38fd4394d0483390f/compiler/rustc_hir_analysis/src/check/check.rs#L84-L115 Copying over the doc comment from the trait: ```rust /// Marker trait for the types that are allowed in union fields, unsafe fields, /// and unsafe binder types. /// /// Implemented for: /// * `&T`, `&mut T` for all `T`, /// * `ManuallyDrop<T>` for all `T`, /// * tuples and arrays whose elements implement `BikeshedGuaranteedNoDrop`, /// * or otherwise, all types that are `Copy`. /// /// Notably, this doesn't include all trivially-destructible types for semver /// reasons. /// /// Bikeshed name for now. ``` As far as I am aware, there's no new behavior being guaranteed by this trait, since it operates the same as the manually implemented check. We could easily rip out this trait and go back to using the manually implemented check for union fields, however using a trait means that this code can be shared by WF for `unsafe<>` binders too. See the last commit. The only diagnostic changes are that this now fires false-negatives for fields that are ill-formed. I don't consider that to be much of a problem though. r? oli-obk [^1]: Please let's not bikeshed this name lol. There's no good name for `ValidForUnsafeFieldsUnsafeBindersAndUnionFields`.
2025-02-13Implement RFC 3624 supertrait_item_shadowingMichael Goulet-0/+1
2025-02-12Split out the `extern_system_varargs` featureJubilee Young-0/+1
After the stabilization PR was opened, `extern "system"` functions were added to `extended_varargs_abi_support`. This has a number of questions regarding it that were not discussed and were somewhat surprising. It deserves to be considered as its own feature, separate from `extended_varargs_abi_support`.
2025-02-13Implement and use BikeshedGuaranteedNoDrop for union/unsafe field validityMichael Goulet-0/+1
2025-02-12Add diagnostic item for `std::io::BufRead`Samuel Tardieu-0/+1
This will be used in Clippy to detect unbuffered calls to `Read::bytes()`.
2025-02-11Rollup merge of #136584 - oli-obk:pattern-types-generic, r=BoxyUwUMatthias Krüger-0/+1
Prevent generic pattern types from being used in libstd Pattern types should follow the same rules that patterns follow. So a pattern type range must not wrap and not be empty. While we reject such invalid ranges at layout computation time, that only happens during monomorphization in the case of const generics. This is the exact same issue as other const generic math has, and since there's no solution there yet, I put these pattern types behind a separate incomplete feature. These are not necessary for the pattern types MVP (replacing the layout range attributes in libcore and rustc). cc #136574 (new tracking issue for the `generic_pattern_types` feature gate) r? ``@lcnr`` cc ``@scottmcm`` ``@joshtriplett``
2025-02-09rename the trait to validity and place a feature gate afrontDing Xiang Fei-2/+2
2025-02-09introduce CoercePointeeWellformed for coherence checks at typeck stageDing Xiang Fei-0/+2
2025-02-06Auto merge of #136471 - safinaskar:parallel, r=SparrowLiibors-61/+62
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` This is continuation of https://github.com/rust-lang/rust/pull/132282 . I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement. There are other possibilities, through. We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase. So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge. cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2025-02-06Prevent generic pattern types from being used in libstdOli Scherer-0/+1
2025-02-05Rollup merge of #128045 - pnkfelix:rustc-contracts, r=oli-obkLeón Orell Valerian Liehr-0/+14
#[contracts::requires(...)] + #[contracts::ensures(...)] cc https://github.com/rust-lang/rust/issues/128044 Updated contract support: attribute syntax for preconditions and postconditions, implemented via a series of desugarings that culminates in: 1. a compile-time flag (`-Z contract-checks`) that, similar to `-Z ub-checks`, attempts to ensure that the decision of enabling/disabling contract checks is delayed until the end user program is compiled, 2. invocations of lang-items that handle invoking the precondition, building a checker for the post-condition, and invoking that post-condition checker at the return sites for the function, and 3. intrinsics for the actual evaluation of pre- and post-condition predicates that third-party verification tools can intercept and reinterpret for their own purposes (e.g. creating shims of behavior that abstract away the function body and replace it solely with the pre- and post-conditions). Known issues: * My original intent, as described in the MCP (https://github.com/rust-lang/compiler-team/issues/759) was to have a rustc-prefixed attribute namespace (like rustc_contracts::requires). But I could not get things working when I tried to do rewriting via a rustc-prefixed builtin attribute-macro. So for now it is called `contracts::requires`. * Our attribute macro machinery does not provide direct support for attribute arguments that are parsed like rust expressions. I spent some time trying to add that (e.g. something that would parse the attribute arguments as an AST while treating the remainder of the items as a token-tree), but its too big a lift for me to undertake. So instead I hacked in something approximating that goal, by semi-trivially desugaring the token-tree attribute contents into internal AST constucts. This may be too fragile for the long-term. * (In particular, it *definitely* breaks when you try to add a contract to a function like this: `fn foo1(x: i32) -> S<{ 23 }> { ... }`, because its token-tree based search for where to inject the internal AST constructs cannot immediately see that the `{ 23 }` is within a generics list. I think we can live for this for the short-term, i.e. land the work, and continue working on it while in parallel adding a new attribute variant that takes a token-tree attribute alongside an AST annotation, which would completely resolve the issue here.) * the *intent* of `-Z contract-checks` is that it behaves like `-Z ub-checks`, in that we do not prematurely commit to including or excluding the contract evaluation in upstream crates (most notably, `core` and `std`). But the current test suite does not actually *check* that this is the case. Ideally the test suite would be extended with a multi-crate test that explores the matrix of enabling/disabling contracts on both the upstream lib and final ("leaf") bin crates.
2025-02-04Auto merge of #135760 - scottmcm:disjoint-bitor, r=WaffleLapkinbors-0/+1
Add `unchecked_disjoint_bitor` per ACP373 Following the names from libs-api in https://github.com/rust-lang/libs-team/issues/373#issuecomment-2085686057 Includes a fallback implementation so this doesn't have to update cg_clif or cg_gcc, and overrides it in cg_llvm to use `or disjoint`, which [is available in LLVM 18](https://releases.llvm.org/18.1.0/docs/LangRef.html#or-instruction) so hopefully we don't need any version checks.
2025-02-04intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even ↵Ralf Jung-12/+4
intrinsic
2025-02-04Rollup merge of #136167 - pitaj:new_range, r=NadrierilJacob Pratt-0/+4
Implement unstable `new_range` feature Switches `a..b`, `a..`, and `a..=b` to resolve to the new range types. For rust-lang/rfcs#3550 Tracking issue #123741 also adds the re-export that was missed in the original implementation of `new_range_api`
2025-02-04Rollup merge of #134814 - sayantn:keylocker, r=oli-obkMatthias Krüger-0/+1
Add `kl` and `widekl` target features, and the feature gate This is an effort towards #134813. This PR adds the target-features and the feature gate to `rustc` <!-- ```@rustbot``` label O-x86_64 O-x86_32 A-target-feature r? compiler -->
2025-02-03Rename rustc_contract to contractCelina G. Val-4/+4
This has now been approved as a language feature and no longer needs a `rustc_` prefix. Also change the `contracts` feature to be marked as incomplete and `contracts_internals` as internal.
2025-02-03Separate contract feature gates for the internal machineryFelix S. Klock II-0/+2
The extended syntax for function signature that includes contract clauses should never be user exposed versus the interface we want to ship externally eventually.
2025-02-03Desugars contract into the internal AST extensionsFelix S. Klock II-0/+2
Check ensures on early return due to Try / Yeet Expand these two expressions to include a call to contract checking
2025-02-03Express contracts as part of function header and lower it to the contract ↵Celina G. Val-0/+5
lang items includes post-developed commit: do not suggest internal-only keywords as corrections to parse failures. includes post-developed commit: removed tabs that creeped in into rustfmt tool source code. includes post-developed commit, placating rustfmt self dogfooding. includes post-developed commit: add backquotes to prevent markdown checking from trying to treat an attr as a markdown hyperlink/ includes post-developed commit: fix lowering to keep contracts from being erroneously inherited by nested bodies (like closures). Rebase Conflicts: - compiler/rustc_parse/src/parser/diagnostics.rs - compiler/rustc_parse/src/parser/item.rs - compiler/rustc_span/src/hygiene.rs Remove contracts keywords from diagnostic messages
2025-02-03contracts: added lang items that act as hooks for rustc-injected code to invoke.Felix S. Klock II-0/+1
see test for an example of the kind of injected code that is anticipated here.