summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
2021-06-14Revert "Allow specifying alignment for functions"Felix S. Klock II-1/+0
This reverts commit 448d07683a6defd567996114793a09c9a8aef5df to address issue 85713 on beta.
2021-04-30Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkovbors-0/+1
Implement RFC 1260 with feature_name `imported_main`. This is the second extraction part of #84062 plus additional adjustments. This (mostly) implements RFC 1260. However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure. cc https://github.com/rust-lang/rust/issues/28937 r? `@petrochenkov`
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-0/+1
2021-04-28Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakisbors-2/+1
Stabilize `:pat_param` and remove `:pat2021` Blocked on #83384 cc `@rust-lang/lang` #79278 If I understand `@nikomatsakis` in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/or.20patterns/near/231133873, another FCP is not needed. r? `@nikomatsakis`
2021-04-27remove pat2021mark-1/+0
2021-04-27Derived Eq no longer shows uncoveredRich Kadel-0/+1
The Eq trait has a special hidden function. MIR `InstrumentCoverage` would add this function to the coverage map, but it is never called, so the `Eq` trait would always appear uncovered. Fixes: #83601 The fix required creating a new function attribute `no_coverage` to mark functions that should be ignored by `InstrumentCoverage` and the coverage `mapgen` (during codegen). While testing, I also noticed two other issues: * spanview debug file output ICEd on a function with no body. The workaround for this is included in this PR. * `assert_*!()` macro coverage can appear covered if followed by another `assert_*!()` macro. Normally they appear uncovered. I submitted a new Issue #84561, and added a coverage test to demonstrate this issue.
2021-04-25Auto merge of #84147 - cuviper:array-method-dispatch, r=nikomatsakis,m-ou-sebors-0/+1
Cautiously add IntoIterator for arrays by value Add the attribute described in #84133, `#[rustc_skip_array_during_method_dispatch]`, which effectively hides a trait from method dispatch when the receiver type is an array. Then cherry-pick `IntoIterator for [T; N]` from #65819 and gate it with that attribute. Arrays can now be used as `IntoIterator` normally, but `array.into_iter()` has edition-dependent behavior, returning `slice::Iter` for 2015 and 2018 editions, or `array::IntoIter` for 2021 and later. r? `@nikomatsakis` cc `@LukasKalbertodt` `@rust-lang/libs`
2021-04-24Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obkbors-1/+2
further split up const_fn feature flag This continues the work on splitting up `const_fn` into separate feature flags: * `const_fn_trait_bound` for `const fn` with trait bounds * `const_fn_unsize` for unsizing coercions in `const fn` (looks like only `dyn` unsizing is still guarded here) I don't know if there are even any things left that `const_fn` guards... at least libcore and liballoc do not need it any more. `@oli-obk` are you currently able to do reviews?
2021-04-25Rollup merge of #83519 - oli-obk:assign_shrink_your_normal_code, r=pnkfelixYuki Okushi-0/+2
Implement a lint that highlights all moves larger than a configured limit Tracking issue: #83518 [MCP 420](https://github.com/rust-lang/compiler-team/issues/420) still ~blazing~ in progress r? ```@pnkfelix``` The main open issue I see with this minimal impl of the feature is that the lint is immediately "stable" (so it can be named on stable), even if it is never executed on stable. I don't think we have the concept of unstable lint names or hiding lint names without an active feature gate, so that would be a bigger change.
2021-04-23Auto merge of #84339 - alexcrichton:llvm-fptoint-sat, r=nagisabors-1/+0
rustc: Use LLVM's new saturating float-to-int intrinsics This commit updates rustc, with an applicable LLVM version, to use LLVM's new `llvm.fpto{u,s}i.sat.*.*` intrinsics to implement saturating floating-point-to-int conversions. This results in a little bit tighter codegen for x86/x86_64, but the main purpose of this is to prepare for upcoming changes to the WebAssembly backend in LLVM where wasm's saturating float-to-int instructions will now be implemented with these intrinsics. This change allows simplifying a good deal of surrounding code, namely removing a lot of wasm-specific behavior. WebAssembly no longer has any special-casing of saturating arithmetic instructions and the need for `fptoint_may_trap` is gone and all handling code for that is now removed. This means that the only wasm-specific logic is in the `fpto{s,u}i` instructions which only get used for "out of bounds is undefined behavior". This does mean that for the WebAssembly target specifically the Rust compiler will no longer be 100% compatible with pre-LLVM 12 versions, but it seems like that's unlikely to be relied on by too many folks. Note that this change does immediately regress the codegen of saturating float-to-int casts on WebAssembly due to the specialization of the LLVM intrinsic not being present in our LLVM fork just yet. I'll be following up with an LLVM update to pull in those patches, but affects a few other SIMD things in flight for WebAssembly so I wanted to separate this change. Eventually the entire `cast_float_to_int` function can be removed when LLVM 12 is the minimum version, but that will require sinking the complexity of it into other backends such as Cranelfit.
2021-04-21rustc: Use LLVM's new saturating float-to-int intrinsicsAlex Crichton-1/+0
This commit updates rustc, with an applicable LLVM version, to use LLVM's new `llvm.fpto{u,s}i.sat.*.*` intrinsics to implement saturating floating-point-to-int conversions. This results in a little bit tighter codegen for x86/x86_64, but the main purpose of this is to prepare for upcoming changes to the WebAssembly backend in LLVM where wasm's saturating float-to-int instructions will now be implemented with these intrinsics. This change allows simplifying a good deal of surrounding code, namely removing a lot of wasm-specific behavior. WebAssembly no longer has any special-casing of saturating arithmetic instructions and the need for `fptoint_may_trap` is gone and all handling code for that is now removed. This means that the only wasm-specific logic is in the `fpto{s,u}i` instructions which only get used for "out of bounds is undefined behavior". This does mean that for the WebAssembly target specifically the Rust compiler will no longer be 100% compatible with pre-LLVM 12 versions, but it seems like that's unlikely to be relied on by too many folks. Note that this change does immediately regress the codegen of saturating float-to-int casts on WebAssembly due to the specialization of the LLVM intrinsic not being present in our LLVM fork just yet. I'll be following up with an LLVM update to pull in those patches, but affects a few other SIMD things in flight for WebAssembly so I wanted to separate this change. Eventually the entire `cast_float_to_int` function can be removed when LLVM 12 is the minimum version, but that will require sinking the complexity of it into other backends such as Cranelfit.
2021-04-20Add an attribute to be able to configure the limitOli Scherer-0/+2
2021-04-19fix few typosklensy-1/+1
2021-04-18fix feature use in rustc libsRalf Jung-1/+0
2021-04-18separate feature flag for unsizing casts in const fnRalf Jung-0/+1
2021-04-18move 'trait bounds on const fn' to separate feature gateRalf Jung-0/+1
2021-04-16Implement #[rustc_skip_array_during_method_dispatch]Josh Stone-0/+1
2021-04-16Auto merge of #84217 - crlf0710:remove_main_attr_pure, r=petrochenkovbors-0/+1
Remove #[main] attribute. This removes the #[main] attribute support from the compiler according to the decisions within #29634. For existing use cases within test harness generation, replaced it with a newly-introduced internal attribute `#[rustc_main]`. This is first part extracted from #84062 . Closes #29634. r? `@petrochenkov`
2021-04-16Remove #[main] attribute.Charles Lew-0/+1
2021-04-15Auto merge of #84205 - workingjubilee:more-simd-intrin, r=bjorn3bors-0/+2
Add simd_{round,trunc} intrinsics LLVM supports many functions from math.h in its IR. Many of these have SIMD instructions on various platforms. So, let's add round and trunc so std::arch can use them. Yes, exact comparison is intentional: rounding must always return a valid integer-equal value, except for inf/NAN.
2021-04-15rename pat2015 to pat_parammark-1/+1
2021-04-14Add more SIMD math.h intrinsicsJubilee Young-0/+2
LLVM supports many functions from math.h in its IR. Many of these have single-instruction variants on various platforms. So, let's add them so std::arch can use them. Yes, exact comparison is intentional: rounding must always return a valid integer-equal value, except for inf/NAN.
2021-04-14Auto merge of #83948 - ABouttefeux:lint-nullprt-deref, r=RalfJungbors-0/+2
add lint deref_nullptr detecting when a null ptr is dereferenced fixes #83856 changelog: add lint that detect code like ```rust unsafe { &*core::ptr::null::<i32>() }; unsafe { addr_of!(std::ptr::null::<i32>()) }; let x: i32 = unsafe {*core::ptr::null()}; let x: i32 = unsafe {*core::ptr::null_mut()}; unsafe {*(0 as *const i32)}; unsafe {*(core::ptr::null() as *const i32)}; ``` ``` warning: Dereferencing a null pointer causes undefined behavior --> src\main.rs:5:26 | 5 | let x: i32 = unsafe {*core::ptr::null()}; | ^^^^^^^^^^^^^^^^^^ | | | a null pointer is dereferenced | this code causes undefined behavior when executed | = note: `#[warn(deref_nullptr)]` on by default ``` Limitation: It does not detect code like ```rust const ZERO: usize = 0; unsafe {*(ZERO as *const i32)}; ``` or code where `0` is not directly a literal
2021-04-08rustc: Add a new `wasm` ABIAlex Crichton-0/+1
This commit implements the idea of a new ABI for the WebAssembly target, one called `"wasm"`. This ABI is entirely of my own invention and has no current precedent, but I think that the addition of this ABI might help solve a number of issues with the WebAssembly targets. When `wasm32-unknown-unknown` was first added to Rust I naively "implemented an abi" for the target. I then went to write `wasm-bindgen` which accidentally relied on details of this ABI. Turns out the ABI definition didn't match C, which is causing issues for C/Rust interop. Currently the compiler has a "wasm32 bindgen compat" ABI which is the original implementation I added, and it's purely there for, well, `wasm-bindgen`. Another issue with the WebAssembly target is that it's not clear to me when and if the default C ABI will change to account for WebAssembly's multi-value feature (a feature that allows functions to return multiple values). Even if this does happen, though, it seems like the C ABI will be guided based on the performance of WebAssembly code and will likely not match even what the current wasm-bindgen-compat ABI is today. This leaves a hole in Rust's expressivity in binding WebAssembly where given a particular import type, Rust may not be able to import that signature with an updated C ABI for multi-value. To fix these issues I had the idea of a new ABI for WebAssembly, one called `wasm`. The definition of this ABI is "what you write maps straight to wasm". The goal here is that whatever you write down in the parameter list or in the return values goes straight into the function's signature in the WebAssembly file. This special ABI is for intentionally matching the ABI of an imported function from the environment or exporting a function with the right signature. With the addition of a new ABI, this enables rustc to: * Eventually remove the "wasm-bindgen compat hack". Once this ABI is stable wasm-bindgen can switch to using it everywhere. Afterwards the wasm32-unknown-unknown target can have its default ABI updated to match C. * Expose the ability to precisely match an ABI signature for a WebAssembly function, regardless of what the C ABI that clang chooses turns out to be. * Continue to evolve the definition of the default C ABI to match what clang does on all targets, since the purpose of that ABI will be explicitly matching C rather than generating particular function imports/exports. Naturally this is implemented as an unstable feature initially, but it would be nice for this to get stabilized (if it works) in the near-ish future to remove the wasm32-unknown-unknown incompatibility with the C ABI. Doing this, however, requires the feature to be on stable because wasm-bindgen works with stable Rust.
2021-04-07Remove the insta-stable `cfg(wasm)`Simonas Kazlauskas-1/+0
The addition of `cfg(wasm)` was an oversight on my end that has a number of downsides: * It was introduced as an insta-stable addition, forgoing the usual staging mechanism we use for potentially far-reaching changes; * It is a breaking change for people who are using `--cfg wasm` either directly or via cargo for other purposes; * It is not entirely clear if a bare `wasm` cfg is a right option or whether `wasm` family of targets are special enough to warrant special-casing these targets specifically. As for the last point, there appears to be a fair amount of support for reducing the boilerplate in specifying architectures from the same family, while ignoring their pointer width. The suggested way forward would be to propose such a change as a separate RFC as it is potentially a quite contentious addition.
2021-04-06add lint deref_nullptrAliénore Bouttefeux-0/+2
2021-04-06Auto merge of #81234 - repnop:fn-alignment, r=lcnrbors-0/+1
Allow specifying alignment for functions Fixes #75072 This allows the user to specify alignment for functions, which can be useful for low level work where functions need to necessarily be aligned to a specific value. I believe the error cases not covered in the match are caught earlier based on my testing so I had them just return `None`.
2021-04-05Allow specifying alignment for functionsWesley Norris-0/+1
2021-04-05Rollup merge of #80525 - devsnek:wasm64, r=nagisaDylan DPC-0/+1
wasm64 support There is still some upstream llvm work needed before this can land.
2021-04-04wasm64Gus Caplan-0/+1
2021-04-02Auto merge of #80965 - camelid:rename-doc-spotlight, r=jyn514bors-0/+2
Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` Fixes #80936. "spotlight" is not a very specific or self-explaining name. Additionally, the dialog that it triggers is called "Notable traits". So, "notable trait" is a better name. * Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` * Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]` * Update documentation * Improve documentation r? `@Manishearth`
2021-03-27Remove (lots of) dead codeJoshua Nelson-31/+4
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-26Use iter::zip in compiler/Josh Stone-1/+1
2021-03-23Add has_default to GenericParamDefKind::Constkadmin-0/+1
This currently creates a field which is always false on GenericParamDefKind for future use when consts are permitted to have defaults Update const_generics:default locations Previously just ignored them, now actually do something about them. Fix using type check instead of value Add parsing This adds all the necessary changes to lower const-generics defaults from parsing. Change P<Expr> to AnonConst This matches the arguments passed to instantiations of const generics, and makes it specific to just anonymous constants. Attempt to fix lowering bugs
2021-03-22rename :pat2018 -> :pat215mark-1/+1
2021-03-20Auto merge of #83271 - SparrowLii:simd_neg, r=Amanieubors-0/+1
Add simd_neg platform intrinsic Stdarch needs to add simd_neg to support the implementation of vneg neon instructions. Look [here](https://github.com/rust-lang/stdarch/pull/1087)
2021-03-19Rollup merge of #83197 - jyn514:cfg-test-dead-code, r=joshtriplettDylan DPC-42/+44
Move some test-only code to test files Split out from https://github.com/rust-lang/rust/pull/83185.
2021-03-19Add simd_neg platform intrinsicSparrowLii-0/+1
2021-03-18Remove unwrap_none/expect_none from compiler/.Mara Bos-7/+11
2021-03-17Move some test-only code to test filesJoshua Nelson-42/+44
This also relaxes the bounds on some structs and moves them to the impl block instead.
2021-03-15Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]`Camelid-0/+2
"spotlight" is not a very specific or self-explaining name. Additionally, the dialog that it triggers is called "Notable traits". So, "notable trait" is a better name. * Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` * Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]` * Update documentation * Improve documentation
2021-03-15Replace `type_alias_impl_trait` by `min_type_alias_impl_trait` with no ↵Oli Scherer-0/+1
actual changes in behaviour This makes `type_alias_impl_trait` not actually do anything anymore
2021-03-14expand: Resolve and expand inner attributes on out-of-line modulesVadim Petrochenkov-0/+1
2021-03-13Auto merge of #83064 - cjgillot:fhash, r=jackh726bors-13/+2
Tweaks to stable hashing
2021-03-11Hash SyntaxContext first.Camille GILLOT-3/+2
2021-03-11Remove useless method.Camille GILLOT-10/+0
2021-03-10Auto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPCbors-1/+4
Rollup of 9 pull requests Successful merges: - #81309 (always eagerly eval consts in Relate) - #82217 (Edition-specific preludes) - #82807 (rustdoc: Remove redundant enableSearchInput function) - #82924 (WASI: Switch to crt1-command.o to enable support for new-style commands) - #82949 (Do not attempt to unlock envlock in child process after a fork.) - #82955 (fix: wrong word) - #82962 (Treat header as first paragraph for shortened markdown descriptions) - #82976 (fix error message for copy(_nonoverlapping) overflow) - #82977 (Rename `Option::get_or_default` to `get_or_insert_default`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-10Rollup merge of #82955 - ltoddy:fix/wrong, r=jonas-schievinkDylan DPC-1/+1
fix: wrong word
2021-03-10Rollup merge of #82217 - m-ou-se:edition-prelude, r=nikomatsakisDylan DPC-0/+3
Edition-specific preludes This changes `{std,core}::prelude` to export edition-specific preludes under `rust_2015`, `rust_2018` and `rust_2021`. (As suggested in https://github.com/rust-lang/rust/issues/51418#issuecomment-395630382.) For now they all just re-export `v1::*`, but this allows us to add things to the 2021edition prelude soon. This also changes the compiler to make the automatically injected prelude import dependent on the selected edition. cc `@rust-lang/libs` `@djc`
2021-03-10fix: wrong wordltoddy-1/+1