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
a4dd8507
Commit
a4dd8507
authored
Jul 26, 2020
by
bors
Browse files
Options
Browse Files
Download
Plain Diff
Auto merge of #74735 - Aaron1011:fix/wf-impl-self-type, r=estebank
Use the proper span when WF-checking an impl self type
parents
8e5489ca
116ad51c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
12 deletions
+43
-12
src/librustc_trait_selection/traits/wf.rs
src/librustc_trait_selection/traits/wf.rs
+12
-4
src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr
...herence/coherence-impl-trait-for-trait-object-safe.stderr
+2
-2
src/test/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr
...eature-gates/feature-gate-object_safe_for_dispatch.stderr
+2
-2
src/test/ui/issues/issue-21837.stderr
src/test/ui/issues/issue-21837.stderr
+2
-2
src/test/ui/unsized/unsized-trait-impl-self-type.stderr
src/test/ui/unsized/unsized-trait-impl-self-type.stderr
+2
-2
src/test/ui/wf/wf-impl-self-type.rs
src/test/ui/wf/wf-impl-self-type.rs
+7
-0
src/test/ui/wf/wf-impl-self-type.stderr
src/test/ui/wf/wf-impl-self-type.stderr
+16
-0
No files found.
src/librustc_trait_selection/traits/wf.rs
View file @
a4dd8507
...
...
@@ -300,13 +300,21 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
trait_ref
.substs
.iter
()
.filter
(|
arg
|
{
.enumerate
()
.filter
(|(
_
,
arg
)|
{
matches!
(
arg
.unpack
(),
GenericArgKind
::
Type
(
..
)
|
GenericArgKind
::
Const
(
..
))
})
.filter
(|
arg
|
!
arg
.has_escaping_bound_vars
())
.map
(|
arg
|
{
.filter
(|(
_
,
arg
)|
!
arg
.has_escaping_bound_vars
())
.map
(|(
i
,
arg
)|
{
let
mut
new_cause
=
cause
.clone
();
// The first subst is the self ty - use the correct span for it.
if
i
==
0
{
if
let
Some
(
hir
::
ItemKind
::
Impl
{
self_ty
,
..
})
=
item
.map
(|
i
|
&
i
.kind
)
{
new_cause
.make_mut
()
.span
=
self_ty
.span
;
}
}
traits
::
Obligation
::
new
(
cause
.clone
()
,
new_cause
,
param_env
,
ty
::
PredicateKind
::
WellFormed
(
arg
)
.to_predicate
(
tcx
),
)
...
...
src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr
View file @
a4dd8507
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:
6
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:
24
|
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
| ------------- ---- ...because method `eq` references the `Self` type in this parameter
| |
| this trait cannot be made into an object...
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
|
^^^^
^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
|
= help: consider moving `eq` to another trait
...
...
src/test/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr
View file @
a4dd8507
...
...
@@ -52,7 +52,7 @@ LL | fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> {
= help: consider moving `foo` to another trait
error[E0038]: the trait `NonObjectSafe1` cannot be made into an object
--> $DIR/feature-gate-object_safe_for_dispatch.rs:38:6
--> $DIR/feature-gate-object_safe_for_dispatch.rs:38:
1
6
|
LL | trait NonObjectSafe1: Sized {}
| -------------- ----- ...because it requires `Self: Sized`
...
...
@@ -60,7 +60,7 @@ LL | trait NonObjectSafe1: Sized {}
| this trait cannot be made into an object...
...
LL | impl Trait for dyn NonObjectSafe1 {}
| ^^^^^ the trait `NonObjectSafe1` cannot be made into an object
|
^^^^^^^^^^^^^
^^^^^ the trait `NonObjectSafe1` cannot be made into an object
error: aborting due to 5 previous errors
...
...
src/test/ui/issues/issue-21837.stderr
View file @
a4dd8507
error[E0277]: the trait bound `T: Bound` is not satisfied
--> $DIR/issue-21837.rs:8:
9
--> $DIR/issue-21837.rs:8:
20
|
LL | pub struct Foo<T: Bound>(T);
| ----- required by this bound in `Foo`
...
LL | impl<T> Trait2 for Foo<T> {}
| ^^^^^^ the trait `Bound` is not implemented for `T`
|
^^^^^^ the trait `Bound` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
...
...
src/test/ui/unsized/unsized-trait-impl-self-type.stderr
View file @
a4dd8507
error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized-trait-impl-self-type.rs:10:
1
7
--> $DIR/unsized-trait-impl-self-type.rs:10:
2
7
|
LL | struct S5<Y>(Y);
| - required by this bound in `S5`
LL |
LL | impl<X: ?Sized> T3<X> for S5<X> {
| - ^^^^^ doesn't have a size known at compile-time
| -
^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|
...
...
src/test/ui/wf/wf-impl-self-type.rs
0 → 100644
View file @
a4dd8507
// Tests that we point at the proper location for an error
// involving the self-type of an impl
trait
Foo
{}
impl
Foo
for
Option
<
[
u8
]
>
{}
//~ ERROR the size for
fn
main
()
{}
src/test/ui/wf/wf-impl-self-type.stderr
0 → 100644
View file @
a4dd8507
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/wf-impl-self-type.rs:5:14
|
LL | impl Foo for Option<[u8]> {}
| ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
::: $SRC_DIR/libcore/option.rs:LL:COL
|
LL | pub enum Option<T> {
| - required by this bound in `std::option::Option`
|
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
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