summary refs log tree commit diff
path: root/src/test/ui/traits
AgeCommit message (Collapse)AuthorLines
2022-02-14Auto merge of #93652 - spastorino:fix-negative-overlap-check-regions, ↵bors-4/+6
r=nikomatsakis Fix negative overlap check regions r? `@nikomatsakis`
2022-02-14Properly check regions on negative overlap checkSantiago Pastorino-4/+6
2022-02-14further update `fuzzy_match_tys`lcnr-4/+5
2022-02-14fuzzify `fuzzy_match_tys`lcnr-0/+6
2022-02-14Make `find_similar_impl_candidates` a little fuzzier.Ben Reeves-0/+2
2022-02-11Rollup merge of #93909 - saschanaz:patch-2, r=petrochenkovMatthias Krüger-8/+8
Fix typo: explicitely -> explicitly
2022-02-11Fix typo: explicitely->explicitlyKagami Sascha Rosylight-8/+8
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-3/+3
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-07Print opaque types from type aliases via their pathOli Scherer-3/+3
2022-02-01Auto merge of #93386 - ↵bors-1/+27
WaffleLapkin:rustc_must_implement_one_of_check_target, r=nagisa Check that `#[rustc_must_implement_one_of]` is applied to a trait `#[rustc_must_implement_one_of]` only makes sense when applied to a trait, so it's sensible to emit an error otherwise.
2022-01-28Add test for old ICE in #91594Ben Reeves-0/+34
2022-01-27Check that `#[rustc_must_implement_one_of]` is applied to a traitMaybe Waffle-1/+27
2022-01-17Rollup merge of #92164 - WaffleLapkin:rustc_must_implement_one_of_attr, ↵Matthias Krüger-0/+256
r=Aaron1011 Implement `#[rustc_must_implement_one_of]` attribute This PR adds a new attribute — `#[rustc_must_implement_one_of]` that allows changing the "minimal complete definition" of a trait. It's similar to GHC's minimal `{-# MINIMAL #-}` pragma, though `#[rustc_must_implement_one_of]` is weaker atm. Such attribute was long wanted. It can be, for example, used in `Read` trait to make transitions to recently added `read_buf` easier: ```rust #[rustc_must_implement_one_of(read, read_buf)] pub trait Read { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { let mut buf = ReadBuf::new(buf); self.read_buf(&mut buf)?; Ok(buf.filled_len()) } fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> { default_read_buf(|b| self.read(b), buf) } } impl Read for Ty0 {} //^ This will fail to compile even though all `Read` methods have default implementations // Both of these will compile just fine impl Read for Ty1 { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { /* ... */ } } impl Read for Ty2 { fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> { /* ... */ } } ``` For now, this is implemented as an internal attribute to start experimenting on the design of this feature. In the future we may want to extend it: - Allow arbitrary requirements like `a | (b & c)` - Allow multiple requirements like - ```rust #[rustc_must_implement_one_of(a, b)] #[rustc_must_implement_one_of(c, d)] ``` - Make it appear in rustdoc documentation - Change the syntax? - Etc Eventually, we should make an RFC and make this (or rather similar) attribute public. --- I'm fairly new to compiler development and not at all sure if the implementation makes sense, but at least it passes tests :)
2022-01-14Do not use `HashSet` for `#[rustc_must_implement_one_of]`Maybe Waffle-3/+3
2022-01-14Check for duplicate arguments in `#[rustc_must_implement_one_of]`Maybe Waffle-0/+53
2022-01-11Add a test for ungated `#[rustc_must_implement_one_of]`Maybe Waffle-0/+24
This test checks that `#[rustc_must_implement_one_of]` is gated behind `#![feature(rustc_attrs)]`.
2022-01-10Rollup merge of #92248 - compiler-errors:normalize-type-for-pointee, r=jackh726Matthias Krüger-0/+22
Normalize struct tail type when checking Pointee trait Let's go ahead and implement the FIXMEs by properly normalizing the struct-tail type when satisfying a Pointee obligation. This should fix the ICE when we try to calculate a layout depending on `<Ty as Pointee>::Metadata` later. Fixes #92128 Fixes #92577 Additionally, mark the obligation as ambiguous if there are any infer types in that struct-tail type. This has the effect of causing `<_ as Pointee>::Metadata` to be properly replaced with an infer variable ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/project.rs#L813)) and registered as an obligation... this turns out to be very important in unifying function parameters with formals that are assoc types. Fixes #91446
2022-01-09Apply suggestions from code reviewWaffle Maybe-17/+17
Use "(associated) function" terminology instead of "method". Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
2022-01-09Move `#[rustc_must_implement_one_of]` tests to fix tidy checkMaybe Waffle-0/+179
2021-12-29Add UI test for #92292Wang Ruochen-0/+32
Closes #92292
2021-12-24Normalize struct tail type when checking Pointee traitMichael Goulet-0/+22
2021-12-20Auto merge of #92041 - Aaron1011:remove-speculative-evaluation, r=jackh726bors-0/+34
Remove 'speculative evaluation' of predicates Performing 'speculative evaluation' introduces caching bugs that cannot be fixed without invasive changes to projection. Hopefully, we can win back most of the performance lost by re-adding 'cache completion' Fixes #90662
2021-12-18Rollup merge of #89090 - cjgillot:bare-dyn, r=jackh726Matthias Krüger-1/+6
Lint bare traits in AstConv. Removing the lint from lowering allows to: - make lowering querification easier; - have the lint implementation in only one place. r? `@estebank`
2021-12-17Remove 'speculative evaluation' of predicatesAaron Hill-0/+34
Performing 'speculative evaluation' introduces caching bugs that cannot be fixed without invasive changes to projection. Hopefully, we can win back most of the performance lost by re-adding 'cache completion' Fixes #90662
2021-12-13Fix HashStable implementation on InferTyMichael Goulet-0/+17
2021-12-11Auto merge of #91769 - estebank:type-trait-bound-span-2, r=oli-obkbors-10/+23
Tweak assoc type obligation spans * Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors r? `@oli-obk` This is a(n uncontroversial) subset of #85799.
2021-12-11Tweak assoc type obligation spansEsteban Kuber-10/+23
* Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors
2021-12-10Tweak wordingEsteban Kuber-7/+7
2021-12-10Use a more accurate `Span` for `'static` obligation from return typeEsteban Kuber-8/+8
2021-12-10Point at return type when it introduces `'static` obligationEsteban Kuber-0/+32
2021-12-10Clean up visual output logicEsteban Kuber-9/+9
2021-12-10Point at capture points for non-`'static` reference crossing a `yield` pointEsteban Kuber-2/+64
``` error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-72312.rs:10:24 | LL | pub async fn start(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... ... LL | require_static(async move { | -------------- ...is required to live as long as `'static` here... LL | &self; | ----- ...and is captured here | note: `'static` lifetime requirement introduced by this trait bound --> $DIR/issue-72312.rs:2:22 | LL | fn require_static<T: 'static>(val: T) -> T { | ^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0759`. ``` Fix #72312.
2021-12-04Use multipart suggestions.Camille GILLOT-1/+6
2021-12-03Add test case that evals to `EvaluatedToOkModuloRegions`Wesley Wiser-1/+32
2021-12-03Add test with `#[rustc_evaluate_where_clauses]`Wesley Wiser-0/+150
As suggested via reviewer feedback.
2021-11-28Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives`Aaron Hill-0/+77
A global predicate is not guarnatenteed to outlive all regions. If the predicate involves late-bound regions, then it may fail to outlive other regions (e.g. `for<'b> &'b bool: 'static` does not hold) We now only produce `EvaluatedToOk` when a global predicate has no late-bound regions - in that case, the ony region that can be present in the type is 'static
2021-11-20Align multiline messages to their label (add left margin)Esteban Kuber-148/+148
2021-11-20Do not mention associated items when they introduce an obligationEsteban Kuber-93/+0
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-21/+73
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-18Move some tests to more reasonable directoriesCaio-0/+132
2021-11-16Rollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkovYuki Okushi-9/+3
Fixes incorrect handling of TraitRefs when emitting suggestions. Closes #90804 , although there were more issues here that were hidden by the thing that caused this ICE. Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations. This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
2021-11-14Move some tests to more reasonable directoriesCaio-0/+409
2021-11-13Fix handling of substitutions and binders when deciding whether to suggest ↵Jakob Degen-9/+3
references When suggesting references, substitutions were being forgotten and some types were misused. This led to at least one ICE and other incorrectly emitted diagnostics. This has been fixed; in some cases this leads to diagnostics changing, and tests have been adjusted.
2021-11-10no overlap errors after failing the orphan checklcnr-14/+14
2021-11-06Move some tests to more reasonable directoriesCaio-0/+248
2021-10-28Add test casesIlya Yanok-0/+41
2021-10-25fix(rustc_typeck): report function argument errors on matching typeMichael Howell-3/+3
Fixes #90101
2021-10-24Always sort suggestions before emitting themEsteban Kuber-2/+2
2021-10-24Point at overlapping impls when type annotations are neededEsteban Kuber-15/+117
2021-10-23Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakisbors-22/+13
Implement coherence checks for negative trait impls The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3). This feature is necessary to handle the following from impl on box. ```rust impl From<&str> for Box<dyn Error> { ... } ``` Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile. We would have this in `alloc`: ```rust impl From<&str> for Box<dyn Error> {} // A impl<E> From<E> for Box<dyn Error> where E: Error {} // B ``` and this in `core`: ```rust trait Error {} impl !Error for &str {} ``` r? `@nikomatsakis` This PR was built on top of `@yaahc` PR #85764. Language team proposal: to https://github.com/rust-lang/lang-team/issues/96