about summary refs log tree commit diff
path: root/src/librustc/traits
AgeCommit message (Collapse)AuthorLines
2017-06-28Auto merge of #42850 - estebank:unwanted-return-rotj, r=nikomatsakisbors-49/+52
Detect missing `;` on methods with return type `()` - Point out the origin of a type requirement when it is the return type of a method - Point out possibly missing semicolon when the return type is `()` and the implicit return makes sense as a statement - Suggest changing the return type of methods with default return type - Don't suggest changing the return type on `fn main()` - Don't suggest changing the return type on impl fn - Suggest removal of semicolon (instead of being help)
2017-06-27rustc: move the PolyFnSig out of TyFnDef.Eduard-Mihai Burtescu-17/+30
2017-06-27rustc: rename closure_type to fn_sig.Eduard-Mihai Burtescu-2/+2
2017-06-24Detect missing `;` on methods with return type `()`Esteban Küber-49/+52
- Point out the origin of a type requirement when it is the return type of a method - Point out possibly missing semicolon when the return type is () and the implicit return makes sense as a statement - Suggest changing the return type of methods with default return type - Don't suggest changing the return type on fn main() - Don't suggest changing the return type on impl fn
2017-06-21avoid translating roots with predicates that do not holdAriel Ben-Yehuda-2/+5
Fixes #37725.
2017-06-14suppress trait errors that are implied by other errorsAriel Ben-Yehuda-155/+92
Instead of suppressing only trait errors that are "exact duplicates", display only the "most high-level" error when there are multiple trait errors with the same span that imply each-other. e.g. when there are both `[closure]: Fn` and `[closure]: FnOnce`, omit displaying the `[closure]: FnOnce` bound.
2017-06-12Auto merge of #42537 - michaelwoerister:tcx-for-dep-node, r=nikomatsakisbors-15/+21
incr.comp.: Make DepNode `Copy` and valid across compilation sessions This PR moves `DepNode` to a representation that does not need retracing and thus simplifies comparing dep-graphs from different compilation sessions. The code also gets a lot simpler in many places, since we don't need the generic parameter on `DepNode` anymore. See https://github.com/rust-lang/rust/issues/42294 for details. ~~NOTE: Only the last commit of this is new, the rest is already reviewed in https://github.com/rust-lang/rust/pull/42504.~~ This PR is almost done but there are some things I still want to do: - [x] Add some module-level documentation to `dep_node.rs`, explaining especially what the `define_dep_nodes!()` macro is about. - [x] Do another pass over the dep-graph loading logic. I suspect that we can get rid of building the `edges` map and also use arrays instead of hash maps in some places. cc @rust-lang/compiler r? @nikomatsakis
2017-06-10rustc: make the comon case of tcx.infer_ctxt(()) nicer.Eduard-Mihai Burtescu-14/+17
2017-06-10rustc: do not depend on infcx.tables in MemCategorizationContext.Eduard-Mihai Burtescu-11/+3
2017-06-09incr.comp.: Uniformly represent DepNodes as (Kind, StableHash) pairs.Michael Woerister-15/+21
2017-06-07Cover all cases in closure errorsTommy Ip-5/+6
2017-06-06Update closure errors to emit context for FnMutTommy Ip-7/+12
It now handles both FnMut and FnOnce case.
2017-06-05Better closure error messageTommy Ip-5/+27
Use tracked data introduced in #42196 to provide a better closure error message by showing why a closure implements `FnOnce`. ``` error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` --> $DIR/issue_26046.rs:4:19 | 4 | let closure = move || { | ___________________^ 5 | | vec 6 | | }; | |_____^ | note: closure is `FnOnce` because it moves the variable `vec` out of its environment --> $DIR/issue_26046.rs:5:9 | 5 | vec | ^^^ error: aborting due to previous error(s) ``` Fixes #26046
2017-06-01pacify the mercilous tidyNiko Matsakis-5/+16
2017-06-01ergonomic improvements to the methods in infcxNiko Matsakis-77/+44
2017-06-01strip param-env from infcxNiko Matsakis-131/+263
2017-06-01move projection mode into parameter environmentNiko Matsakis-16/+19
2017-05-31Upgrade ProjectionTy's Name to a DefIdTobias Schottdorf-12/+15
Part of #42171, in preparation for downgrading the contained `TraitRef` to only its `substs`.
2017-05-30Syntax highlight all rust code in librustc/traits/README.mdbjorn3-19/+31
Also replace `...` with `/*...*/`
2017-05-23Auto merge of #42015 - nikomatsakis:chalk-trait-env-2, r=eddybbors-22/+22
remove interior mutability of type-flags We were previously using the flags on `Ty<'tcx>` instances to do some ad-hoc caching schemes around things like `is_sized()`, `is_freeze()`, and `moves_by_default()`. This PR replaces those schemes with a proper query; the query key is based on the pair of a `(ParameterEnvironment<'tcx>, Ty<'tcx>)` pair. This is also intended to be a preliminary template for what trait-selection and projection will eventually look like. I did some performance measurements. In the past, I observed a noticeable speedup (6%) for building rustc, but since I've rebased, the numbers appear to be more of a wash: | Crate | Before | After | Percentage | | --- | --- | --- | -- | | syntax | 167s | 166s | 0.6% faster | | rustc | 376s | 382s | 1.5% slower | Some advantages of this new scheme: - `is_sized` etc are proper queries - we get caching across generic fns, so long as trait environment is identical - dependency tracking is correct
2017-05-23Auto merge of #41559 - GuillaumeGomez:partial-eq-msg, r=estebankbors-10/+18
Add better error message when == operator is badly used Part of #40660. With the following code: ```rust fn foo<T: PartialEq>(a: &T, b: T) { a == b; } fn main() { foo(&1, 1); } ``` It prints: ``` error[E0277]: the trait bound `&T: std::cmp::PartialEq<T>` is not satisfied --> test.rs:2:5 | 2 | a == b; | ^^^^^^ can't compare `&T` with `T` | = help: the trait `std::cmp::PartialEq<T>` is not implemented for `&T` = help: consider adding a `where &T: std::cmp::PartialEq<T>` bound error: aborting due to previous error ```
2017-05-22two more style nitsNiko Matsakis-10/+10
2017-05-22rename `parameter_environment` to `param_env`Niko Matsakis-6/+6
2017-05-22rename `ParameterEnvironment` to `ParamEnv`Niko Matsakis-7/+7
2017-05-22centralize the caching for is-copy, is-sized, and is-freezeNiko Matsakis-3/+3
Use the trait-environment+type as the key. Note that these are only invoked on types that live for the entire compilation (no inference artifacts). We no longer need the various special-case bits and caches that were in place before.
2017-05-17Add better error message when == operator is badly usedGuillaume Gomez-10/+18
2017-05-16Remove unreachable branches in traits::projectMichael Woerister-116/+72
2017-05-16Don't use queries::try_get() in assoc_ty projectionMichael Woerister-25/+16
2017-05-15Share lists of blanket impls in results of relevant_impls_for() query.Michael Woerister-1/+13
2017-05-15Re-introduce cycle-check in assoc. item resolution.Michael Woerister-7/+33
2017-05-15Remove interior mutability from TraitDef by turning fields into queries.Michael Woerister-48/+91
2017-05-13rustc: treat ReEarlyBound as free without replacing it with ReFree.Eduard-Mihai Burtescu-7/+4
2017-05-13rustc: use DefId instead of CodeExtent for FreeRegion's scope.Eduard-Mihai Burtescu-1/+1
2017-05-13rustc: uniformly compute ParameterEnvironment's "free outlive scope".Eduard-Mihai Burtescu-3/+1
2017-05-08Remove need for &format!(...) or &&"" dances in `span_label` callsOliver Schneider-11/+11
2017-05-02Store interned predicates in ParameterEnvironmentTobias Schottdorf-5/+13
See #41444. As a first step towards untangling `ParameterEnvironment`, change its `caller_bounds` field from a `Vec` into an interned slice of `ty::Predicate`s. This change is intentionally well-contained and doesn't pull on any of the loose ends. In particular, you'll note that `normalize_param_env_or_error` now interns twice.
2017-05-02Rollup merge of #41662 - nikomatsakis:on-demandify-region-mapping, r=eddybCorey Farwell-13/+13
On demandify region mapping This is an adaptation of @cramertj's PR. I am sort of tempted to keep simplifying it, but also tempted to land it so and we can refactor more in follow-up PRs. As is, it does the following things: - makes the region-maps an on-demand query, per function `tcx.region_maps(def_id)` - interns code extents instead of of having them be integers - remove the "root region extent" and (to some extent) item extents; instead we use `Option<CodeExtent<'tcx>>` in a few places (no space inefficiency since `CodeExtent<'tcx>` is now a pointer). I'm not entirely happy with the way I have it setup though. Here are some of the changes I was considering (I'm not sure if they would work out well): 1. Removing `item_extents` entirely -- they are rarely used now, because most of the relevant places now accept an `Option<Region<'tcx>>` or an `Option<CodeExtent<'tcx>>`, but I think still used in a few places. 2. Merging `RegionMaps` into the typeck tables, instead of having it be its own query. 3. Change `CodeExtent<'tcx>` to store the parent pointer. This would mean that fewer places in the code actually *need* a `RegionMaps` anyhow, since most of them just want to be able to walk "up the tree". On the other hand, you wouldn't be able to intern a `CodeExtent<'tcx>` for some random node-id, you'd need to look it up in the table (since there'd be more information). Most of this code is semi-temporary -- I expect it to largely go away as we move to NLL -- so I'm also not *that* concerned with making it perfect. r? @eddyb
2017-05-02Auto merge of #41488 - estebank:closure-args, r=arielb1bors-8/+103
Clean up callable type mismatch errors ```rust error[E0593]: closure takes 1 argument but 2 arguments are required here --> ../../src/test/ui/mismatched_types/closure-arg-count.rs:13:15 | 13 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); | ^^^^^^^ -------------------------- takes 1 argument | | | expected closure that takes 2 arguments ``` instead of ```rust error[E0281]: type mismatch: the type `[closure@../../src/test/ui/mismatched_types/closure-arg-count.rs:13:23: 13:49]` implements the trait `for<'r> std::ops::FnMut<(&'r {integer},)>`, but the trait `for<'r, 'r> std::ops::FnMut<(&'r {integer}, &'r {integer})>` is required (expected a tuple with 2 elements, found one with 1 elements) --> ../../src/test/ui/mismatched_types/closure-arg-count.rs:13:15 | 13 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); | ^^^^^^^ ``` Fix #21857, re #24680.
2017-04-30introduce per-fn RegionMapsTaylor Cramer-5/+7
Instead of requesting the region maps for the entire crate, request for a given item etc. Several bits of code were modified to take `&RegionMaps` as input (e.g., the `resolve_regions_and_report_errors()` function). I am not totally happy with this setup -- I *think* I'd rather have the region maps be part of typeck tables -- but at least the `RegionMaps` works in a "parallel" way to `FreeRegionMap`, so it's not too bad. Given that I expect a lot of this code to go away with NLL, I didn't want to invest *too* much energy tweaking it.
2017-04-30intern CodeExtentsNiko Matsakis-4/+4
Make a `CodeExtent<'tcx>` be something allocated in an arena instead of an index into the `RegionMaps`.
2017-04-30remove ROOT_CODE_EXTENT and DUMMY_CODE_EXTENTNiko Matsakis-4/+2
Instead, thread around `Option<CodeExtent>` where applicable.
2017-04-30On-demandify region mappingTaylor Cramer-1/+1
2017-04-27Auto merge of #37860 - giannicic:defaultimpl, r=nagisabors-1/+28
#37653 support `default impl` for specialization this commit implements the first step of the `default impl` feature: > all items in a `default impl` are (implicitly) `default` and hence > specializable. In order to test this feature I've copied all the tests provided for the `default` method implementation (in run-pass/specialization and compile-fail/specialization directories) and moved the `default` keyword from the item to the impl. See [referenced](https://github.com/rust-lang/rust/issues/37653) issue for further info r? @aturon
2017-04-26 support `default impl` for specializationGianni Ciccarelli-0/+5
`[default] [unsafe] impl` and typecheck
2017-04-26Auto merge of #41504 - eddyb:query-api, r=nikomatsakisbors-26/+26
Improve the librustc on-demand/query API ergonomics. Queries are now performed through these two forms: * `tcx.type_of(def_id)` (the most common usage) * `tcx.at(span).type_of(def_id)` (to provide a more specific location in the cycle stack) Several queries were renamed to work better as method names, i.e. by suffixing with `_of`. r? @nikomatsakis
2017-04-25 support `default impl` for specializationGianni Ciccarelli-23/+23
pr review
2017-04-24Reorder code, fix unittestsEsteban Küber-52/+97
2017-04-24rustc: rename some of the queries to match tcx methods.Eduard-Mihai Burtescu-26/+26
2017-04-24support `default impl` for specializationGianni Ciccarelli-1/+23
this commit implements the first step of the `default impl` feature: all items in a `default impl` are (implicitly) `default` and hence specializable. In order to test this feature I've copied all the tests provided for the `default` method implementation (in run-pass/specialization and compile-fail/specialization directories) and moved the `default` keyword from the item to the impl. See referenced issue for further info
2017-04-24Fix type error.Without Boats-1/+1