about summary refs log tree commit diff
path: root/src/librustc/ty
AgeCommit message (Collapse)AuthorLines
2020-03-18Rollup merge of #69899 - ecstatic-morse:const-idx-methods, r=oli-obkMazdak Farrokhzad-1/+1
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 #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-17Make stuff private.Camille GILLOT-24/+19
2020-03-17Rename `from_u32_const` -> `from_u32`Dylan MacKenzie-1/+1
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-2/+34
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-105/+295
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-25/+18
2020-03-16hygiene: `modern` -> `normalize_to_macros_2_0`Vadim Petrochenkov-8/+10
`modern_and_legacy` -> `normalize_to_macro_rules`
2020-03-15rustc: tweak comments on InstanceDef.Ana-Maria Mihalache-12/+9
2020-03-15rustc: don't resolve Instances which would produce malformed shims.Eduard-Mihai Burtescu-0/+15
2020-03-15Avoid ICEs when we emit errors constructing the specialization graphMatthew Jasper-1/+2
2020-03-15Add attributes to allow specializing on traitsMatthew Jasper-1/+32
2020-03-14Index HIR after creating TyCtxtJohn Kåre Alsaker-10/+5
2020-03-14Remove `Hir` and `HirBody` dep nodesJohn Kåre Alsaker-2/+0
2020-03-14Clean up the collectorJohn Kåre Alsaker-1/+1
2020-03-14Remove `AllLocalTraitImpls`John Kåre Alsaker-1/+0
2020-03-14Update `trait_impls`John Kåre Alsaker-3/+17
2020-03-14Create Map after TyCtxtJohn Kåre Alsaker-16/+27
2020-03-14Add HIR queriesJohn Kåre Alsaker-0/+1
2020-03-14Use smaller discriminants for generatorsJonas Schievink-6/+9
2020-03-14Rollup merge of #69802 - matthiaskrgr:cl1ppy, r=Dylan-DPCYuki Okushi-6/+1
fix more clippy findings * reduce references on match patterns (clippy::match_ref_pats) * Use writeln!(fmt, "word") instead of write!(fmt, "word\n") (clippy::write_with_newline) * libtest: remove redundant argument to writeln!() (clippy::writeln_empty_string) * remove unneeded mutable references (cippy::unnecessary_mut_passed) * libtest: declare variables as floats instead of casting them (clippy::unnecessary_cast) * rustdoc: remove redundant static lifetimes (clippy::redundant_static_lifetimes) * call .as_deref() instead of .as_ref().map(Deref::deref) (clippy::option_as_ref_deref) * iterate over a maps values directly. (clippy::for_kv_map) * rustdoc: simplify boolean condition (clippy::nonminimal_bool) * Use ?-operator in more places (clippy::question_mark, had some false negatives fixed recently) * rustdoc: Use .any(p) instead of find(p).is_some(). (clippy::search_is_some) * rustdoc: don't call into_iter() on iterator. (clippy::identity_conversion)
2020-03-13Print ConstKind::Placeholder just like TyKind::PlaceholderOliver Scherer-15/+1
2020-03-13Print ConstKind::Bound the same as TyKind::BoundOliver Scherer-9/+17
2020-03-12Ensure HAS_FREE_LOCAL_NAMES is set for ReFreeMatthew Jasper-26/+29
2020-03-12Rollup merge of #69747 - spastorino:rename-rustc-guide, r=pietroalbiniMazdak Farrokhzad-6/+6
Rename rustc guide This is in preparation for https://github.com/rust-lang/rustc-guide/issues/470 Needs to be merged after we actually rename the guide. Have used this to rename: `git grep -l 'rustc_guide' | xargs sed -i 's/rustc_guide/rustc_dev_guide/g'` `git grep -l 'rustc-guide' | xargs sed -i 's/rustc-guide/rustc-dev-guide/g'` `git grep -l 'rustc guide' | xargs sed -i 's/rustc guide/rustc dev guide/g'`