about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2023-11-19Rollup merge of #117994 - compiler-errors:throw-away-regions-in-coherence, ↵Michael Goulet-9/+8
r=lcnr Ignore but do not assume region obligations from unifying headers in negative coherence Partly addresses a FIXME that was added in #112875. Just as we can throw away the nested trait/projection obligations from unifying two impl headers, we can also just throw away the region obligations too. I removed part of the FIXME that was incorrect, namely: > Given that the only region constraints we get are involving inference regions in the root, it shouldn't matter, but still sus. This is not true when unifying `fn(A)` and `for<'b> fn(&'b B)` which ends up with placeholder region outlives from non-root universes. I'm pretty sure this is okay, though it would be nice if we were to use them as assumptions. See the `explicit` revision of the test I committed, which still fails. Fixes #117986 r? lcnr, feel free to reassign tho.
2023-11-19Ignore but do not assume region obligations from unifying headers in ↵Michael Goulet-9/+8
negative coherence
2023-11-19Make regionck care about placeholders in outlives componentsMichael Goulet-2/+11
2023-11-18Auto merge of #117742 - ↵bors-13/+97
weiznich:turn_overlapping_diagnostic_options_into_warnings, r=compiler-errors Add some additional warnings for duplicated diagnostic items This commit adds warnings if a user supplies several diagnostic options where we can only apply one of them. We explicitly warn about ignored options here. In addition a small test for these warnings is added. r? `@compiler-errors` For now that's the last PR to improve the warnings generated by misused `#[diagnostic::on_unimplemented]` attributes. I'm not sure what needs to be done next to move this closer to stabilization.
2023-11-17Auto merge of #117944 - lcnr:region-refactor-uwu, r=BoxyUwUbors-9/+11
some additional region refactorings the commits are selfcontained ✨ r? `@BoxyUwU`
2023-11-17Auto merge of #112422 - aliemjay:implied-bounds-placeholders, r=lcnrbors-2/+6
ignore implied bounds with placeholders given the following code: ```rust trait Trait { type Ty<'a> where Self: 'a; } impl<T> Trait for T { type Ty<'a> = () where Self: 'a; } struct Foo<T: Trait>(T) where for<'x> T::Ty<'x>: Sized; ``` when computing the implied bounds from `Foo<X>` we incorrectly get the bound `X: !x` from the normalization of ` for<'x> <X as Trait>::Ty::<'x>: Sized`. This is a a known bug! we shouldn't use the constraints that arise from normalization as implied bounds. See #109628. Ignore these bounds for now. This should prevent later ICEs. Fixes #112250 Fixes #107409
2023-11-17rename bound region instantiationlcnr-9/+11
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17Add some additional warnings for duplicated diagnostic itemsGeorg Semmler-13/+97
This commit adds warnings if a user supplies several diagnostic options where we can only apply one of them. We explicitly warn about ignored options here. In addition a small test for these warnings is added.
2023-11-16ignore implied bounds with placeholdersAli MJ Al-Nasrawy-2/+6
2023-11-15Re-format code with new rustfmtMark Rousskov-33/+53
2023-11-15Auto merge of #117878 - gavinleroy:proper-depth-check, r=lcnrbors-1/+7
Fix depth check in ProofTreeVisitor. The hack to cutoff overflows and cycles in the new trait solver was incorrect. We want to inspect everything with depth [0..10]. This fix exposed a previously unseen bug, which caused the compiler to ICE when invoking `trait_ref` on a non-assoc type projection. I simply added the guard in the `AmbiguityCausesVisitor`, and updated the expected output for the `auto-trait-coherence` test which now includes the extra note: ```text | = note: upstream crates may add a new impl of trait `std::marker::Send` for type `OpaqueType` in future versions ``` r? `@lcnr`
2023-11-14finish `RegionKind` renamelcnr-1/+1
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`
2023-11-14Add guard checking for associated types before computing intercrate ↵Gavin Gray-1/+7
ambiguity of projections. Bless test with more specific notes on the ambiguity cause.
2023-11-13Rollup merge of #117870 - lcnr:rename-args_ref, r=compiler-errorsMatthias Krüger-2/+2
`fn args_ref_X` to `fn args_X`
2023-11-13Auto merge of #117881 - TaKO8Ki:rollup-n7jtmgj, r=TaKO8Kibors-7/+2
Rollup of 5 pull requests Successful merges: - #117737 (Remove `-Zkeep-hygiene-data`.) - #117830 (Small improvements in object lifetime default code) - #117858 (Compute layout with spans for better cycle errors in coroutines) - #117863 (Remove some unused stuff from `rustc_index`) - #117872 (Cranelift isn't available on non-nightly channels) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-13update type flagslcnr-4/+4
- `HAS_RE_LATE_BOUND` -> `HAS_RE_BOUND` - `HAS_TY_LATE_BOUND` -> `HAS_TY_BOUND` - `HAS_CT_LATE_BOUND` -> `HAS_CT_BOUND` - `HAS_LATE_BOUND` -> `HAS_BOUND_VARS` - `fn has_late_bound_regions` -> `fn has_bound_regions` - `fnhas_non_region_late_bound` -> `fn has_non_region_bound_vars` - `fn has_late_bound_vars` -> `fn has_bound_vars`
2023-11-13continue renaminglcnr-13/+13
- `RegionVariableOrigin::~~Late~~BoundRegion` - `~~Late~~BoundRegionConversionTime`
2023-11-13rename `ReLateBound` to `ReBound`lcnr-13/+13
other changes: - `Region::new_late_bound` -> `Region::new_bound` - `Region::is_late_bound` -> `Region::is_bound`
2023-11-13args~~_ref~~_may_unifylcnr-2/+2
2023-11-12Small improvements in object lifetime default codeNilstrieb-7/+2
I found those while trying to understand how the code works.
2023-11-09Rollup merge of #117645 - compiler-errors:auto-trait-subst, r=petrochenkovTakayuki Maeda-6/+15
Extend builtin/auto trait args with error when they have >1 argument Reuse `extend_with_error` to add error args to any auto trait (or built-in trait like `Copy` that is defined incorrectly) that has additional non-`Self` args. Fixes #117628
2023-11-08Rollup merge of #113925 - clubby789:const-ctor-repeat, r=estebankMatthias Krüger-9/+20
Improve diagnostic for const ctors in array repeat expressions Fixes #113912
2023-11-06Don't instantiate the binder twice when assembling object candidateMichael Goulet-17/+7
2023-11-06Only check predicates for late-bound non-lifetime vars in object candidate ↵Michael Goulet-1/+4
assembly
2023-11-06Extend builtin/auto trait args with error when they have >1 argumentMichael Goulet-6/+15
2023-11-06Auto merge of #117585 - dnbln:feat/move-kw-span, r=cjgillotbors-1/+1
Add the `Span` of the `move` keyword to the HIR. This is required to implement a lint like the one described here: https://github.com/rust-lang/rust-clippy/issues/11721
2023-11-04Rollup merge of #117583 - compiler-errors:placeholderconst-lifetime, r=cjgillotMatthias Krüger-5/+5
Remove `'tcx` lifetime on `PlaceholderConst` The `'tcx` lifetime is not needed for anything, so this is a continuation of #117139.
2023-11-04Fix remaining uses of `CaptureBy::Value`Dinu Blanovschi-1/+1
2023-11-04No lifetime on PlaceholderConstMichael Goulet-5/+5
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-4/+3
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-03Auto merge of #116439 - compiler-errors:on-unimplemented, r=davidtwcobors-0/+14
Pretty print `Fn` traits in `rustc_on_unimplemented` I don't think that users really ever should need to think about `Fn*` traits' tupled args for a simple trait error. r? diagnostics
2023-11-02Auto merge of #117134 - lcnr:dropck_outlives-coroutine, r=compiler-errorsbors-13/+22
dropck_outlives check whether generator witness needs_drop see https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/.23116242.3A.20Code.20no.20longer.20compiles.20after.20-Zdrop-tracking-mir.20.E2.80.A6/near/398311627 for an explanation. Fixes #116242 (or well, the repro by `@jamuraa` in https://github.com/rust-lang/rust/issues/116242#issuecomment-1739802047). I did not add a regression test as it depends on other crates. We do have 1 test going from fail to pass, showing the intended behavior. r? types
2023-11-02Pretty print Fn traits in rustc_on_unimplementedMichael Goulet-0/+14
2023-11-02only erase param env regions where neededlcnr-1/+1
2023-11-02dropck_outlives check generator witness needs_droplcnr-13/+22
2023-11-02Rollup merge of #117394 - lcnr:proof-tree-cache4, r=compiler-errorsMatthias Krüger-2/+2
use global cache when computing proof trees we're writing the solver while relying on the existence of the global cache to avoid exponential blowup. By disabling the global cache when building proof trees, it is easy to get hangs, e.g. when computing intercrate ambiguity causes. Removes the unstable `-Zdump_solver_proof_tree_use_cache` option, as we now always return a full proof tree. r? `@compiler-errors`
2023-11-02use global cache when computing proof treeslcnr-2/+2
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-4/+3
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-31Auto merge of #117419 - compiler-errors:gen, r=oli-obkbors-22/+23
Some more coroutine renamings a few places where `gen_` names leaked through but should be coroutine. r? oli-obk
2023-10-30Some more coroutine renamingsMichael Goulet-22/+23
2023-10-30Auto merge of #116405 - estebank:issue-103155, r=davidtwcobors-2/+2
Detect object safety errors when assoc type is missing When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with. Fix #103155.
2023-10-30Detect object safety errors when assoc type is missingEsteban Küber-2/+2
When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with. Fix #103155.
2023-10-30Don't super-fold types when we hit the recursion limitMichael Goulet-7/+4
2023-10-30Rollup merge of #117205 - weiznich:multiple_notes_for_on_unimplemented, ↵León Orell Valerian Liehr-22/+24
r=compiler-errors Allows `#[diagnostic::on_unimplemented]` attributes to have multiple notes This commit extends the `#[diagnostic::on_unimplemented]` (and `#[rustc_on_unimplemented]`) attributes to allow multiple `note` options. This enables emitting multiple notes for custom error messages. For now I've opted to not change any of the existing usages of `#[rustc_on_unimplemented]` and just updated the relevant compile tests. r? `@compiler-errors` I'm happy to adjust any of the existing changed location to emit the old error message if that's desired.
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-4/+139
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-28Rollup merge of #116945 - estebank:sealed-trait-impls, r=petrochenkovJubilee-2/+28
When encountering sealed traits, point types that implement it ``` error[E0277]: the trait bound `S: d::Hidden` is not satisfied --> $DIR/sealed-trait-local.rs:53:20 | LL | impl c::Sealed for S {} | ^ the trait `d::Hidden` is not implemented for `S` | note: required by a bound in `c::Sealed` --> $DIR/sealed-trait-local.rs:17:23 | LL | pub trait Sealed: self::d::Hidden { | ^^^^^^^^^^^^^^^ required by this bound in `Sealed` = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `c::d::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it = help: the following types implement the trait: - c::X - c::Y ``` The last `help` is new.
2023-10-28Rollup merge of #116739 - Milo123459:milo/short-paths, r=estebankJubilee-5/+11
Make `E0277` use short paths Fixes #116616
2023-10-27Update type_err_ctxt_ext.rsMilo-2/+2
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2023-10-27When encountering sealed traits, point types that implement itEsteban Küber-2/+28
``` error[E0277]: the trait bound `S: d::Hidden` is not satisfied --> $DIR/sealed-trait-local.rs:53:20 | LL | impl c::Sealed for S {} | ^ the trait `d::Hidden` is not implemented for `S` | note: required by a bound in `c::Sealed` --> $DIR/sealed-trait-local.rs:17:23 | LL | pub trait Sealed: self::d::Hidden { | ^^^^^^^^^^^^^^^ required by this bound in `Sealed` = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `c::d::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it = help: the following types implement the trait: - c::X - c::Y ``` The last `help` is new.
2023-10-27Make `gen` blocks implement the `Iterator` traitOli Scherer-3/+120