about summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
2021-07-17Drop ExpnData::krate.Camille GILLOT-19/+10
2021-07-17Drop orig_id.Camille GILLOT-33/+9
2021-07-17Encode ExpnId using ExpnHash for incr. comp.Camille GILLOT-66/+57
2021-07-17Choose encoding format in caller code.Camille GILLOT-72/+26
2021-07-17Use LocalExpnId where possible.Camille GILLOT-14/+1
2021-07-17Make the CrateNum part of the ExpnId.Camille GILLOT-96/+251
2021-07-17Corrected symbol order after adding diagnostic itemsxFrednet-1/+1
2021-07-15Added diagnostic items to structs and traits for ClippyxFrednet-0/+13
2021-07-15Added diagnostic items to functions for ClippyxFrednet-0/+9
2021-07-15Simplify metadata decoding.Camille GILLOT-30/+8
2021-07-15Separate encoding paths.Camille GILLOT-52/+87
The two paths will be modified independently in the next few commits.
2021-07-14Auto merge of #87106 - Mark-Simulacrum:edition-no-clone, r=petrochenkovbors-1/+1
Avoid cloning ExpnData to access Span edition ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In some cases this may get optimized out, but it's not clear that will always be the case. Try to avoid that cost. r? `@ghost` -- opening for a perf run to start with
2021-07-13Auto merge of #87044 - cjgillot:expnhash, r=petrochenkovbors-194/+144
Cache expansion hash globally ... instead of computing it multiple times. Split from #86676 r? `@petrochenkov`
2021-07-13Cache expansion hash.Camille GILLOT-171/+122
2021-07-13Move HashStable implementations.Camille GILLOT-61/+60
2021-07-13Avoid cloning ExpnData to access Span editionMark Rousskov-1/+1
ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In some cases this may get optimized out, but it's not clear that will always be the case. Try to avoid that cost.
2021-07-13Auto merge of #86922 - joshtriplett:target-abi, r=oli-obkbors-0/+2
target abi Implement cfg(target_abi) (RFC 2992) Add an `abi` field to `TargetOptions`, defaulting to "". Support using `cfg(target_abi = "...")` for conditional compilation on that field. Gated by `feature(cfg_target_abi)`. Add a test for `target_abi`, and a test for the feature gate. Add `target_abi` to tidy as a platform-specific cfg. Update targets to use `target_abi` All eabi targets have `target_abi = "eabi".` All eabihf targets have `target_abi = "eabihf"`. `armv6_unknown_freebsd` and `armv7_unknown_freebsd` have `target_abi = "eabihf"`. All abi64 targets have `target_abi = "abi64"`. All ilp32 targets have `target_abi = "ilp32"`. All softfloat targets have `target_abi = "softfloat"`. All *-uwp-windows-* targets have `target_abi = "uwp"`. All spe targets have `target_abi = "spe"`. All macabi targets have `target_abi = "macabi"`. aarch64-apple-ios-sim has `target_abi = "sim"`. `x86_64-fortanix-unknown-sgx` has `target_abi = "fortanix"`. `x86_64-unknown-linux-gnux32` has `target_abi = "x32"`. Add FIXME entries for targets for which existing values need to change once `cfg_target_abi` becomes stable. (All of them are tier 3 targets.) Add a test for `target_abi` in `--print cfg`.
2021-07-13Auto merge of #86857 - fee1-dead:add-attr, r=oli-obkbors-0/+1
Add #[default_method_body_is_const] `@rustbot` label F-const_trait_impl
2021-07-11Auto merge of #87042 - petrochenkov:cleanquotspan, r=Aaron1011bors-42/+29
Cleanup span quoting I finally got to reviewing https://github.com/rust-lang/rust/pull/84278. See the individual commit messages. r? `@Aaron1011`
2021-07-11Auto merge of #86416 - Amanieu:asm_clobber_only, r=nagisabors-0/+3
Add clobber-only register classes for asm! These are needed to properly express a function call ABI using a clobber list, even though we don't support passing actual values into/out of these registers.
2021-07-11rustc_span: Reorder some `ExpnData` fields in accordance with commentsVadim Petrochenkov-26/+25
A drive-by change.
2021-07-10rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`Vadim Petrochenkov-16/+4
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-10Add clobber-only register classes for asm!Amanieu d'Antras-0/+3
These are needed to properly express a function call ABI using a clobber list, even though we don't support passing actual values into/out of these registers.
2021-07-10Add #[default_method_body_is_const]Deadbeef-0/+1
2021-07-09Rollup merge of #86881 - tmiasko:lookup-line, r=nagisaMara Bos-25/+16
Inline implementation of lookup_line to avoid unnecessary conversions from `Option<usize>` to `isize` and back.
2021-07-09Auto merge of #85828 - scottmcm:raw-eq, r=oli-obkbors-0/+1
Stop generating `alloca`s & `memcmp` for simple short array equality Example: ```rust pub fn demo(x: [u16; 6], y: [u16; 6]) -> bool { x == y } ``` Before: ```llvm define zeroext i1 `@_ZN10playground4demo17h48537f7eac23948fE(i96` %0, i96 %1) unnamed_addr #0 { start: %y = alloca [6 x i16], align 8 %x = alloca [6 x i16], align 8 %.0..sroa_cast = bitcast [6 x i16]* %x to i96* store i96 %0, i96* %.0..sroa_cast, align 8 %.0..sroa_cast3 = bitcast [6 x i16]* %y to i96* store i96 %1, i96* %.0..sroa_cast3, align 8 %_11.i.i.i = bitcast [6 x i16]* %x to i8* %_14.i.i.i = bitcast [6 x i16]* %y to i8* %bcmp.i.i.i = call i32 `@bcmp(i8*` nonnull dereferenceable(12) %_11.i.i.i, i8* nonnull dereferenceable(12) %_14.i.i.i, i64 12) #2, !alias.scope !2 %2 = icmp eq i32 %bcmp.i.i.i, 0 ret i1 %2 } ``` ```x86 playground::demo: # `@playground::demo` sub rsp, 32 mov qword ptr [rsp], rdi mov dword ptr [rsp + 8], esi mov qword ptr [rsp + 16], rdx mov dword ptr [rsp + 24], ecx xor rdi, rdx xor esi, ecx or rsi, rdi sete al add rsp, 32 ret ``` After: ```llvm define zeroext i1 `@_ZN4mini4demo17h7a8994aaa314c981E(i96` %0, i96 %1) unnamed_addr #0 { start: %2 = icmp eq i96 %0, %1 ret i1 %2 } ``` ```x86 _ZN4mini4demo17h7a8994aaa314c981E: xor rcx, r8 xor edx, r9d or rdx, rcx sete al ret ```
2021-07-09Auto merge of #86904 - m-ou-se:prelude-collision-check-trait, r=nikomatsakisbors-0/+1
Check FromIterator trait impl in prelude collision check. Fixes #86902.
2021-07-08Stop generating `alloca`s+`memcmp` for simple array equalityScott McMurray-0/+1
2021-07-08Inline implementation of lookup_lineTomasz Miąsko-25/+16
to simplify the implementation and avoid unnecessary conversions from `Option<usize>` to `isize` and back.
2021-07-08Rollup merge of #86726 - ↵Guillaume Gomez-3/+2
sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r=nikomatsakis Use diagnostic items instead of lang items for rfc2229 migrations This PR removes the `Send`, `UnwindSafe` and `RefUnwindSafe` lang items introduced in https://github.com/rust-lang/rust/pull/84730, and uses diagnostic items instead to check for `Send`, `UnwindSafe` and `RefUnwindSafe` traits for RFC2229 migrations. r? ```@nikomatsakis```
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-19/+65
2021-07-07Implement cfg(target_abi) (RFC 2992)Josh Triplett-0/+2
Add an `abi` field to `TargetOptions`, defaulting to "". Support using `cfg(target_abi = "...")` for conditional compilation on that field. Gated by `feature(cfg_target_abi)`. Add a test for `target_abi`, and a test for the feature gate. Add `target_abi` to tidy as a platform-specific cfg. This does not add an abi to any existing target.
2021-07-07Check FromIterator trait impl in prelude collision check.Mara Bos-0/+1
2021-07-06Auto merge of #86143 - bjorn3:revert_revert_merge_crate_disambiguator, ↵bors-45/+32
r=michaelwoerister Reland "Merge CrateDisambiguator into StableCrateId" Reverts https://github.com/rust-lang/rust/pull/85891 as this revert of #85804 made perf even worse. r? `@Mark-Simulacrum`
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-45/+32
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-07-06Store macro parent module in ExpnData.Camille GILLOT-2/+10
2021-07-01Avoid byte to char position conversions in is_multilineTomasz Miąsko-3/+7
Converting a byte position into a char position is currently linear in the number of multibyte characters in the source code. Avoid it when checking if a range spans across lines. This makes it feasible to compile source files with a large number of multibyte characters.
2021-06-29Remove lang items Send, UnwindSafe and RefUnwindSafeRoxane Fruytier-3/+2
2021-06-23Auto merge of #86386 - ↵bors-0/+1
inquisitivecrystal:better-errors-for-display-traits-v3, r=estebank Better errors for Debug and Display traits Currently, if someone tries to pass value that does not implement `Debug` or `Display` to a formatting macro, they get a very verbose and confusing error message. This PR changes the error messages for missing `Debug` and `Display` impls to be less overwhelming in this case, as suggested by #85844. I was a little less aggressive in changing the error message than that issue proposed. Still, this implementation would be enough to reduce the number of messages to be much more manageable. After this PR, information on the cause of an error involving a `Debug` or `Display` implementation would suppressed if the requirement originated within a standard library macro. My reasoning was that errors originating from within a macro are confusing when they mention details that the programmer can't see, and this is particularly problematic for `Debug` and `Display`, which are most often used via macros. It is possible that either a broader or a narrower criterion would be better. I'm quite open to any feedback. Fixes #85844.
2021-06-22Auto merge of #86368 - michaelwoerister:lexing-ice, r=davidtwcobors-10/+31
Disambiguate between SourceFiles from different crates even if they have the same path This PR fixes an ICE that can occur when the compiler encounters a source file that is part of both the local crate and an upstream crate: 1. While importing source files from an upstream crate the compiler creates a `SourceFile` entry for `foo.rs` in the `SourceMap`. Since this is an imported source file its `src` field is `None`. 2. At a later point the parser encounters `foo.rs` again. It tells the `SourceMap` to load the file but because we already have an entry for `foo.rs` the `SourceMap` will return the existing version with `src == None`. 3. The parser proceeds under the assumption that `src.is_some()` and panics when actually trying to use the file's contents. This PR fixes the issue by adding the source file's associated `CrateNum` to the `SourceMap`'s interning key. As a consequence the two instances of the file will each have a separate entry in the `SourceMap`. They just happen to share the same file path. This approach seemed less problematic to me than trying to mutate the `SourceFile` after it had already been created. Another, more involved, approach might be to merge the `src` and the `external_src` field. Fixes #85955
2021-06-22Auto merge of #85707 - jam1garner:future_prelude_collision_lint, r=nikomatsakisbors-0/+3
Add `future_prelude_collision` lint Implements #84594. (RFC rust-lang/rfcs#3114 ([rendered](https://github.com/rust-lang/rfcs/blob/master/text/3114-prelude-2021.md))) Not entirely complete but wanted to have my progress decently available while I finish off the last little bits. Things left to implement: * [x] UI tests for lints * [x] Only emit lint for 2015 and 2018 editions * [ ] Lint name/message bikeshedding * [x] Implement for `FromIterator` (from best I can tell, the current approach as mentioned from [this comment](https://github.com/rust-lang/rust/issues/84594#issuecomment-847288288) won't work due to `FromIterator` instances not using dot-call syntax, but if I'm correct about this then that would also need to be fixed for `TryFrom`/`TryInto`)* * [x] Add to `rust-2021-migration` group? (See #85512) (added to `rust-2021-compatibility` group) * [ ] Link to edition guide in lint docs *edit: looked into it, `lookup_method` will also not be hit for `TryFrom`/`TryInto` for non-dotcall syntax. If anyone who is more familiar with typecheck knows the equivalent for looking up associated functions, feel free to chime in.
2021-06-21Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3bors-0/+2
Add MIR pass to lower call to `core::slice::len` into `Len` operand During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator. It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how. Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
2021-06-21Encode SourceFile source crate as StableCrateId in incr. comp. OnDiskCache.Michael Woerister-2/+2
2021-06-21Disambiguate between SourceFiles from different crates even if they have the ↵Michael Woerister-10/+31
same path.
2021-06-20Squashed implementation of the passAlex Vlasov-0/+2
2021-06-17Make `s` pre-internedYuki Okushi-0/+1
2021-06-16Improve errors for missing Debug and Display implsAris Merchant-0/+1
2021-06-15Rollup merge of #85608 - scottmcm:stabilize-control-flow-enum-basics, r=m-ou-seYuki Okushi-1/+0
Stabilize `ops::ControlFlow` (just the type) Tracking issue: https://github.com/rust-lang/rust/issues/75744 (which also tracks items *not* closed by this PR). With the new `?` desugar implemented, [it's no longer possible to mix `Result` and `ControlFlow`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=13feec97f5c96a9d791d97f7de2d49a6). (At the time of making this PR, godbolt was still on the 2021-05-01 nightly, where you can see that [the mixing example compiled](https://rust.godbolt.org/z/13Ke54j16).) That resolves the only blocker I know of, so I'd like to propose that `ControlFlow` be considered for stabilization. Its basic existence was part of https://github.com/rust-lang/rfcs/pull/3058, where it got a bunch of positive comments (examples [1](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-758277325) [2](https://github.com/rust-lang/rfcs/pull/3058#pullrequestreview-592106494) [3](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-784444155) [4](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-797031584)). Its use in the compiler has been well received (https://github.com/rust-lang/rust/pull/78182#issuecomment-713695594), and there are ecosystem updates interested in using it (https://github.com/rust-itertools/itertools/issues/469#issuecomment-677729589, https://github.com/jonhoo/rust-imap/issues/194). As this will need an FCP, picking a libs member manually: r? `@m-ou-se` ## Stabilized APIs ```rust #[derive(Debug, Clone, Copy, PartialEq)] pub enum ControlFlow<B, C = ()> { /// Exit the operation without running subsequent phases. Break(B), /// Move on to the next phase of the operation as normal. Continue(C), } ``` As well as using `?` on a `ControlFlow<B, _>` in a function returning `ControlFlow<B, _>`. (Note, in particular, that there's no `From::from`-conversion on the `Break` value, the way there is for `Err`s.) ## Existing APIs *not* stabilized here All the associated methods and constants: `break_value`, `is_continue`, `map_break`, [`CONTINUE`](https://doc.rust-lang.org/nightly/std/ops/enum.ControlFlow.html#associatedconstant.CONTINUE), etc. Some of the existing methods in nightly seem reasonable, some seem like they should be removed, and some need more discussion to decide. But none of them are *essential*, so [as in the RFC](https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#methods-on-controlflow), they're all omitted from this PR. They can be considered separately later, as further usage demonstrates which are important.
2021-06-14Add support for associated functions to `future_prelude_collision` lintjam1garner-0/+1
2021-06-14Add future_prelude_collision lintjam1garner-0/+2