Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
rust
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
rust
Commits
31a3bb59
Commit
31a3bb59
authored
Jul 25, 2020
by
Tyler Mandry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove manual normalization in compare_projection_bounds
parent
83a9dc92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
54 deletions
+25
-54
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/compare_method.rs
+3
-50
src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs
...ui/generic-associated-types/unsatisfied-outlives-bound.rs
+1
-1
src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr
...eneric-associated-types/unsatisfied-outlives-bound.stderr
+21
-3
No files found.
src/librustc_typeck/check/compare_method.rs
View file @
31a3bb59
...
...
@@ -6,15 +6,14 @@ use rustc_hir::{GenericParamKind, ImplItemKind, TraitItemKind};
use
rustc_infer
::
infer
::{
self
,
InferOk
,
TyCtxtInferExt
};
use
rustc_middle
::
ty
;
use
rustc_middle
::
ty
::
error
::{
ExpectedFound
,
TypeError
};
use
rustc_middle
::
ty
::
subst
::{
InternalSubsts
,
Subst
,
SubstsRef
};
use
rustc_middle
::
ty
::
subst
::{
InternalSubsts
,
Subst
};
use
rustc_middle
::
ty
::
util
::
ExplicitSelf
;
use
rustc_middle
::
ty
::{
GenericParamDefKind
,
ToPredicate
,
TyCtxt
,
WithConstness
};
use
rustc_middle
::
ty
::{
GenericParamDefKind
,
ToPredicate
,
TyCtxt
};
use
rustc_span
::
Span
;
use
rustc_trait_selection
::
traits
::
error_reporting
::
InferCtxtExt
;
use
rustc_trait_selection
::
traits
::{
self
,
ObligationCause
,
ObligationCauseCode
,
Reveal
};
use
super
::{
potentially_plural_count
,
FnCtxt
,
Inherited
};
use
std
::
iter
;
/// Checks that a method from an impl conforms to the signature of
/// the same method as declared in the trait.
...
...
@@ -1240,22 +1239,6 @@ fn compare_projection_bounds<'tcx>(
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
Reveal
::
UserFacing
,
None
)
};
// Map the predicate from the trait to the corresponding one for the impl.
// For example:
//
// trait X<A> { type Y<'a>: PartialEq<A> } impl X for T { type Y<'a> = &'a S; }
// impl<'x> X<&'x u32> for () { type Y<'c> = &'c u32; }
//
// For the `for<'a> <<Self as X<A>>::Y<'a>: PartialEq<A>` bound, this
// function would translate and partially normalize
// `[<Self as X<A>>::Y<'a>, A]` to `[&'a u32, &'x u32]`.
let
translate_predicate_substs
=
move
|
predicate_substs
:
SubstsRef
<
'tcx
>
|
{
tcx
.mk_substs
(
iter
::
once
(
impl_ty_value
.into
())
.chain
(
predicate_substs
[
1
..
]
.iter
()
.map
(|
s
|
s
.subst
(
tcx
,
rebased_substs
))),
)
};
tcx
.infer_ctxt
()
.enter
(
move
|
infcx
|
{
let
inh
=
Inherited
::
new
(
infcx
,
impl_ty
.def_id
.expect_local
());
let
infcx
=
&
inh
.infcx
;
...
...
@@ -1270,39 +1253,10 @@ fn compare_projection_bounds<'tcx>(
);
let
predicates
=
tcx
.projection_predicates
(
trait_ty
.def_id
);
debug!
(
"compare_projection_bounds: projection_predicates={:?}"
,
predicates
);
for
predicate
in
predicates
{
let
concrete_ty_predicate
=
match
predicate
.kind
()
{
ty
::
PredicateKind
::
Trait
(
poly_tr
,
c
)
=>
poly_tr
.map_bound
(|
tr
|
{
let
trait_substs
=
translate_predicate_substs
(
tr
.trait_ref.substs
);
ty
::
TraitRef
{
def_id
:
tr
.def_id
(),
substs
:
trait_substs
}
})
.with_constness
(
*
c
)
.to_predicate
(
tcx
),
ty
::
PredicateKind
::
Projection
(
poly_projection
)
=>
poly_projection
.map_bound
(|
projection
|
{
let
projection_substs
=
translate_predicate_substs
(
projection
.projection_ty.substs
);
ty
::
ProjectionPredicate
{
projection_ty
:
ty
::
ProjectionTy
{
substs
:
projection_substs
,
item_def_id
:
projection
.projection_ty.item_def_id
,
},
ty
:
projection
.ty
.subst
(
tcx
,
rebased_substs
),
}
})
.to_predicate
(
tcx
),
ty
::
PredicateKind
::
TypeOutlives
(
poly_outlives
)
=>
poly_outlives
.map_bound
(|
outlives
|
{
ty
::
OutlivesPredicate
(
impl_ty_value
,
outlives
.1
.subst
(
tcx
,
rebased_substs
))
})
.to_predicate
(
tcx
),
_
=>
bug!
(
"unexepected projection predicate kind: `{:?}`"
,
predicate
),
};
let
concrete_ty_predicate
=
predicate
.subst
(
tcx
,
rebased_substs
);
debug!
(
"compare_projection_bounds: concrete predicate = {:?}"
,
concrete_ty_predicate
);
let
traits
::
Normalized
{
value
:
normalized_predicate
,
obligations
}
=
traits
::
normalize
(
...
...
@@ -1311,7 +1265,6 @@ fn compare_projection_bounds<'tcx>(
normalize_cause
.clone
(),
&
concrete_ty_predicate
,
);
debug!
(
"compare_projection_bounds: normalized predicate = {:?}"
,
normalized_predicate
);
inh
.register_predicates
(
obligations
);
...
...
src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs
View file @
31a3bb59
...
...
@@ -7,7 +7,7 @@ trait ATy {
impl
<
'b
>
ATy
for
&
'b
()
{
type
Item
<
'a
>
=
&
'b
();
//~^ ERROR
does not fulfill the required
lifetime
//~^ ERROR
cannot infer an appropriate
lifetime
}
trait
StaticTy
{
...
...
src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr
View file @
31a3bb59
error[E04
77]: the type `&'b ()` does not fulfill the required lifetime
error[E04
95]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
--> $DIR/unsatisfied-outlives-bound.rs:9:5
|
LL | type Item<'a> = &'b ();
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'a` as defined on the associated item at 9:15
note: first, the lifetime cannot outlive the lifetime `'b` as defined on the impl at 8:6...
--> $DIR/unsatisfied-outlives-bound.rs:8:6
|
LL | impl<'b> ATy for &'b () {
| ^^
note: ...so that the types are compatible
--> $DIR/unsatisfied-outlives-bound.rs:9:5
|
LL | type Item<'a> = &'b ();
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `ATy`
found `ATy`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the associated item at 9:15...
--> $DIR/unsatisfied-outlives-bound.rs:9:15
|
LL | type Item<'a> = &'b ();
| ^^
note: ...so that the type `&()` will meet its required lifetime bounds
--> $DIR/unsatisfied-outlives-bound.rs:9:5
|
LL | type Item<'a> = &'b ();
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0477]: the type `&'a ()` does not fulfill the required lifetime
--> $DIR/unsatisfied-outlives-bound.rs:18:5
...
...
@@ -20,4 +37,5 @@ LL | type Item<'a> = &'a ();
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0477`.
Some errors have detailed explanations: E0477, E0495.
For more information about an error, try `rustc --explain E0477`.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment