about summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
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
2021-05-12Implement span quoting for proc-macrosAaron Hill-4/+16
This PR implements span quoting, allowing proc-macros to produce spans pointing *into their own crate*. This is used by the unstable `proc_macro::quote!` macro, allowing us to get error messages like this: ``` error[E0412]: cannot find type `MissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:37:20 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]` ... LL | field: MissingType | ^^^^^^^^^^^ not found in this scope | ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] | ----------------------- in this macro invocation ``` Here, `MissingType` occurs inside the implementation of the proc-macro `#[error_from_attribute]`. Previosuly, this would always result in a span pointing at `#[error_from_attribute]` This will make many proc-macro-related error message much more useful - when a proc-macro generates code containing an error, users will get an error message pointing directly at that code (within the macro definition), instead of always getting a span pointing at the macro invocation site. This is implemented as follows: * When a proc-macro crate is being *compiled*, it causes the `quote!` macro to get run. This saves all of the sapns in the input to `quote!` into the metadata of *the proc-macro-crate* (which we are currently compiling). The `quote!` macro then expands to a call to `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an opaque identifier for the span in the crate metadata. * When the same proc-macro crate is *run* (e.g. it is loaded from disk and invoked by some consumer crate), the call to `proc_macro::Span::recover_proc_macro_span` causes us to load the span from the proc-macro crate's metadata. The proc-macro then produces a `TokenStream` containing a `Span` pointing into the proc-macro crate itself. The recursive nature of 'quote!' can be difficult to understand at first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows the output of the `quote!` macro, which should make this eaier to understand. This PR also supports custom quoting spans in custom quote macros (e.g. the `quote` crate). All span quoting goes through the `proc_macro::quote_span` method, which can be called by a custom quote macro to perform span quoting. An example of this usage is provided in `src/test/ui/proc-macro/auxiliary/custom-quote.rs` Custom quoting currently has a few limitations: In order to quote a span, we need to generate a call to `proc_macro::Span::recover_proc_macro_span`. However, proc-macros support renaming the `proc_macro` crate, so we can't simply hardcode this path. Previously, the `quote_span` method used the path `crate::Span` - however, this only works when it is called by the builtin `quote!` macro in the same crate. To support being called from arbitrary crates, we need access to the name of the `proc_macro` crate to generate a path. This PR adds an additional argument to `quote_span` to specify the name of the `proc_macro` crate. Howver, this feels kind of hacky, and we may want to change this before stabilizing anything quote-related. Additionally, using `quote_span` currently requires enabling the `proc_macro_internals` feature. The builtin `quote!` macro has an `#[allow_internal_unstable]` attribute, but this won't work for custom quote implementations. This will likely require some additional tricks to apply `allow_internal_unstable` to the span of `proc_macro::Span::recover_proc_macro_span`.
2021-05-11Add initial asm!() support for PowerPCDr. Chat-0/+1
This includes GPRs and FPRs only
2021-05-11Split span_to_string into span_to_diagnostic/embeddable_stringAndy Wang-4/+16
2021-05-08Rollup merge of #85044 - ChrisDenton:file-exists, r=jackh726Dylan DPC-1/+1
Use `path.exists()` instead of `fs::metadata(path).is_ok()` It's more explicit and potentially allows platforms to optimize the existence check.
2021-05-08Rollup merge of #84887 - jyn514:index-span, r=XanewokDylan DPC-6/+1
Remove SpanInterner::get - It's used exactly once, so it's trivial to replace - It doesn't match the normal convention for containers: normally `get()` returns an option and indexing panics. Instead `SpanInterner::get()` panics and there's no indexing operation available.
2021-05-07Use `path.exists()` instead of `fs::metadata(path).is_ok()`Chris Denton-1/+1
It's more explicit and allows platforms to optimize the existence check.
2021-05-06Actually implement the feature in the compilerScott McMurray-5/+8
Including all the bootstrapping tweaks in the library.
2021-05-06Add additional migrations to handle auto-traits and clone traitsRoxane-0/+3
Combine all 2229 migrations under one flag name
2021-05-05Implement RFC 2951: Native link modifiersLuqman Aden-0/+6
This commit implements both the native linking modifiers infrastructure as well as an initial attempt at the individual modifiers from the RFC. It also introduces a feature flag for the general syntax along with individual feature flags for each modifier.
2021-05-05Use local and remapped paths where appropriateAndy Wang-6/+11
2021-05-05Revamp RealFileName public methodsAndy Wang-20/+22
2021-05-05Remove impl Display for FileName and add FileNameDisplay wrapper typeAndy Wang-12/+39
2021-05-05Make local_path in RealFileName::Remapped Option to be removed in exported ↵Andy Wang-31/+70
metadata
2021-05-05Rename RealFileName::Named to LocalPath and Devirtualized to RemappedAndy Wang-91/+44
2021-05-03Remove SpanInterner::getJoshua Nelson-6/+1
- It's used exactly once, so it's trivial to replace - It doesn't match the normal convention for containers: normally `get()` returns and option and indexing panics. Instead `get()` panicked and there's no indexing operation available.