about summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
2021-02-04add `relaxed_struct_unsize` feature gateBastian Kauschke-0/+1
2021-02-03Auto merge of #81294 - pnkfelix:issue-81211-use-ufcs-in-derive-debug, r=oli-obkbors-0/+2
Use ufcs in derive(Debug) Cc #81211. (Arguably this *is* the fix for it.)
2021-02-03Auto merge of #81346 - hug-dev:nonsecure-call-abi, r=jonas-schievinkbors-0/+1
Add a new ABI to support cmse_nonsecure_call This adds support for the `cmse_nonsecure_call` feature to be able to perform non-secure function call. See the discussion on Zulip [here](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Support.20for.20callsite.20attributes/near/223054928). This is a followup to #75810 which added `cmse_nonsecure_entry`. As for that PR, I assume that the changes are small enough to not have to go through a RFC but I don't mind doing one if needed 😃 I did not yet create a tracking issue, but if most of it is fine, I can create one and update the various files accordingly (they refer to the other tracking issue now). On the Zulip chat, I believe `@jonas-schievink` volunteered to be a reviewer 💯
2021-02-02Let a portion of DefPathHash uniquely identify the DefPath's crate.Michael Woerister-0/+118
This allows to directly map from a DefPathHash to the crate it originates from, without constructing side tables to do that mapping. It also allows to reliably and cheaply check for DefPathHash collisions.
2021-02-02Add a new ABI to support cmse_nonsecure_callHugues de Valon-0/+1
This commit adds a new ABI to be selected via `extern "C-cmse-nonsecure-call"` on function pointers in order for the compiler to apply the corresponding cmse_nonsecure_call callsite attribute. For Armv8-M targets supporting TrustZone-M, this will perform a non-secure function call by saving, clearing and calling a non-secure function pointer using the BLXNS instruction. See the page on the unstable book for details. Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2021-02-02Rollup merge of #81608 - Aaron1011:macro-res-parse-err, r=davidtwcoJonas Schievink-0/+3
Improve handling of spans around macro result parse errors Fixes #81543 After we expand a macro, we try to parse the resulting tokens as a AST node. This commit makes several improvements to how we handle spans when an error occurs: * Only ovewrite the original `Span` if it's a dummy span. This preserves a more-specific span if one is available. * Use `self.prev_token` instead of `self.token` when emitting an error message after encountering EOF, since an EOF token always has a dummy span * Make `SourceMap::next_point` leave dummy spans unused. A dummy span does not have a logical 'next point', since it's a zero-length span. Re-using the span span preserves its 'dummy-ness' for other checks
2021-02-01Use UFCS instead of method calls in `derive(Debug)`. See issue 81211 for ↵Felix S. Klock II-0/+2
discussion.
2021-02-01Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkovbors-0/+6
Implement Rust 2021 panic This implements the Rust 2021 versions of `panic!()`. See https://github.com/rust-lang/rust/issues/80162 and https://github.com/rust-lang/rfcs/pull/3007. It does so by replacing `{std, core}::panic!()` by a bulitin macro that expands to either `$crate::panic::panic_2015!(..)` or `$crate::panic::panic_2021!(..)` depending on the edition of the caller. This does not yet make std's panic an alias for core's panic on Rust 2021 as the RFC proposes. That will be a separate change: https://github.com/rust-lang/rust/pull/80879/commits/c5273bdfb266c35e8eab9413aa8d58d27fdbe114 That change is blocked on figuring out what to do with https://github.com/rust-lang/rust/issues/80846 first.
2021-01-31Improve handling of spans around macro result parse errorsAaron Hill-0/+3
Fixes #81543 After we expand a macro, we try to parse the resulting tokens as a AST node. This commit makes several improvements to how we handle spans when an error occurs: * Only ovewrite the original `Span` if it's a dummy span. This preserves a more-specific span if one is available. * Use `self.prev_token` instead of `self.token` when emitting an error message after encountering EOF, since an EOF token always has a dummy span * Make `SourceMap::next_point` leave dummy spans unused. A dummy span does not have a logical 'next point', since it's a zero-length span. Re-using the span span preserves its 'dummy-ness' for other checks
2021-01-28Rollup merge of #81277 - flip1995:from_diag_items, r=matthewjasperYuki Okushi-0/+3
Make more traits of the From/Into family diagnostic items Following traits are now diagnostic items: - `From` (unchanged) - `Into` - `TryFrom` - `TryInto` This also adds symbols for those items: - `into_trait` - `try_from_trait` - `try_into_trait` Related: https://github.com/rust-lang/rust-clippy/pull/6620#discussion_r562482587
2021-01-25Implement new panic!() behaviour for Rust 2021.Mara Bos-0/+6
2021-01-23Add disambiugator to ExpnDataAaron Hill-14/+165
Due to macro expansion, its possible to end up with two distinct `ExpnId`s that have the same `ExpnData` contents. This violates the contract of `HashStable`, since two unequal `ExpnId`s will end up with equal `Fingerprint`s. This commit adds a `disambiguator` field to `ExpnData`, which is used to force two otherwise-equivalent `ExpnData`s to be distinct.
2021-01-22Make more traits of the From/Into family diagnostic itemsflip1995-0/+3
Following traits are now diagnostic items: - `From` (unchanged) - `Into` - `TryFrom` - `TryInto` This also adds symbols for those items: - `into_trait` - `try_from_trait` - `try_into_trait`
2021-01-17Feature-gate `pointer` and `reference` in intra-doc linksJoshua Nelson-0/+1
- Only feature gate associated items - Add docs to unstable book
2021-01-16Auto merge of #80290 - RalfJung:less-intrinsic-write, r=lcnrbors-1/+0
implement ptr::write without dedicated intrinsic This makes `ptr::write` more consistent with `ptr::write_unaligned`, `ptr::read`, `ptr::read_unaligned`, all of which are implemented in terms of `copy_nonoverlapping`. This means we can also remove `move_val_init` implementations in codegen and Miri, and its special handling in the borrow checker. Also see [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/ptr.3A.3Aread.20vs.20ptr.3A.3Awrite).
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-3/+3
2021-01-13Auto merge of #80654 - Aaron1011:fix/dummy-span-ctxt, r=wesleywiserbors-1/+2
Properly handle `SyntaxContext` of dummy spans in incr comp Fixes #80336 Due to macro expansion, we may end up with spans with an invalid location and non-root `SyntaxContext`. This commits preserves the `SyntaxContext` of such spans in the incremental cache, and ensures that we always hash the `SyntaxContext` when computing the `Fingerprint` of a `Span` Previously, we would discard the `SyntaxContext` during serialization to the incremental cache, causing the span's `Fingerprint` to change across compilation sessions.
2021-01-13Auto merge of #77524 - Patryk27:fixes/66228, r=estebankbors-5/+24
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924) This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13Properly handle `SyntaxContext` of dummy spans in incr compAaron Hill-1/+2
Fixes #80336 Due to macro expansion, we may end up with spans with an invalid location and non-root `SyntaxContext`. This commits preserves the `SyntaxContext` of such spans in the incremental cache, and ensures that we always hash the `SyntaxContext` when computing the `Fingerprint` of a `Span` Previously, we would discard the `SyntaxContext` during serialization to the incremental cache, causing the span's `Fingerprint` to change across compilation sessions.
2021-01-13Rollup merge of #80859 - jsgf:fix-pretty-remap, r=davidtwcoDylan DPC-1/+14
Fix --pretty=expanded with --remap-path-prefix Per https://github.com/rust-lang/rust/issues/80832, using --pretty=expanded and --remap-path-prefix results in an ICE. This is becasue the session source files table is stored in remapped form, whereas --pretty-expanded looks up unremapped files. This remaps the path prefixes before lookup. ~~There don't appear to be any existing tests for --pretty=expanded; I'll look into adding some.~~ Never mind, found the pretty tests. Fixes #80832
2021-01-12Auto merge of #80499 - matthiaskrgr:red_clos, r=estebankbors-2/+2
remove redundant closures (clippy::redundant_closure)
2021-01-11Auto merge of #79012 - tgnottingham:span_data_to_lines_and_cols, r=estebankbors-55/+214
rustc_span: add span_data_to_lines_and_cols to caching source map view
2021-01-10Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasperbors-1/+9
resolve: Scope visiting doesn't need an `Ident` Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part. The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow. I think it's clearer to pass only the necessary part. Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case. r? `@matthewjasper`
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-5/+24
2021-01-09Fix --pretty=expanded with --remap-path-prefixJeremy Fitzhardinge-1/+14
Per https://github.com/rust-lang/rust/issues/80832, using --pretty=expanded and --remap-path-prefix results in an ICE. This is becasue the session source files table is stored in remapped form, whereas --pretty-expanded looks up unremapped files. This remaps the path prefixes before lookup.
2021-01-07Use correct span for structured suggestionEsteban Küber-1/+3
On structured suggestion for `let` -> `const` and `const` -> `let`, use a proper `Span` and update tests to check the correct application. Follow up to #80012.
2021-01-07resolve: Scope visiting doesn't need an `Ident`Vadim Petrochenkov-1/+9
2021-01-07Auto merge of #80648 - Aaron1011:expn-data-private, r=petrochenkovbors-2/+42
Make `ExpnData` fields `krate` and `orig_id` private These fields are only used by hygiene serialized, and should not be accessed by anything outside of `rustc_span`.
2021-01-03Make `ExpnData` fields `krate` and `orig_id` privateAaron Hill-2/+42
These fields are only used by hygiene serialized, and should not be accessed by anything outside of `rustc_span`.
2021-01-03remove redundant closures (clippy::redundant_closure)Matthias Krüger-2/+2
2021-01-01Allow references to interior mutable data behind a feature gateoli-0/+1
2021-01-01first pass at default values for const genericsJulian Knodt-0/+1
- Adds optional default values to const generic parameters in the AST and HIR - Parses these optional default values - Adds a `const_generics_defaults` feature gate
2020-12-31Add edition 2021.Mara Bos-2/+18
2020-12-31Auto merge of #80459 - mark-i-m:or-pat-reg, r=petrochenkovbors-0/+3
Implement edition-based macro :pat feature This PR does two things: 1. Fixes the perf regression from https://github.com/rust-lang/rust/pull/80100#issuecomment-750893149 2. Implements `:pat2018` and `:pat2021` matchers, as described by `@joshtriplett` in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090 behind the feature gate `edition_macro_pat`. r? `@petrochenkov` cc `@Mark-Simulacrum`
2020-12-31remove move_val_init leftoversRalf Jung-1/+0
2020-12-30Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkovMara Bos-6/+6
Rename kw::Invalid -> kw::Empty See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context. r? `@petrochenkov`
2020-12-30#[doc(inline)] sym_generatedLeSeulArtichaut-0/+1
2020-12-30Implement edition-based macro pat featuremark-0/+3
2020-12-30Rename kw::Invalid -> kw::EmptyJoshua Nelson-6/+6
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context.
2020-12-30Rollup merge of #80358 - pierwill:edit_rustc_span, r=lcnrYuki Okushi-46/+71
Edit rustc_span documentation Various changes to the `rustc_span` docs, including the following: - Additions to top-level docs - Edits to the source_map module docs - Edits to documentation for `Span` and `SpanData` - Added intra-docs links - Documentation for Levenshtein distances - Fixed missing punctuation
2020-12-27rustc_span: Remove `Symbol::with`Vadim Petrochenkov-9/+3
2020-12-25Edit rustc_span documentationpierwill-46/+71
Various changes to the `rustc_span` docs, including the following: - Additions to top-level docs - Edits to the source_map module docs - Edits to documentation for `Span` and `SpanData` - Added intra-docs links - Documentation for Levenshtein distances - Fixed missing punctuation
2020-12-25Auto merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinembors-1/+1
Remap instrument-coverage line numbers in doctests This uses the `SourceMap::doctest_offset_line` method to re-map line numbers from doctests. Remapping columns is not yet done, and rustdoc still does not output the correct filename when running doctests in a workspace. Part of #79417 although I dont consider that fixed until both filenames and columns are mapped correctly. r? `@richkadel` I might jump on zulip the comming days. Still need to figure out how to properly write tests for this, and deal with other doctest issues in the meantime.
2020-12-23Rollup merge of #80297 - jyn514:more-docs, r=bjorn3Guillaume Gomez-1/+1
Add some intra-doc links to compiler docs r? `@pierwill`
2020-12-22Add some intra-doc links to compiler docsJoshua Nelson-1/+1
2020-12-21rustc_span: Provide a reserved identifier check for a specific editionVadim Petrochenkov-11/+32
Edition evaluation is kept lazy because it may be expensive.
2020-12-19Remap instrument-coverage line numbers in doctestsArpad Borsos-1/+1
This uses the `SourceMap::doctest_offset_line` method to re-map line numbers from doctests. Remapping columns is not yet done. Part of issue #79417.
2020-12-18Rollup merge of #80130 - pierwill:patch-7, r=oli-obkRalf Jung-1/+1
docs: Edit rustc_span::symbol::Symbol method Edit wording of the doc comment for [rustc_span::symbol::Symbol::can_be_raw](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/symbol/struct.Symbol.html#method.can_be_raw) to match related methods.
2020-12-17Stop using intermediate macros in definition of symbolsArlie Davis-8/+8
Currently, the rustc_macros::symbols macro generates two `macro_rules!` macros as its output. These two macros are used in rustc_span/src/symbol.rs. This means that each Symbol that we define is represented in the AST of rustc_symbols twice: once in the definition of the `define_symbols!` macro (similarly for the `keywords! macro), and once in the rustc_span::symbols definition. That would be OK if there were only a handful of symbols, but currently we define over 1100 symbols. The definition of the `define_symbols!` macro contains the expanded definition of each symbol, so that's a lot of AST storage wasted on a macro that is used exactly once. This commit removes the `define_symbols` macro, and simply allows the proc macro to directly generate the `rustc_symbols::symbol::sym` module. The benefit is mainly in reducing memory wasted during compilation of rustc itself. It should also reduce memory used by Rust Analyzer. This commit also reduces the size of the AST for symbol definitions, by moving two `#[allow(...)]` attributes from the symbol constants to the `sym` module. This eliminates 2200+ attribute nodes. This commit also eliminates the need for the `digits_array` constant. There's no need to store an array of Symbol values for digits. We can simply define a constant of the base value, and add to that base value.
2020-12-17docs: Edit rustc_span::symbol::Symbol methodpierwill-1/+1
Edit wording of the doc comment for rustc_span::symbol::Symbol::can_be_raw to match related methods.