Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
40185db
Delete old re-exports from rustc_smir
celinval Mar 4, 2023
af664be
rustdoc: include link on all.html location header
notriddle Mar 3, 2023
b66db7e
Create new rustc_smir struct to map future crates
celinval Mar 4, 2023
775bacd
Simplify `sort_by` calls
WaffleLapkin Mar 7, 2023
5eaeb71
Change item collection to be on demand
celinval Mar 7, 2023
a439c02
may not => cannot
compiler-errors Mar 7, 2023
0f4255e
Dedup copy field errors for identical types
compiler-errors Mar 8, 2023
8a99ffc
Suppress copy impl error when post-normalized type references errors
compiler-errors Mar 7, 2023
be60bcb
Rename `MapInPlace` as `FlatMapInPlace`.
nnethercote Mar 8, 2023
204ba32
fix: evaluate with wrong obligation stack
LYF1999 Mar 8, 2023
1d442af
move clippy tests back to their intended directory
pietroalbini Mar 8, 2023
6c91ce2
Rollup merge of #108686 - notriddle:notriddle/jank-all, r=jsha
matthiaskrgr Mar 8, 2023
9b6b7a3
Rollup merge of #108846 - celinval:smir-poc, r=oli-obk
matthiaskrgr Mar 8, 2023
1a9376d
Rollup merge of #108873 - WaffleLapkin:cmp, r=cjgillot
matthiaskrgr Mar 8, 2023
f6b8a9f
Rollup merge of #108883 - compiler-errors:post-norm-copy-err, r=BoxyUwU
matthiaskrgr Mar 8, 2023
031b528
Rollup merge of #108884 - compiler-errors:tweak-illegal-copy-impl-mes…
matthiaskrgr Mar 8, 2023
a95943b
Rollup merge of #108887 - nnethercote:rename-MapInPlace, r=lqd
matthiaskrgr Mar 8, 2023
33c3036
Rollup merge of #108901 - LYF1999:yf/108897, r=lcnr
matthiaskrgr Mar 8, 2023
7732ccc
Rollup merge of #108903 - rust-lang:pa-fix-clippy-tests, r=flip1995
matthiaskrgr Mar 8, 2023
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
Dedup copy field errors for identical types
  • Loading branch information
compiler-errors committed Mar 8, 2023
commit 0f4255ece2e2ff5e0ab7467513cd45d3cdecb27d
8 changes: 8 additions & 0 deletions compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! up data structures required by type-checking/codegen.

use crate::errors::{CopyImplOnNonAdt, CopyImplOnTypeWithDtor, DropImplOnWrongItem};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{struct_span_err, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
Expand Down Expand Up @@ -94,7 +95,14 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
let mut errors: BTreeMap<_, Vec<_>> = Default::default();
let mut bounds = vec![];

let mut seen_tys = FxHashSet::default();

for (field, ty, reason) in fields {
// Only report an error once per type.
if !seen_tys.insert(ty) {
continue;
}

let field_span = tcx.def_span(field.did);
err.span_label(field_span, "this field does not implement `Copy`");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ LL | #[derive(Debug, Copy, Clone)]
LL | pub struct AABB<K: Copy>{
LL | pub loc: Vector2<K>,
| ------------------- this field does not implement `Copy`
LL | pub size: Vector2<K>
| -------------------- this field does not implement `Copy`
|
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
--> $DIR/missing-bound-in-derive-copy-impl-3.rs:12:14
|
LL | pub loc: Vector2<K>,
| ^^^^^^^^^^
LL | pub size: Vector2<K>
| ^^^^^^^^^^
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting this bound
|
Expand Down
4 changes: 0 additions & 4 deletions tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ LL | #[derive(Debug, Copy, Clone)]
LL | pub struct AABB<K>{
LL | pub loc: Vector2<K>,
| ------------------- this field does not implement `Copy`
LL | pub size: Vector2<K>
| -------------------- this field does not implement `Copy`
|
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
--> $DIR/missing-bound-in-derive-copy-impl.rs:11:14
|
LL | pub loc: Vector2<K>,
| ^^^^^^^^^^
LL | pub size: Vector2<K>
| ^^^^^^^^^^
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `K`
|
Expand Down