about summary refs log tree commit diff
path: root/src/librustc
AgeCommit message (Collapse)AuthorLines
2020-03-19rustc: use LocalDefId instead of DefId in TypeckTables.Eduard-Mihai Burtescu-77/+50
2020-03-19rustc: use LocalDefId instead of DefIndex in hir::map::definitions.Eduard-Mihai Burtescu-117/+108
2020-03-19rustc: use LocalDefId instead of DefIndex in ich.Eduard-Mihai Burtescu-24/+9
2020-03-19rustc: use LocalDefId instead of DefIndex in HirId.Eduard-Mihai Burtescu-117/+74
2020-03-19rustc: introduce DefId::as_local(self) -> Option<LocalDefId> and use it.Eduard-Mihai Burtescu-18/+26
2020-03-19rustc: rename DefId::to_local to expect_local and use it instead of ↵Eduard-Mihai Burtescu-2/+2
LocalDefId::from_def_id.
2020-03-19rustc: make LocalDefId's index field public like DefId's is.Eduard-Mihai Burtescu-2/+2
2020-03-19rustc: use LocalDefId instead of DefIndex for query keys.Eduard-Mihai Burtescu-24/+27
2020-03-19do not 'return' in 'throw_' macrosRalf Jung-5/+6
2020-03-19Rollup merge of #69036 - eddyb:monoshim, r=nikomatsakisMazdak Farrokhzad-0/+12
rustc: don't resolve Instances which would produce malformed shims. There are some `InstanceDef` variants (shims and drop "glue") which contain a `Ty`, and that `Ty` is used in generating the shim MIR. But if that `Ty` mentions any generic parameters, the generated shim would refer to them (but they won't match the `Substs` of the `Instance`), or worse, generating the shim would fail because not enough of the type is known. Ideally we would always produce a "skeleton" of the type, e.g. `(_, _)` for dropping any tuples with two elements, or `Vec<_>` for dropping any `Vec` value, but that's a lot of work, and they would still not match the `Substs` of the `Instance` as it exists today, so `Instance` would probably need to change. By making `Instance::resolve` return `None` in the still-generic cases, we get behavior similar to specialization, where a default can only be used if there are no more generic parameters which would allow a more specialized `impl` to match. <hr/> This was found while testing the MIR inliner with #68965, because it was trying to inline shims. cc @rust-lang/wg-mir-opt
2020-03-18Properly handle Spans that reference imported SourceFilesAaron Hill-7/+5
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-45/+36
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-18Rollup merge of #69899 - ecstatic-morse:const-idx-methods, r=oli-obkMazdak Farrokhzad-2/+5
Make methods declared by `newtype_index` macro `const` Crates that use the macro to define an `Idx` type need to enable `#![feature(const_if_match, const_panic)]`.
2020-03-18Rollup merge of #69839 - RalfJung:miri-error-cleanup, r=oli-obkMazdak Farrokhzad-217/+134
Miri error reform Some time ago we started moving Miri errors into a few distinct categories, but we never classified all the old errors. That's what this PR does. ~~This is on top of https://github.com/rust-lang/rust/pull/69762; [relative diff](https://github.com/RalfJung/rust/compare/validity-errors...RalfJung:miri-error-cleanup).~~ r? @oli-obk Fixes https://github.com/rust-lang/const-eval/issues/4
2020-03-18Rollup merge of #69837 - jonas-schievink:gen-discr-opt, r=tmandryMazdak Farrokhzad-6/+9
Use smaller discriminants for generators Closes https://github.com/rust-lang/rust/issues/69815 I'm not yet sure about the runtime performance impact of this, so I'll try running this on some benchmarks (if I can find any). (Update: No impact on the benchmarks I've measured on) * [x] Add test with a generator that has exactly 256 total states * [x] Add test with a generator that has more than 256 states so that it needs to use a u16 discriminant * [x] Add tests for the size of `Option<[generator]>` * [x] Add tests for the `discriminant_value` intrinsic in all cases
2020-03-18Rollup merge of #69189 - matthewjasper:erase-the-world, r=nikomatsakisMazdak Farrokhzad-9/+0
Erase regions in writeback Regions in `TypeckTables` (except canonicalized user annotations) are now erased. Further, we no longer do lexical region solving on item bodies with `-Zborrowck=mir`. cc #68261 r? @nikomatsakis
2020-03-18rustc_infer: remove InferCtxt::closure_sig as the FnSig is always shallowly ↵Eduard-Mihai Burtescu-20/+14
known.
2020-03-17Use `const_eval_limit` instead of infinite loop detectorDylan MacKenzie-7/+5
2020-03-17Make stuff private.Camille GILLOT-24/+19
2020-03-17Add requisite feature gates for const assertDylan MacKenzie-0/+3
2020-03-17Rename `from_u32_const` -> `from_u32`Dylan MacKenzie-2/+2
2020-03-17Rollup merge of #69956 - matthewjasper:fix-region-flags, r=nikomatsakisMazdak Farrokhzad-26/+29
Ensure HAS_FREE_LOCAL_NAMES is set for ReFree This fixes a bug introduced by #69469. I don't have any ideas on how to reate a regression test for this.
2020-03-17Remove `free_region_map` from `TypeckTables`Matthew Jasper-9/+0
It was unused.
2020-03-17Rollup merge of #70049 - oli-obk:param_env_empty_considered_unimplemented, ↵Mazdak Farrokhzad-15/+34
r=eddyb Fiddle `ParamEnv` through to a place that used to use `ParamEnv::empty` in a buggy manner cc https://github.com/rust-lang/rust/pull/69981#discussion_r393048924 r? @eddyb
2020-03-16Auto merge of #68970 - matthewjasper:min-spec, r=nikomatsakisbors-12/+53
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-16Fiddle `ParamEnv` through to a place that used to use `ParamEnv::empty` in a ↵Oliver Scherer-15/+34
buggy manner
2020-03-16Auto merge of #67133 - oli-obk:it_must_be_a_sign, r=eddybbors-113/+303
Deduplicate pretty printing of constants r? @eddyb for the pretty printing logic cc @RalfJung
2020-03-16Rollup merge of #70036 - mark-i-m:describe-it-4, r=eddybDylan DPC-14/+15
Make article_and_description primarily use def_kind r? @eddyb cc @matthewjasper
2020-03-16Rollup merge of #69989 - petrochenkov:nolegacy, r=eddyb,matthewjasperDylan DPC-8/+10
resolve/hygiene: `macro_rules` are not "legacy" The "modern" vs "legacy" naming was introduced by jseyfried during initial implementation of macros 2.0. At this point it's clear that `macro_rules` are not going anywhere and won't be deprecated in the near future. So this PR changes the naming "legacy" (when it implies "macro_rules") to "macro_rules". This should also help people reading this code because it's wasn't obvious that "legacy" actually meant "macro_rules" in these contexts. The most contentious renaming here is probably ``` fn modern -> fn normalize_to_macros_2_0 fn modern_and_legacy -> fn normalize_to_macro_rules ``` Other alternatives that I could think of are `normalize_to_opaque`/`normalize_to_semitransparent`, or `strip_non_opaque`/`strip_transparent`, but they seemed less intuitive. The documentation to these functions can be found in `symbol.rs`. r? @matthewjasper
2020-03-16Remove QueryState type alias.Camille GILLOT-21/+22
2020-03-16Make QueryCache parameters associated types.Camille GILLOT-94/+101
2020-03-16Simplify type aliases.Camille GILLOT-36/+21
2020-03-16Offload try_collect_active_jobs.Camille GILLOT-26/+37
2020-03-16Remove Q parameter from try_get_cached.Camille GILLOT-11/+13
2020-03-16Remove Q parameter from JobOwner.Camille GILLOT-18/+43
2020-03-16Remove Q parameter from query stats.Camille GILLOT-9/+14
2020-03-16Remove Q parameter from alloc_self_profile_query_strings_for_query_cache.Camille GILLOT-6/+7
2020-03-16Remove Q parameter from QueryCache::lookup.Camille GILLOT-13/+14
2020-03-16Unpack type arguments for QueryState.Camille GILLOT-15/+23
2020-03-16Unpack type arguments for QueryLookup.Camille GILLOT-3/+4
2020-03-16Unpack type arguments for QueryStateShard.Camille GILLOT-14/+21
2020-03-16Move impl of Queries with its definition.Camille GILLOT-49/+49
2020-03-16Inline QueryAccessor::query.Camille GILLOT-9/+2
2020-03-16Make QueryAccessor::dep_kind an associated const.Camille GILLOT-11/+6
2020-03-16Remove __query_compute module.Camille GILLOT-20/+8
2020-03-15make article_and_description primarily use def_kindmark-14/+15
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-45/+36
2020-03-15update commentMark Mansi-5/+1
2020-03-15More Method->Fn renamingMark Mansi-14/+19
2020-03-16hygiene: `modern` -> `normalize_to_macros_2_0`Vadim Petrochenkov-8/+10
`modern_and_legacy` -> `normalize_to_macro_rules`