about summary refs log tree commit diff
path: root/src/librustc/traits
AgeCommit message (Collapse)AuthorLines
2019-02-24hir: remove NodeId from Blockljedrz-1/+2
2019-02-21partially revert 904a0bde93f0348f69914ee90b1f8b6e4e0d7cbcNiko Matsakis-1/+19
This preserves the error you currently get on stable for the old-lub-glb-object.rs test.
2019-02-21introduce a dummy leak check and invoke it in all the right placesNiko Matsakis-24/+61
This set of diffs was produced by combing through b68fad670bb3612cac26e50751e4fd9150e59977 and seeing where the `leak_check` used to be invoked and how.
2019-02-21s/skol_/placeholder_/Niko Matsakis-10/+10
2019-02-14Rollup merge of #58267 - estebank:match-arms, r=matthewjasperMazdak Farrokhzad-3/+17
Tweak "incompatible match arms" error - Point at the body expression of the match arm with the type error. - Point at the prior match arms explicitly stating the evaluated type. - Point at the entire match expr in a secondary span, instead of primary. - For type errors in the first match arm, the cause is outside of the match, treat as implicit block error to give a more appropriate error. Fix #46776, fix #57206. CC #24157, #38234.
2019-02-13HirId-ify hir::BodyIdljedrz-14/+14
2019-02-13Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasperMazdak Farrokhzad-5/+5
Rename rustc_errors dependency in rust 2018 crates I think this is a better solution than `use rustc_errors as errors` in `lib.rs` and `use crate::errors` in modules. Related: rust-lang/cargo#5653 cc #58099 r? @Centril
2019-02-13Cleanup importsTaiki Endo-3/+3
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-3/+3
2019-02-10rustc: doc commentsAlexander Regueiro-117/+116
2019-02-10Auto merge of #58151 - ljedrz:HirIdify_rustc, r=Zoxcbors-4/+5
Partially HirId-ify rustc Another step towards https://github.com/rust-lang/rust/pull/57578.
2019-02-09Auto merge of #58207 - nnethercote:intern_lazy_const, r=oli-obkbors-4/+4
Make `intern_lazy_const` actually intern its argument. Currently it just unconditionally allocates it in the arena. For a "Clean Check" build of the the `packed-simd` benchmark, this change reduces both the `max-rss` and `faults` counts by 59%; it slightly (~3%) increases the instruction counts but the `wall-time` is unchanged. For the same builds of a few other benchmarks, `max-rss` and `faults` drop by 1--5%, but instruction counts and `wall-time` changes are in the noise. Fixes #57432, fixes #57829.
2019-02-08review comments: (marginally) reduce memory consumtionEsteban Küber-5/+11
2019-02-07Reweork incompatible match arms errorEsteban Küber-3/+11
- Point at the body expression of the match arm with the type error. - Point at the prior match arms explicitely stating the evaluated type. - Point at the entire match expr in a secondary span, instead of primary. - For type errors in the first match arm, the cause is outside of the match, treat as implicit block error to give a more appropriate error.
2019-02-06Make `intern_lazy_const` actually intern its argument.Nicholas Nethercote-4/+4
Currently it just unconditionally allocates it in the arena. For a "Clean Check" build of the the `packed-simd` benchmark, this change reduces both the `max-rss` and `faults` counts by 59%; it slightly (~3%) increases the instruction counts but the `wall-time` is unchanged. For the same builds of a few other benchmarks, `max-rss` and `faults` drop by 1--5%, but instruction counts and `wall-time` changes are in the noise. Fixes #57432, fixes #57829.
2019-02-05rustc: partially HirIdifyljedrz-4/+5
2019-02-05move librustc to 2018Mark Mansi-191/+191
2019-02-02hir: add HirId to main Hir nodesljedrz-1/+1
2019-01-27Mark non-static generators as always UnpinWim Looman-3/+15
2019-01-27Mark static generators as !UnpinWim Looman-0/+6
2019-01-26remove `_with_applicability` from suggestion fnsAndy Russell-12/+12
2019-01-25Auto merge of #57714 - matthewjasper:wellformed-unreachable, r=pnkfelixbors-10/+5
[NLL] Clean up handling of type annotations * Renames (Canonical)?UserTypeAnnotation -> (Canonical)?UserType so that the name CanonicalUserTypeAnnotation is free. * Keep the inferred type associated to user type annotations in the MIR, so that it can be compared against the annotated type, even when the annotated expression gets removed from the MIR. (#54943) * Use the inferred type to allow infallible handling of user type projections (#57531) * Uses revisions for the tests in #56993 * Check the types of `Unevaluated` constants with no annotations (#46702) * Some drive-by cleanup Closes #46702 Closes #54943 Closes #57531 Closes #57731 cc #56993 leaving this open to track the underlying issue: we are not running tests with full NLL enabled on CI at the moment r? @nikomatsakis
2019-01-22Auto merge of #57475 - SimonSapin:signed, r=estebankbors-3/+7
Add signed num::NonZeroI* types Multiple people have asked for them in https://github.com/rust-lang/rust/issues/49137. Given that the unsigned ones already exist, they are very easy to add and not an additional maintenance burden.
2019-01-21Fix some non-determinism in help messages for E0277 errors.Simon Sapin-3/+7
The diagnostic for this error prints `the following implementations were found` followed by the first N relevant impls, sorted. This commit makes the sort happen before slicing, so that the set of impls being printed is deterministic when the input is not.
2019-01-19Handle lifetime annotations in unreachable codeMatthew Jasper-10/+5
We equate the type in the annotation with the inferred type first so that we have a fully inferred type to perform the well-formedness check on.
2019-01-19Rollup merge of #57502 - nikomatsakis:fix-trait-alias-1b, r=nikomatsakisMazdak Farrokhzad-1/+1
make trait-aliases work across crates This is rebase of a small part of @alexreg's PR #55994. It focuses just on the changes that integrate trait aliases properly into crate metadata, excluding the stylistic edits and the trait objects. The stylistic edits I also rebased and can open a separate PR. The trait object stuff I found challenging and decided it basically needed to be reimplemented. For now I've excluded it. Since this is really @alexreg's work (I really just rebased) I am going to make it r=me once it is working. Fixes #56488. Fixes #57023.
2019-01-19Auto merge of #56722 - Aaron1011:fix/blanket-eval-overflow, r=nikomatsakisbors-25/+73
Fix stack overflow when finding blanket impls Currently, SelectionContext tries to prevent stack overflow by keeping track of the current recursion depth. However, this depth tracking is only used when performing normal section (which includes confirmation). No such tracking is performed for evaluate_obligation_recursively, which can allow a stack overflow to occur. To fix this, this commit tracks the current predicate evaluation depth. This is done separately from the existing obligation depth tracking: an obligation overflow can occur across multiple calls to 'select' (e.g. when fulfilling a trait), while a predicate evaluation overflow can only happen as a result of a deep recursive call stack. Fixes #56701 I've re-used `tcx.sess.recursion_limit` when checking for predication evaluation overflows. This is such a weird corner case that I don't believe it's necessary to have a separate setting controlling the maximum depth.
2019-01-16Don't explicitly increment the depth for new trait predicatesAaron Hill-2/+1
2019-01-16Auto merge of #57321 - petrochenkov:atokens, r=nikomatsakisbors-4/+1
Implement basic input validation for built-in attributes Correct top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is enforced for built-in attributes, built-in attributes must also fit into the "meta-item" syntax (aka the "classic attribute syntax"). For some subset of attributes (found by crater run), errors are lowered to deprecation warnings. NOTE: This PR previously included https://github.com/rust-lang/rust/pull/57367 as well.
2019-01-13Suggest removal of semicolon when appropriateEsteban Küber-1/+6
2019-01-13Tweak output of type mismatch between "then" and `else` `if` armsEsteban Küber-3/+6
2019-01-13Rollup merge of #57366 - estebank:point-match-discrim, r=varkorMazdak Farrokhzad-4/+12
Point at match discriminant on type error in match arm pattern ``` error[E0308]: mismatched types --> src/main.rs:5:9 | 4 | let temp: usize = match a + b { | ----- this expression has type `usize` 5 | Ok(num) => num, | ^^^^^^^ expected usize, found enum `std::result::Result` | = note: expected type `usize` found type `std::result::Result<_, _>` ``` Fix #57279.
2019-01-13Implement basic input validation for built-in attributesVadim Petrochenkov-4/+1
2019-01-12Point at the match discriminant when arm pattern has a type mismatchEsteban Küber-4/+12
2019-01-11Auto merge of #57355 - arielb1:correct-subst, r=nikomatsakisbors-9/+24
use the correct supertrait substitution in `object_ty_for_trait` beta-nominating because regression. Fixes #57156.
2019-01-10integrate trait aliases into def-paths / metadataNiko Matsakis-1/+1
Co-authored-by: Alexander Regueiro <alexreg@me.com>
2019-01-05use the correct supertrait substitution in `object_ty_for_trait`Ariel Ben-Yehuda-9/+24
Fixes #57156.
2019-01-05Rollup merge of #57229 - mikeyhew:fix-56806, r=varkorkennytm-5/+18
Fix #56806 by using `delay_span_bug` in object safety layout sanity checks It's possible that `is_object_safe` is called on a trait method that with an invalid receiver type. This caused an ICE in #56806, because `receiver_is_dispatchable` returns `true` for `self: Box<dyn Trait>`, which causes one of the layout sanity checks in object_safety.rs to fail. Replacing `bug!` with `delay_span_bug` solves this. The fact that `receiver_is_dispatchable` returns `true` here could be considered a bug. It passes the check that the method implements, though: `Box<dyn Trait>` implements `DispatchFromDyn<Box<dyn Trait>>` because `dyn Trait` implements `Unsize<dyn Trait>`. It would be good to hear what @eddyb and @nikomatsakis think. Note that I only added a test for the case encountered in #56806. I could not come up with a case that triggered an ICE from the other check, `bug!("receiver when Self = dyn Trait should be ScalarPair, found Scalar")`. There is no way, to my knowledge, that you can make `receiver_is_dispatchable` return true but still have a `Scalar` ABI when `Self = dyn Trait`. One other case I encountered while debugging #56806 was that if you have a type parameter `T` that implements `Deref<Target=Self>` and `DispatchFromDyn<T>`, and use it as a method receiver, it will cause an ICE during `is_object_safe` because `T` has no layout ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d9b7497b3be0ca8382fa7d9497263214)): ```rust trait Trait<T: Deref<Target=Self> + DispatchFromDyn<T>> { fn foo(self: T) -> dyn Trait<T>; } ``` I don't intend to remove the ICE there because it is a pathological case, especially since there is no way to implement `DispatchFromDyn<T>` for `T` — the checks in typeck/coherence/builtin.rs do not allow that. fixes #56806 r? @varkor
2019-01-05Auto merge of #56837 - arielb1:nonprincipal-trait-objects, r=nikomatsakisbors-51/+50
Add support for trait-objects without a principal The hard-error version of #56481 - should be merged after we do something about the `traitobject` crate. Fixes #33140. Fixes #57057. r? @nikomatsakis
2019-01-05Auto merge of #56145 - weiznich:re_rebalance_coherence, r=nikomatsakisbors-32/+57
Implement the Re-rebalance coherence RFC This is the first time I touch anything in the compiler so just tell me if I got something wrong. Big thanks to @sgrif for the pointers where to look for those things. cc #55437
2019-01-04use `delay_span_bug` instead of `bug!` when doing layout sanity checkMichael Hewson-5/+18
It's possible that `is_object_safe` is called on a trait that is ill-formed, and we shouldn't ICE unless there are no errors being raised. Using `delay_span_bug` solves this. fixes #56806
2019-01-04Auto merge of #56723 - oli-obk:lazy_const, r=nikomatsakisbors-15/+14
Don't emit `Unevaluated` from `const_eval` cc @eddyb @RalfJung
2019-01-03Improve commentAaron Hill-1/+8
2019-01-03Cleanup codeAaron Hill-7/+1
2019-01-03Improve error generation, fixup recursion limitsAaron Hill-6/+28
2019-01-03More tidy fixesAaron Hill-3/+4
2019-01-03Ensure that we properly increment obligation depthAaron Hill-21/+24
2019-01-03Remove extra recursion_depth trackingAaron Hill-63/+41
2019-01-03Fix tidy errorsAaron Hill-6/+11
2019-01-03Fix stack overflow when finding blanket implsAaron Hill-31/+70
Currently, SelectionContext tries to prevent stack overflow by keeping track of the current recursion depth. However, this depth tracking is only used when performing normal section (which includes confirmation). No such tracking is performed for evaluate_obligation_recursively, which can allow a stack overflow to occur. To fix this, this commit tracks the current predicate evaluation depth. This is done separately from the existing obligation depth tracking: an obligation overflow can occur across multiple calls to 'select' (e.g. when fulfilling a trait), while a predicate evaluation overflow can only happen as a result of a deep recursive call stack. Fixes #56701