about summary refs log tree commit diff
path: root/compiler/rustc_span
AgeCommit message (Collapse)AuthorLines
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.
2020-12-14Switch to Symbol for item.nameJoshua Nelson-0/+4
This decreases the size of `Item` from 680 to 616 bytes. It also does a lot less work since it no longer has to copy as much.
2020-12-10Use Symbol for inline asm register class namesArlie Davis-0/+23
This takes care of one "FIXME": // FIXME: use direct symbol comparison for register class names Instead of using string literals, this uses Symbol for register class names.
2020-12-09Accept arbitrary expressions in key-value attributes at parse timeVadim Petrochenkov-0/+1
2020-12-03rustc_span: add span_data_to_lines_and_cols to caching source map viewTyson Nottingham-39/+195
Gives a performance increase over calling byte_pos_to_line_and_col twice, partially because it decreases the function calling overhead, potentially because it doesn't populate the line cache with lines that turn out to belong to invalid spans, and likely because of some other incidental improvements made possible by having more context available.
2020-12-03rustc_span: refactor byte_pos_to_line_and_colTyson Nottingham-28/+31
2020-12-03rustc_span: avoid unnecessary cloning in byte_pos_to_line_and_colTyson Nottingham-2/+2
2020-12-04Rollup merge of #79678 - jyn514:THE-PAPERCLIP-COMETH, r=varkorDylan DPC-18/+11
Fix some clippy lints Happy to revert these if you think they're less readable, but personally I like them better now (especially the `else { if { ... } }` to `else if { ... }` change).
2020-12-03Fix some clippy lintsJoshua Nelson-18/+11
2020-12-01add const_allocate intrisicVishnunarayan K I-0/+1
2020-11-29Rollup merge of #79464 - GuillaumeGomez:doc-keyword-ident, r=jyn514Dylan DPC-5/+0
Extend doc keyword feature by allowing any ident Part of #51315. As suggested by ``@danielhenrymantilla`` in [this comment](https://github.com/rust-lang/rust/issues/51315#issuecomment-733879934), this PR extends `#[doc(keyword = "...")]` to allow any ident to be used as keyword. The final goal is to allow (proc-)macro crates' owners to write documentation of the keywords they might introduce. r? ``@jyn514``
2020-11-27Remove unused is_doc_keyword functionGuillaume Gomez-5/+0
2020-11-26Rollup merge of #79000 - sivadeilra:user/ardavis/lev_distance, r=wesleywiserJonas Schievink-0/+161
Move lev_distance to rustc_ast, make non-generic rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST would not have any dependency its lexer, for minimizing design-time dependencies. Breaking this dependency would also have practical benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast. This commit does not remove the rustc_ast --> rustc_lexer dependency, but it does remove one of the sources of this dependency, which is the code that handles fuzzy matching between symbol names for making suggestions in diagnostics. Since that code depends only on Symbol, it is easy to move it to rustc_span. It might even be best to move it to a separate crate, since other tools such as Cargo use the same algorithm, and have simply contain a duplicate of the code. This changes the signature of find_best_match_for_name so that it is no longer generic over its input. I checked the optimized binaries, and this function was duplicated for nearly every call site, because most call sites used short-lived iterator chains, generic over Map and such. But there's no good reason for a function like this to be generic, since all it does is immediately convert the generic input (the Iterator impl) to a concrete Vec<Symbol>. This has all of the costs of generics (duplicated method bodies) with no benefit. Changing find_best_match_for_name to be non-generic removed about 10KB of code from the optimized binary. I know it's a drop in the bucket, but we have to start reducing binary size, and beginning to tame over-use of generics is part of that.
2020-11-24Move lev_distance to rustc_ast, make non-genericArlie Davis-0/+161
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST would not have any dependency its lexer, for minimizing unnecessarily design-time dependencies. Breaking this dependency would also have practical benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast. This commit does not remove the rustc_ast --> rustc_lexer dependency, but it does remove one of the sources of this dependency, which is the code that handles fuzzy matching between symbol names for making suggestions in diagnostics. Since that code depends only on Symbol, it is easy to move it to rustc_span. It might even be best to move it to a separate crate, since other tools such as Cargo use the same algorithm, and have simply contain a duplicate of the code. This changes the signature of find_best_match_for_name so that it is no longer generic over its input. I checked the optimized binaries, and this function was duplicated at nearly every call site, because most call sites used short-lived iterator chains, generic over Map and such. But there's no good reason for a function like this to be generic, since all it does is immediately convert the generic input (the Iterator impl) to a concrete Vec<Symbol>. This has all of the costs of generics (duplicated method bodies) with no benefit. Changing find_best_match_for_name to be non-generic removed about 10KB of code from the optimized binary. I know it's a drop in the bucket, but we have to start reducing binary size, and beginning to tame over-use of generics is part of that.
2020-11-23Rename `optin_builtin_traits` to `auto_traits`Camelid-0/+1
They were originally called "opt-in, built-in traits" (OIBITs), but people realized that the name was too confusing and a mouthful, and so they were renamed to just "auto traits". The feature flag's name wasn't updated, though, so that's what this PR does. There are some other spots in the compiler that still refer to OIBITs, but I don't think changing those now is worth it since they are internal and not particularly relevant to this PR. Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
2020-10-19Also apply panic_fmt lint suggestions to debug_assert!().Mara Bos-0/+1
2020-10-18Expand assert!(expr) to panic() function instead of panic!() macro.Mara Bos-0/+1
The panic message might contain braces which should never be interpreted as format placeholders, which panic!() will do in a future edition.