summary refs log tree commit diff
path: root/src/librustc_metadata/rmeta/decoder.rs
AgeCommit message (Collapse)AuthorLines
2020-06-01Split payload of FileName::Real to track both real and virutalized paths.Felix S. Klock II-9/+16
Such splits arise from metadata refs into libstd. This way, we can (in a follow on commit) continue to emit the virtual name into things like the like the StableSourceFileId that ends up in incremetnal build artifacts, while still using the devirtualized file path when we want to access the file. Note that this commit is intended to be a refactoring; the actual fix to the bug in question is in a follow-on commit.
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-2/+5
2020-04-14Rename AssocKind::Method to AssocKind::FnRustin-Liu-2/+2
Rename fn_has_self_argument to fn_has_self_parameter Rename AssocItemKind::Method to AssocItemKind::Fn Refine has_no_input_arg Refine has_no_input_arg Revert has_no_input_arg Refine suggestion_descr Move as_def_kind into AssocKind Signed-off-by: Rustin-Liu <rustin.liu@gmail.com> Fix tidy check issue Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
2020-04-11Auto merge of #70161 - cjgillot:query-arena, r=nikomatsakisbors-15/+13
Allocate some query results on an arena This avoids a cloning few `Lrc` and `Vec`s in the queries.
2020-04-05Remove unneeded Lrc in query results.Camille GILLOT-10/+8
2020-04-05Remove Arcs in queries.Camille GILLOT-3/+3
2020-04-05Allocate query Vecs on the arena.Camille GILLOT-2/+2
2020-04-05Stop importing int/float modules in librustc_*Linus Färnstrand-1/+0
2020-04-03Auto merge of #70642 - eddyb:remap-sysroot-src, r=Mark-Simulacrumbors-9/+52
Translate the virtual `/rustc/$hash` prefix back to a real directory. Closes #53486 and fixes #53081, by undoing the remapping to `/rustc/$hash` on the fly, when appropriate (e.g. our testsuites, or user crates that depend on `libstd`), but not during the Rust build itself (as that could leak the absolute build directory into the artifacts, breaking deterministic builds). Tested locally by setting `remap-debuginfo = true` in `config.toml`, which without these changes, was causing 56 tests to fail (see https://github.com/rust-lang/rust/issues/53081#issuecomment-606703215 for more details). cc @Mark-Simulacrum @alexcrichton @ehuss
2020-04-02Rollup merge of #70634 - Centril:import-directly, r=Mark-SimulacrumMazdak Farrokhzad-1/+1
Remove some reexports in `rustc_middle` This will help get these imports out of the way of detecting the true dependencies in and out to `rustc_middle`, thereby helping future work towards https://github.com/rust-lang/rust/issues/65031.
2020-04-02direct imports for langitem stuffMazdak Farrokhzad-1/+1
2020-04-02Translate the virtual `/rustc/$hash` prefix back to a real directory.Eduard-Mihai Burtescu-9/+52
2020-03-31Renamed `PerDefTables` to `Tables`Valentin Lazureanu-26/+26
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-11/+11
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-11/+11
2020-03-24Rollup merge of #70077 - Aaron1011:feature/new-def-path-ident, r=petrochenkovMazdak Farrokhzad-25/+31
Store idents for `DefPathData` into crate metadata Previously, we threw away the `Span` associated with a definition's identifier when we encoded crate metadata, causing us to lose location and hygiene information. We now store the identifier's `Span` in a side table, which gets encoded into the crate metadata. When we decode items from the metadata, we combine the name and span back into an `Ident`. This improves the output of several tests, which previously had messages suppressed due to dummy spans. This is a prerequisite for #68686, since throwing away a `Span` means that we lose hygiene information.
2020-03-23Fallout in other crates.Camille GILLOT-1/+1
2020-03-22Store idents for `DefPathData` into crate metadataAaron Hill-25/+31
Previously, we threw away the `Span` associated with a definition's identifier when we encoded crate metadata, causing us to lose location and hygiene information. We now store the identifier's `Span` in the crate metadata. When we decode items from the metadata, we combine the name and span back into an `Ident`. This improves the output of several tests, which previously had messages suppressed due to dummy spans. This is a prerequisite for #68686, since throwing away a `Span` means that we lose hygiene information.
2020-03-21{rustc::hir::map -> rustc_hir}::definitionsMazdak Farrokhzad-2/+2
2020-03-19rustc: rename DefId::to_local to expect_local and use it instead of ↵Eduard-Mihai Burtescu-1/+1
LocalDefId::from_def_id.
2020-03-18Properly handle Spans that reference imported SourceFilesAaron Hill-6/+85
Previously, metadata encoding used DUMMY_SP to represent any spans that referenced an 'imported' SourceFile - e.g. a SourceFile from an upstream dependency. These leads to sub-optimal error messages in certain cases (see the included test). This PR changes how we encode and decode spans in crate metadata. We encode spans in one of two ways: * 'Local' spans, which reference non-imported SourceFiles, are encoded exactly as before. * 'Foreign' spans, which reference imported SourceFiles, are encoded with the CrateNum of their 'originating' crate. Additionally, their 'lo' and 'high' values are rebased on top of the 'originating' crate, which allows them to be used with the SourceMap data encoded for that crate. The `ExternalSource` enum is renamed to `ExternalSourceKind`. There is now a struct called `ExternalSource`, which holds an `ExternalSourceKind` along with the original line number information for the file. This is used during `Span` serialization to rebase spans onto their 'owning' crate.
2020-03-18Rollup merge of #69920 - Centril:hir-cleanup, r=ZoxcMazdak Farrokhzad-12/+11
Remove some imports to the rustc crate - When we have `NestedVisitorMap::None`, we use `type Map = dyn intravisit::Map<'v>;` instead of the actual map. This doesn't actually result in dynamic dispatch (in the future we may want to use an associated type default to simplify the code). - Use `rustc_session::` imports instead of `rustc::{session, lint}`. r? @Zoxc
2020-03-16Auto merge of #68970 - matthewjasper:min-spec, r=nikomatsakisbors-0/+2
Implement a feature for a sound specialization subset This implements a new feature (`min_specialization`) that restricts specialization to a subset that is reasonable for the standard library to use. The plan is to then: * Update `libcore` and `liballoc` to compile with `min_specialization`. * Add a lint to forbid use of `feature(specialization)` (and other unsound, type system extending features) in the standard library. * Fix the soundness issues around `specialization`. * Remove `min_specialization` The rest of this is an overview from a comment in this PR ## Basic approach To enforce this requirement on specializations we take the following approach: 1. Match up the substs for `impl2` so that the implemented trait and self-type match those for `impl1`. 2. Check for any direct use of `'static` in the substs of `impl2`. 3. Check that all of the generic parameters of `impl1` occur at most once in the *unconstrained* substs for `impl2`. A parameter is constrained if its value is completely determined by an associated type projection predicate. 4. Check that all predicates on `impl1` also exist on `impl2` (after matching substs). ## Example Suppose we have the following always applicable impl: ```rust impl<T> SpecExtend<T> for std::vec::IntoIter<T> { /* specialized impl */ } impl<T, I: Iterator<Item=T>> SpecExtend<T> for I { /* default impl */ } ``` We get that the subst for `impl2` are `[T, std::vec::IntoIter<T>]`. `T` is constrained to be `<I as Iterator>::Item`, so we check only `std::vec::IntoIter<T>` for repeated parameters, which it doesn't have. The predicates of `impl1` are only `T: Sized`, which is also a predicate of impl2`. So this specialization is sound. ## Extensions Unfortunately not all specializations in the standard library are allowed by this. So there are two extensions to these rules that allow specializing on some traits. ### rustc_specialization_trait If a trait is always applicable, then it's sound to specialize on it. We check trait is always applicable in the same way as impls, except that step 4 is now "all predicates on `impl1` are always applicable". We require that `specialization` or `min_specialization` is enabled to implement these traits. ### rustc_specialization_marker There are also some specialization on traits with no methods, including the `FusedIterator` trait which is advertised as allowing optimizations. We allow marking marker traits with an unstable attribute that means we ignore them in point 3 of the checks above. This is unsound but we allow it in the short term because it can't cause use after frees with purely safe code in the same way as specializing on traits methods can. r? @nikomatsakis cc #31844 #67194
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-12/+11
2020-03-15More Method->Fn renamingMark Mansi-5/+5
2020-03-15Add attributes to allow specializing on traitsMatthew Jasper-0/+2
2020-03-14Update `visit_item_likes_in_module`John Kåre Alsaker-2/+3
2020-03-12Rollup merge of #69674 - mark-i-m:assoc-fn, r=matthewjasperMazdak Farrokhzad-1/+1
Rename DefKind::Method and TraitItemKind::Method r? @eddyb, @Centril, or @matthewjasper cc #69498 #60163
2020-03-10Auto merge of #66364 - Centril:cleanup-macro-def, r=petrochenkov,eddybbors-2/+2
Cleanup `rmeta::MacroDef` Avoid using rountrip parsing in the encoder and in `fn load_macro_untracked`. The main reason I was interested in this was to remove `rustc_parse` as a dependency of `rustc_metadata` but it seems like this had other benefits as well. Fixes #49511. r? @eddyb cc @matthewjasper @estebank @petrochenkov
2020-03-10Store `TokenStream` in `rmeta::MacroDef`.Mazdak Farrokhzad-2/+2
This removes a hack from `load_macro_untracked` in which parsing is used.
2020-03-05rustc_metadata: Move some code from `impl CrateMetadataRef` to `impl ↵Vadim Petrochenkov-89/+87
CrateMetadata`
2020-03-05rustc_metadata: Give decoder access to whole crate storeVadim Petrochenkov-17/+22
2020-03-03DefKind::Method -> DefKind::AssocFnMark Mansi-1/+1
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-1/+1
2020-02-29Make it build againVadim Petrochenkov-1/+1
2020-02-26Auto merge of #67742 - mark-i-m:describe-it, r=matthewjasperbors-6/+13
Generalized article_and_description r? @matthewjasper The logic of finding the right word and article to print seems to be repeated elsewhere... this is an experimental method to unify this logic...
2020-02-24rustc_metadata: Use binary search from standard libraryVadim Petrochenkov-13/+5
instead of a hand rolled one.
2020-02-22get rid of lazymark-1/+1
2020-02-22add generator_kind queryMark Mansi-6/+13
2020-02-15Record proc macro harness order for use during metadata deserializationAaron Hill-4/+0
Fixes #68690 When we generate the proc macro harness, we now explicitly recorder the order in which we generate entries. We then use this ordering data to deserialize the correct proc-macro-data from the crate metadata.
2020-02-01Move builtin attribute logic to new rustc_attr crate.Mazdak Farrokhzad-1/+1
For now, this is all the crate contains, but more attribute logic & types will be moved there over time.
2020-01-16don't clone types that are copyMatthias Krüger-1/+1
found via clippy
2020-01-10Auto merge of #65241 - tmiasko:no-std-san, r=alexcrichtonbors-4/+0
build-std compatible sanitizer support ### Motivation When using `-Z sanitizer=*` feature it is essential that both user code and standard library is instrumented. Otherwise the utility of sanitizer will be limited, or its use will be impractical like in the case of memory sanitizer. The recently introduced cargo feature build-std makes it possible to rebuild standard library with arbitrary rustc flags. Unfortunately, those changes alone do not make it easy to rebuild standard library with sanitizers, since runtimes are dependencies of std that have to be build in specific environment, generally not available outside rustbuild process. Additionally rebuilding them requires presence of llvm-config and compiler-rt sources. The goal of changes proposed here is to make it possible to avoid rebuilding sanitizer runtimes when rebuilding the std, thus making it possible to instrument standard library for use with sanitizer with simple, although verbose command: ``` env CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-Zsanitizer=thread cargo test -Zbuild-std --target x86_64-unknown-linux-gnu ``` ### Implementation * Sanitizer runtimes are no long packed into crates. Instead, libraries build from compiler-rt are used as is, after renaming them into `librusc_rt.*`. * rustc obtains runtimes from target libdir for default sysroot, so that they are not required in custom build sysroots created with build-std. * The runtimes are only linked-in into executables to address issue #64629. (in previous design it was hard to avoid linking runtimes into static libraries produced by rustc as demonstrated by sanitizer-staticlib-link test, which still passes despite changes made in #64780). cc @kennytm, @japaric, @firstyear, @choller
2020-01-09{rustc::util -> rustc_data_structures}::capturesMazdak Farrokhzad-1/+1
2020-01-09Remove sanitizer_runtime attributeTomasz Miąsko-4/+0
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-3/+3
2020-01-04extract Export, ExportMap from hir::defMazdak Farrokhzad-12/+8
2020-01-02Normalize `syntax::source_map` imports.Mazdak Farrokhzad-1/+1
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-7/+7
2019-12-30Rename `libsyntax_ext` and `libsyntax_expand` in codeVadim Petrochenkov-2/+2