about summary refs log tree commit diff
path: root/src/librustc/traits
AgeCommit message (Collapse)AuthorLines
2018-08-02Tidy fixesAaron Hill-4/+12
2018-08-02A bit of cleanupAaron Hill-4/+23
2018-08-02Filter out duplicated trait predicates when generating auto traitsAaron Hill-3/+63
Fixes #51236
2018-08-01Split out growth functionality into BitVector typeMark Rousskov-2/+2
2018-07-31assert no region obligations on entering custom type opNiko Matsakis-0/+13
Fixes #51649
2018-07-30Auto merge of #52830 - matthewjasper:bootstrap-prep, r=matthewjasperbors-1/+1
[NLL] Fix some things for bootstrap Some changes that are required when bootstrapping rustc with NLL enabled. * Remove a bunch of unused `mut`s that aren't needed, but the existing lint doesn't catch. * Rewrite a function call to satisfy NLL borrowck. Note that the borrow is two-phase, but gets activated immediately by an unsizing coercion. cc #51823
2018-07-30Auto merge of #52805 - ljedrz:format_str_literal, r=petrochenkovbors-1/+1
Don't format!() string literals Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
2018-07-29Auto merge of #52738 - ljedrz:push_to_extend, r=eddybbors-3/+3
Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible.
2018-07-29Remove unused `mut`sMatthew Jasper-1/+1
2018-07-29Replace push loops with collect() and extend() where possibleljedrz-3/+3
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-8/+8
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-28Auto merge of #52546 - nikomatsakis:issue-52050, r=pnkfelixbors-22/+79
do not overwrite child def-id in place but rather remove/insert When inserting a node N into the tree of impls, we sometimes find than an existing node C should be replaced with N. We used to overwrite C in place with the new def-id N -- but since the lists of def-ids are separated by simplified type, that could lead to N being inserted in the wrong place. This meant we might miss conflicts. We are now not trying to be so smart -- we remove C and then add N later. Fixes #52050 r? @aturon -- do you still remember this code at all? :)
2018-07-28Don't format!() string literalsljedrz-1/+1
2018-07-28Auto merge of #52711 - eddyb:unsized-manuallydrop, r=nikomatsakisbors-1/+4
Change ManuallyDrop<T> to a lang item. This PR implements the approach @RalfJung proposes in https://internals.rust-lang.org/t/pre-rfc-unions-drop-types-and-manuallydrop/8025 (lang item `struct` instead of `union`). A followup PR can easily solve #47034 as well, by just adding a few `?Sized` to `libcore/mem.rs`. r? @nikomatsakis
2018-07-28Rollup merge of #52781 - ljedrz:avoid_vec_arguments, r=nikomatsakiskennytm-2/+2
Use a slice where a vector is not necessary
2018-07-28Rollup merge of #52703 - ljedrz:vec_improvements, r=nikomatsakiskennytm-7/+4
Improve a few vectors - calculate capacity or build from iterators Collecting from iterators improves readability and tailoring vector capacities should be beneficial in terms of performance.
2018-07-27Use slices where a vector is not necessaryljedrz-2/+2
2018-07-27Prefer to_string() to format!()ljedrz-8/+8
2018-07-27Auto merge of #52650 - oli-obk:associated_existential_types, r=nikomatsakisbors-6/+23
Implement associated existential types r? @nikomatsakis no idea if these work with generic traits. I'm going home for the day :rofl:
2018-07-26Improve a few vectors - calculate capacity or build from iteratorsljedrz-7/+4
2018-07-26Rollup merge of #52647 - csmoe:closure_arg_ignore, r=estebankMark Rousskov-0/+24
Suggest to take and ignore args while closure args count mismatching Closes #52473
2018-07-25Change ManuallyDrop from an union to a struct and make it a lang item.Eduard-Mihai Burtescu-1/+4
2018-07-25Add type system canaries for potential future bugsOliver Schneider-1/+5
2018-07-25Fix associated existentials for generic traitsOliver Schneider-1/+2
2018-07-25Update comment and do suggestcsmoe-8/+9
2018-07-25Suggest in separate linecsmoe-1/+1
2018-07-23librustc: Prefer `Option::map`/etc over `match` where applicableColin Wallace-5/+4
2018-07-24Mark the suggestion applicablecsmoe-9/+15
2018-07-23Implement associated existential typesOliver Schneider-6/+18
2018-07-23Suggest to take and ignore args while closure args count mismatchingcsmoe-1/+18
2018-07-22Auto merge of #52394 - estebank:println, r=oli-obkbors-2/+2
Improve suggestion for missing fmt str in println Avoid using `concat!(fmt, "\n")` to improve the diagnostics being emitted when the first `println!()` argument isn't a formatting string literal. Fix #52347.
2018-07-21Remove dependency on `libsyntax`Esteban Küber-3/+3
2018-07-21do not overwrite child def-id in place but rather remove/insertNiko Matsakis-22/+79
When inserting a node N into the tree of impls, we sometimes find than an existing node C should be replaced with N. We used to overwrite C in place with the new def-id N -- but since the lists of def-ids are separated by simplified type, that could lead to N being inserted in the wrong place. This meant we might miss conflicts. We are now not trying to be so smart -- we remove C and then add N later.
2018-07-21use proper body-id and span when solving obligationsNiko Matsakis-2/+2
2018-07-21skip no-op obligations and add a little debug outputNiko Matsakis-1/+3
2018-07-21Convert implied_outlives_bounds to a queryTyler Mandry-0/+170
2018-07-19Use correct spans for format string errorsEsteban Küber-3/+3
When encountering format string errors in a raw string, or regular string literal with embedded newlines, account for the positional change to use correct spans. :drive by fix: 🚗
2018-07-18Auto merge of #52342 - nnethercote:CanonicalVar, r=nikomatsakisbors-6/+15
Avoid most allocations in `Canonicalizer`. Extra allocations are a significant cost of NLL, and the most common ones come from within `Canonicalizer`. In particular, `canonical_var()` contains this code: indices .entry(kind) .or_insert_with(|| { let cvar1 = variables.push(info); let cvar2 = var_values.push(kind); assert_eq!(cvar1, cvar2); cvar1 }) .clone() `variables` and `var_values` are `Vec`s. `indices` is a `HashMap` used to track what elements have been inserted into `var_values`. If `kind` hasn't been seen before, `indices`, `variables` and `var_values` all get a new element. (The number of elements in each container is always the same.) This results in lots of allocations. In practice, most of the time these containers only end up holding a few elements. This PR changes them to avoid heap allocations in the common case, by changing the `Vec`s to `SmallVec`s and only using `indices` once enough elements are present. (When the number of elements is small, a direct linear search of `var_values` is as good or better than a hashmap lookup.) The changes to `variables` are straightforward and contained within `Canonicalizer`. The changes to `indices` are more complex but also contained within `Canonicalizer`. The changes to `var_values` are more intrusive because they require defining a new type `SmallCanonicalVarValues` -- which is to `CanonicalVarValues` as `SmallVec` is to `Vec -- and passing stack-allocated values of that type in from outside. All this speeds up a number of NLL "check" builds, the best by 2%. r? @nikomatsakis
2018-07-17Avoid most allocations in `Canonicalizer`.Nicholas Nethercote-6/+15
Extra allocations are a significant cost of NLL, and the most common ones come from within `Canonicalizer`. In particular, `canonical_var()` contains this code: indices .entry(kind) .or_insert_with(|| { let cvar1 = variables.push(info); let cvar2 = var_values.push(kind); assert_eq!(cvar1, cvar2); cvar1 }) .clone() `variables` and `var_values` are `Vec`s. `indices` is a `HashMap` used to track what elements have been inserted into `var_values`. If `kind` hasn't been seen before, `indices`, `variables` and `var_values` all get a new element. (The number of elements in each container is always the same.) This results in lots of allocations. In practice, most of the time these containers only end up holding a few elements. This PR changes them to avoid heap allocations in the common case, by changing the `Vec`s to `SmallVec`s and only using `indices` once enough elements are present. (When the number of elements is small, a direct linear search of `var_values` is as good or better than a hashmap lookup.) The changes to `variables` are straightforward and contained within `Canonicalizer`. The changes to `indices` are more complex but also contained within `Canonicalizer`. The changes to `var_values` are more intrusive because they require defining a new type `SmallCanonicalVarValues` -- which is to `CanonicalVarValues` as `SmallVec` is to `Vec -- and passing stack-allocated values of that type in from outside. All this speeds up a number of NLL "check" builds, the best by 2%.
2018-07-16ItemKindcsmoe-2/+2
2018-07-16TyKindcsmoe-1/+1
2018-07-16ExprKindcsmoe-2/+2
2018-07-16VariantKindcsmoe-1/+1
2018-07-14Remove `ty_to_def_id`Oliver Schneider-2/+8
2018-07-04Remove obsolete documentation from FufillmentContext::select comment.Benjamin Peterson-2/+1
The `only_new_obligations` parameter has not existed since 43756934d255603a0fb7a871f2a145380e488b71.
2018-07-02drive-by nits and debugNiko Matsakis-0/+5
Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-07-02use `ty::TraitRef::identity` where possibleNiko Matsakis-9/+4
Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-06-28Rollup merge of #51636 - oli-obk:const_diagnostics, r=eddybMark Rousskov-11/+14
Refactor error reporting of constants cc @eddyb This PR should not change any behaviour. It solely simplifies the internal handling of the errors
2018-06-28Rebase falloutOliver Schneider-1/+1
2018-06-28Merge `ConstVal` and `ConstValue`Oliver Schneider-3/+3