Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #121761

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8d0d4ce
AST: Refactor type alias where clauses
fmease Feb 19, 2024
dbd70e5
Detect empty leading where-clauses on type aliases
fmease Feb 20, 2024
ffc9e83
Improve error messages for generics with default parameters
veera-sivarajan Feb 21, 2024
97e00a7
Avoid code duplication
veera-sivarajan Feb 23, 2024
3927057
Update item order in test
veera-sivarajan Feb 23, 2024
2aa8a1d
std: make `ReentrantLock` public
joboet Mar 28, 2023
5df9593
Prevent inclusion of whitespace character after macro_rules ident
GuillaumeGomez Feb 27, 2024
67f14e8
Add a comment about how `IntoDiagnostic` should be impl'd.
nnethercote Feb 27, 2024
c0e0d13
try_with_capacity for RawVec
kornelski Jan 30, 2024
990fd60
try_with_capacity for Vec, VecDeque, String
kornelski Jan 30, 2024
196522b
Move capacity_overflow function to make ui tests change less
kornelski Jan 31, 2024
bac96bd
Refactor `DiagCtxtInner::flush_delayed`.
nnethercote Feb 27, 2024
951f2d9
Use `LitKind::Err` for floats with empty exponents.
nnethercote Feb 28, 2024
7976609
Reformat `float-field.rs` test.
nnethercote Feb 28, 2024
840c8d3
Use `LitKind::Err` for floats with unsupported bases.
nnethercote Feb 28, 2024
12b991d
Don't panic when encountering unexpected constructor
Nadrieril Feb 28, 2024
632d26a
Add regression test for inclusion of whitespace characters in rustdoc…
GuillaumeGomez Feb 27, 2024
5cdbe83
Opportunistically resolve regions when processing region outlives obl…
compiler-errors Feb 27, 2024
90244b7
Rollup merge of #110543 - joboet:reentrant_lock, r=m-ou-se
GuillaumeGomez Feb 28, 2024
f38a60b
Rollup merge of #120504 - kornelski:try_with_capacity, r=Amanieu
GuillaumeGomez Feb 28, 2024
a426716
Rollup merge of #121326 - fmease:detect-empty-leading-where-clauses-o…
GuillaumeGomez Feb 28, 2024
0d5303a
Rollup merge of #121416 - veera-sivarajan:bugfix-120785, r=nnethercote
GuillaumeGomez Feb 28, 2024
fd3b535
Rollup merge of #121689 - GuillaumeGomez:rustdoc-highlighting-whitesp…
GuillaumeGomez Feb 28, 2024
9704475
Rollup merge of #121723 - nnethercote:two-diagnostic-things, r=oli-obk
GuillaumeGomez Feb 28, 2024
cd01b13
Rollup merge of #121724 - nnethercote:LitKind-Err-for-floats, r=fmease
GuillaumeGomez Feb 28, 2024
74fbbaa
Rollup merge of #121735 - Nadrieril:no-panic-on-type-error, r=compile…
GuillaumeGomez Feb 28, 2024
1c10897
Rollup merge of #121743 - compiler-errors:opportunistically-resolve-r…
GuillaumeGomez Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Opportunistically resolve regions when processing region outlives obl…
…igations
  • Loading branch information
compiler-errors committed Feb 28, 2024
commit 5cdbe83af82e0e48a05bc87ff41ef381e45391dc
10 changes: 9 additions & 1 deletion compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@
use crate::infer::outlives::components::{push_outlives_components, Component};
use crate::infer::outlives::env::RegionBoundPairs;
use crate::infer::outlives::verify::VerifyBoundCx;
use crate::infer::resolve::OpportunisticRegionResolver;
use crate::infer::{
self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, UndoLog, VerifyBound,
};
use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{self, GenericArgsRef, Region, Ty, TyCtxt, TypeVisitableExt};
use rustc_middle::ty::{
self, GenericArgsRef, Region, Ty, TyCtxt, TypeFoldable as _, TypeVisitableExt,
};
use rustc_middle::ty::{GenericArgKind, PolyTypeOutlivesPredicate};
use rustc_span::DUMMY_SP;
use smallvec::smallvec;
Expand Down Expand Up @@ -176,6 +179,11 @@ impl<'tcx> InferCtxt<'tcx> {
.map_err(|NoSolution| (outlives, origin.clone()))?
.no_bound_vars()
.expect("started with no bound vars, should end with no bound vars");
// `TypeOutlives` is structural, so we should try to opportunistically resolve all
// region vids before processing regions, so we have a better chance to match clauses
// in our param-env.
let (sup_type, sub_region) =
(sup_type, sub_region).fold_with(&mut OpportunisticRegionResolver::new(self));

debug!(?sup_type, ?sub_region, ?origin);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait MessageListenersInterface {

impl<'a> MessageListenersInterface for MessageListeners<'a> {
fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> {
//~^ ERROR cannot infer an appropriate lifetime for lifetime parameter 'b in generic type due to conflicting requirements
//~^ ERROR in type `&'a MessageListeners<'_>`, reference has a longer lifetime than the data it references
self
}
}
Expand Down
20 changes: 4 additions & 16 deletions tests/ui/implied-bounds/impl-implied-bounds-compatibility.stderr
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'b in generic type due to conflicting requirements
error[E0491]: in type `&'a MessageListeners<'_>`, reference has a longer lifetime than the data it references
--> $DIR/impl-implied-bounds-compatibility.rs:12:5
|
LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'c` as defined here...
--> $DIR/impl-implied-bounds-compatibility.rs:12:5
|
LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...so that the method type is compatible with trait
--> $DIR/impl-implied-bounds-compatibility.rs:12:5
|
LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `fn(&'c MessageListeners<'_>) -> &'c MessageListeners<'c>`
found `fn(&MessageListeners<'_>) -> &'a MessageListeners<'_>`
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
note: the pointer is valid for the lifetime `'a` as defined here
--> $DIR/impl-implied-bounds-compatibility.rs:11:6
|
LL | impl<'a> MessageListenersInterface for MessageListeners<'a> {
| ^^
note: ...so that the reference type `&'a MessageListeners<'_>` does not outlive the data it points at
note: but the referenced data is only valid for the lifetime `'c` as defined here
--> $DIR/impl-implied-bounds-compatibility.rs:12:5
|
LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0495`.
For more information about this error, try `rustc --explain E0491`.
Loading