Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
093ec70
Add new EFIAPI ABI
roblabla Oct 24, 2019
6173280
Fix EFIABI test
roblabla Oct 25, 2019
13d27af
Fix inverted check in EFIAPI
roblabla Oct 25, 2019
e54ae51
Add proper tracking issue for EFIAPI
roblabla Oct 25, 2019
174d4f9
EFIAPI: Fix symbolname tests
roblabla Oct 25, 2019
7f3c843
Refactor check_attr
varkor Oct 11, 2019
94c4dd9
Emit warning for ignored #[inline] on trait method prototypes
varkor Oct 11, 2019
66d7ef0
Emit warning for ignored #[inline] on foreign function prototypes
varkor Oct 11, 2019
af2b497
Improve comments
varkor Oct 11, 2019
4552c8f
Add test for attribute error checking on trait and foreign items
varkor Oct 11, 2019
41ee9ea
Refactor `check_track_caller`
varkor Oct 11, 2019
8042206
Handle `ImplItem` in `check_attr`
varkor Oct 13, 2019
b925eb5
Update bitflags
varkor Oct 13, 2019
e8566fb
Move handling of `#[track_caller]` to `check_attr`
varkor Oct 14, 2019
6446f19
Permit `#[target_feature]` on method implementations
varkor Oct 14, 2019
f8db8ff
Permit #[track_caller] on inherent methods
varkor Oct 24, 2019
f47f530
Make inline associated constants a future compatibility warning
varkor Oct 25, 2019
1099826
Only run efiapi test on llvm 9.0+
roblabla Oct 26, 2019
adfe9a4
Call out the types that are non local on E0117
estebank Oct 11, 2019
9b4f811
Use more targeted spans for orphan rule errors
estebank Oct 12, 2019
56aa89c
Further tweak spans for better readability
estebank Oct 12, 2019
daeafd8
Talk about specific types and remove lifetimes from output
estebank Oct 13, 2019
db1bfbd
Account for tuples in explanation
estebank Oct 13, 2019
95364df
Do not display ADT type arguments and fix rebase
estebank Oct 24, 2019
2cd28c1
add comment
estebank Oct 27, 2019
627691f
Fix rebase
estebank Oct 28, 2019
273ee61
Improve the "try using a variant of the expected type" hint.
Patryk27 Oct 18, 2019
e188e2d
Fix a previously forgotten pretty-printing test after a change to the…
Patryk27 Oct 26, 2019
5c023d6
Improve pretty-printing for compound qualified paths.
Patryk27 Oct 27, 2019
d7f99da
Update backtrace to 0.3.40
tmandry Oct 17, 2019
42d4e26
Rollup merge of #65294 - varkor:lint-inline-prototype, r=matthewjasper
Centril Oct 29, 2019
b07e8ed
Rollup merge of #65318 - estebank:coherence, r=varkor
Centril Oct 29, 2019
ffc6225
Rollup merge of #65531 - tmandry:bump-backtrace, r=cramertj
Centril Oct 29, 2019
9c5b6b2
Rollup merge of #65562 - Patryk27:master, r=estebank
Centril Oct 29, 2019
46063ed
Rollup merge of #65809 - roblabla:eficall-abi, r=nagisa
Centril Oct 29, 2019
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
Use more targeted spans for orphan rule errors
  • Loading branch information
estebank committed Oct 28, 2019
commit 9b4f811b7f646ebb7273fa3cf8f9d092a44058b5
14 changes: 8 additions & 6 deletions src/librustc/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>(
}

pub enum OrphanCheckErr<'tcx> {
NonLocalInputType(Vec<Ty<'tcx>>),
NonLocalInputType(Vec<(Ty<'tcx>, usize)>),
UncoveredTy(Ty<'tcx>),
}

Expand Down Expand Up @@ -391,8 +391,10 @@ fn orphan_check_trait_ref<'tcx>(
}

let mut non_local_spans = vec![];
for input_ty in
trait_ref.input_types().flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
for (i, input_ty) in trait_ref
.input_types()
.flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
.enumerate()
{
debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty);
if ty_is_local(tcx, input_ty, in_crate) {
Expand All @@ -402,7 +404,7 @@ fn orphan_check_trait_ref<'tcx>(
debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty);
return Err(OrphanCheckErr::UncoveredTy(input_ty))
}
non_local_spans.push(input_ty);
non_local_spans.push((input_ty, i));
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
Expand All @@ -413,7 +415,7 @@ fn orphan_check_trait_ref<'tcx>(
// parameters to the trait, with the self type appearing
// first. Find the first input type that either references a
// type parameter OR some local type.
for input_ty in trait_ref.input_types() {
for (i, input_ty) in trait_ref.input_types().enumerate() {
if ty_is_local(tcx, input_ty, in_crate) {
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);

Expand Down Expand Up @@ -442,7 +444,7 @@ fn orphan_check_trait_ref<'tcx>(
return Err(OrphanCheckErr::UncoveredTy(param));
}

non_local_spans.push(input_ty);
non_local_spans.push((input_ty, i));
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
Expand Down
49 changes: 32 additions & 17 deletions src/librustc_typeck/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
fn visit_item(&mut self, item: &hir::Item) {
let def_id = self.tcx.hir().local_def_id(item.hir_id);
// "Trait" impl
if let hir::ItemKind::Impl(.., Some(_), _, _) = item.kind {
if let hir::ItemKind::Impl(.., generics, Some(_), impl_ty, _) = &item.kind {
debug!("coherence2::orphan check: trait impl {}",
self.tcx.hir().node_to_string(item.hir_id));
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
Expand All @@ -41,28 +41,43 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
"only traits defined in the current crate can be implemented for \
arbitrary types"
);
err.span_label(sp, "impl doesn't use types inside crate");
for ty in &tys {
err.note(&format!("`{}` is not defined in the current create", ty));
err.span_label(sp, "impl doesn't use only types from inside the current crate");
for (ty, i) in &tys {
let msg = format!("`{}` is not defined in the current crate", ty);
if *i == 0 {
err.span_label(impl_ty.span, &msg);
} else {
err.note(&msg);
}
}
err.note("define and implement a trait or new type instead");
err.emit();
return;
}
Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => {
struct_span_err!(self.tcx.sess,
sp,
E0210,
"type parameter `{}` must be used as the type parameter \
for some local type (e.g., `MyStruct<{}>`)",
param_ty,
param_ty)
.span_label(sp,
format!("type parameter `{}` must be used as the type \
parameter for some local type", param_ty))
.note("only traits defined in the current crate can be implemented \
for a type parameter")
.emit();
let mut sp = sp;
for param in &generics.params {
if param.name.ident().to_string() == param_ty.to_string() {
sp = param.span;
}
}
let mut err = struct_span_err!(
self.tcx.sess,
sp,
E0210,
"type parameter `{}` must be used as the type parameter for some local \
type (e.g., `MyStruct<{}>`)",
param_ty,
param_ty
);
err.span_label(sp, format!(
"type parameter `{}` must be used as the type parameter for some local \
type",
param_ty,
));
err.note("only traits defined in the current crate can be implemented for a \
type parameter");
err.emit();
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/coherence/coherence-all-remote.old.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-all-remote.rs:9:1
--> $DIR/coherence-all-remote.rs:9:6
|
LL | impl<T> Remote1<T> for isize { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/coherence/coherence-all-remote.re.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-all-remote.rs:9:1
--> $DIR/coherence-all-remote.rs:9:6
|
LL | impl<T> Remote1<T> for isize { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/coherence/coherence-bigint-param.old.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-bigint-param.rs:11:1
--> $DIR/coherence-bigint-param.rs:11:6
|
LL | impl<T> Remote1<BigInt> for T { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/coherence/coherence-bigint-param.re.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-bigint-param.rs:11:1
--> $DIR/coherence-bigint-param.rs:11:6
|
LL | impl<T> Remote1<BigInt> for T { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/coherence/coherence-cow.a.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:18:1
--> $DIR/coherence-cow.rs:18:6
|
LL | impl<T> Remote for Pair<T,Cover<T>> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/coherence/coherence-cow.b.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:23:1
--> $DIR/coherence-cow.rs:23:6
|
LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/coherence/coherence-cow.c.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:28:1
--> $DIR/coherence-cow.rs:28:6
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/coherence/coherence-cow.re_a.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-cow.rs:18:1
|
LL | impl<T> Remote for Pair<T,Cover<T>> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `lib::Pair<T, Cover<T>>` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `lib::Pair<T, Cover<T>>` is not defined in the current create
= note: define and implement a trait or new type instead

error: aborting due to previous error
Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/coherence/coherence-cow.re_b.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-cow.rs:23:1
|
LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `lib::Pair<Cover<T>, T>` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `lib::Pair<Cover<T>, T>` is not defined in the current create
= note: define and implement a trait or new type instead

error: aborting due to previous error
Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/coherence/coherence-cow.re_c.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-cow.rs:28:1
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `lib::Pair<Cover<T>, U>` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `lib::Pair<Cover<T>, U>` is not defined in the current create
= note: define and implement a trait or new type instead

error: aborting due to previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ LL | impl<A> Foo for A {
- impl trait_impl_conflict::Foo for isize;

error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct<A>`)
--> $DIR/coherence-cross-crate-conflict.rs:12:1
--> $DIR/coherence-cross-crate-conflict.rs:12:6
|
LL | impl<A> Foo for A {
| ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type
| ^ type parameter `A` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ LL | impl<A> Foo for A {
- impl trait_impl_conflict::Foo for isize;

error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct<A>`)
--> $DIR/coherence-cross-crate-conflict.rs:12:1
--> $DIR/coherence-cross-crate-conflict.rs:12:6
|
LL | impl<A> Foo for A {
| ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type
| ^ type parameter `A` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-fundamental-trait-objects.rs:15:1
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^----------------------
| | |
| | `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + 'static)` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + 'static)` is not defined in the current create
= note: define and implement a trait or new type instead

error: aborting due to previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-fundamental-trait-objects.rs:15:1
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^----------------------
| | |
| | `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + 'static)` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + 'static)` is not defined in the current create
= note: define and implement a trait or new type instead

error: aborting due to previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:22:1
|
LL | impl !Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^-----------
| | |
| | `(dyn Marker2 + 'static)` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `(dyn Marker2 + 'static)` is not defined in the current create
= note: define and implement a trait or new type instead

error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:22:1
|
LL | unsafe impl Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^^^^^-----------
| | |
| | `(dyn Marker2 + 'static)` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `(dyn Marker2 + 'static)` is not defined in the current create
= note: define and implement a trait or new type instead

error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)`
Expand Down
24 changes: 16 additions & 8 deletions src/test/ui/coherence/coherence-impls-copy.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,44 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-impls-copy.rs:8:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^---
| | |
| | `i32` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `i32` is not defined in the current create
= note: define and implement a trait or new type instead

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-copy.rs:32:1
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^----------------
| | |
| | `(MyType, MyType)` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `(MyType, MyType)` is not defined in the current create
= note: define and implement a trait or new type instead

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-copy.rs:40:1
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^--------
| | |
| | `[MyType]` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `[MyType]` is not defined in the current create
= note: define and implement a trait or new type instead

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-copy.rs:45:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^------------------
| | |
| | `&'static [NotSync]` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: `&'static [NotSync]` is not defined in the current create
= note: define and implement a trait or new type instead

error: aborting due to 10 previous errors
Expand Down
Loading