about summary refs log tree commit diff
path: root/compiler/rustc_span
AgeCommit message (Collapse)AuthorLines
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-24rustc_span: Explicitly handle crates that differ from package namesJosh Triplett-2/+2
The sha-1 and md-5 packages contain crates named sha1 and md5, respectively. This discrepancy makes it somewhat more challenging to automate detection of unused crates. Explicitly rename the packages to the names of the crates they contain, to simplify such detection.
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
2021-06-12Auto merge of #86180 - cjgillot:defmv, r=petrochenkovbors-13/+48
Hash DefId in rustc_span. This is mostly just moving code around. Changes are simplifications of unneeded callbacks from rustc_span to rustc_middle. r? `@petrochenkov`
2021-06-12Rollup merge of #86153 - tmiasko:dummy-span, r=estebankYuki Okushi-1/+1
Print dummy spans as `no-location` Fixes #58808.
2021-06-11Make DummyHashStableContext dummier.Camille GILLOT-5/+5
2021-06-11Sprinkle inline.Camille GILLOT-5/+6
2021-06-11Hash DefId in rustc_span.Camille GILLOT-13/+47
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-0/+1
position.
2021-06-09Print dummy spans as `no-location`Tomasz Miąsko-1/+1
2021-06-07Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkorbors-39/+41
Remove unused functions and arguments from rustc_serialize
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-32/+45
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-06Auto merge of #79608 - alessandrod:bpf, r=nagisabors-0/+2
BPF target support This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker. I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.
2021-06-04Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514Yuki Okushi-2/+0
Remove unused feature gates The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`) The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though. The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-02Miscellaneous inlining improvementsTomasz Miąsko-0/+2
2021-06-01Auto merge of #85829 - bjorn3:simplify_crate_num, r=jackh726bors-60/+4
Remove CrateNum::ReservedForIncrCompCache It's only use is easily replaceable with `Option<CrateNum>`.
2021-06-01Remove unused functions and arguments from rustc_serializebjorn3-39/+41
2021-05-31Remove unused feature gatesbjorn3-1/+0
2021-05-31Use allow_internal_unstable more in rustc_indexbjorn3-1/+0
2021-05-30Remove CrateNum::ReservedForIncrCompCachebjorn3-60/+4
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-45/+32
2021-05-26Specialize implementationsJacob Pratt-0/+1
Implementations in stdlib are now optimized as they were before.
2021-05-23Stabilize ops::ControlFlow (just the type)Scott McMurray-1/+0
2021-05-23Add support for BPF inline assemblyAlessandro Decina-0/+2
2021-05-20Rollup merge of #85439 - mgacek8:add_diagnostic_item_to_CStr_type, r=davidtwcoRalf Jung-0/+1
Add diagnostic item to `CStr` Required for clippy issue: https://github.com/rust-lang/rust-clippy/issues/7145
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-5/+8
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-18Add diagnostic item to `CStr`Mateusz Gacek-0/+1
2021-05-17Auto merge of #84571 - jedel1043:issue-49804-impl, r=petrochenkovbors-0/+1
Parse unnamed fields of struct and union type Added the `unnamed_fields` feature gate. This is a prototype of [RFC 2102](https://github.com/rust-lang/rust/issues/49804), so any suggestions are greatly appreciated. r? `@petrochenkov`
2021-05-16Implement Anonymous{Struct, Union} in the ASTjedel1043-0/+1
Add unnamed_fields feature gate and gate unnamed fields on parsing
2021-05-16Allow `async {}` expressions in const contextsJonas Schievink-0/+1
2021-05-14add new attribute rustc_insignificant_dtor and a query to check if a type ↵Dhruv Jauhar-0/+1
has a significant drop
2021-05-13Auto merge of #85186 - nikomatsakis:issue-83538-polluted-cache, r=jackh726bors-0/+1
have on_completion record subcycles have on_completion record subcycles Rework `on_completion` method so that it removes all provisional cache entries that are "below" a completed node (while leaving those entries that are not below the node). This corrects an imprecise result that could in turn lead to an incremental compilation failure. Under the old scheme, if you had: * A depends on... * B depends on A * C depends on... * D depends on C * T: 'static then the provisional results for A, B, C, and D would all be entangled. Thus, if A was `EvaluatedToOkModuloRegions` (because of that final condition), then the result for C and D would also be demoted to "ok modulo regions". In reality, though, the result for C depends only on C and itself, and is not dependent on regions. If we happen to evaluate the cycle starting from C, we would never reach A, and hence the result would be "ok". Under the new scheme, the provisional results for C and D are moved to the permanent cache immediately and are not affected by the result of A. Fixes #83538 r? `@Aaron1011`
2021-05-13Auto merge of #85110 - RalfJung:no-rustc_args_required_const, r=oli-obkbors-1/+0
Remove rustc_args_required_const attribute Now that stdarch no longer needs it (thanks `@Amanieu!),` we can kill the `rustc_args_required_const` attribute. This means that lifetime extension of references to temporaries is the only remaining job that promotion is performing. :-) r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/69493
2021-05-13introduce a unit testing feature `rustc_evaluate_where_clauses`Niko Matsakis-0/+1
This attribute will cause us to invoke evaluate on every where clause of an invoked function and to generate an error with the result. Without this, it is very difficult to observe the effects of invoking the trait evaluator.
2021-05-13Auto merge of #84732 - DrChat:asm_powerpc, r=Amanieubors-0/+1
Add asm!() support for PowerPC This includes GPRs and FPRs only. Note that this does not include PowerPC64. For my reference, this was mostly duplicated from PR #73214.
2021-05-12entirely remove rustc_args_required_const attributeRalf Jung-1/+0
2021-05-12Auto merge of #84730 - sexxi-goose:rox-auto-trait, r=nikomatsakisbors-0/+3
Add auto traits and clone trait migrations for RFC2229 This PR - renames the existent RFC2229 migration `disjoint_capture_drop_reorder` to `disjoint_capture_migration` - add additional migrations for auto traits and clone trait Closes rust-lang/project-rfc-2229#29 Closes rust-lang/project-rfc-2229#28 r? `@nikomatsakis`
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-127/+165
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation