Skip to content

Rollup of 9 pull requests #122607

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

Merged
merged 18 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8b576d5
fix attribute validation on associated items in traits
gvozdvmozgu Feb 24, 2024
c121a26
Split refining_impl_trait lint into _reachable, _internal variants
tmandry Feb 28, 2024
f25809d
fix `long-linker-command-lines` failure caused by `rust.rpath=false`
onur-ozkan Mar 10, 2024
a37fe00
Remove obsolete parameter `speculative` from `instantiate_poly_trait_…
fmease Mar 16, 2024
873a0f2
Add `wasm_c_abi` `future-incompat` lint
daxpedda Nov 14, 2023
f272133
core: optimize `ptr::replace`
joboet Mar 16, 2024
b2ed9d0
Delegation: fix ICE on duplicated associative items
Bryanskiy Mar 16, 2024
fc42f3b
Mention @jieyouxu for changes to compiletest, run-make tests and the …
jieyouxu Mar 16, 2024
ad84934
rustc-metadata: Store crate name in self-profile of metadata_register…
osiewicz Mar 16, 2024
c00c5fe
Rollup merge of #117918 - daxpedda:wasm-c-abi-warning, r=workingjubilee
fmease Mar 16, 2024
79c1e58
Rollup merge of #121545 - gvozdvmozgu:fix-attribute-validation-associ…
fmease Mar 16, 2024
0995508
Rollup merge of #121720 - tmandry:split-refining, r=compiler-errors
fmease Mar 16, 2024
c2b7d77
Rollup merge of #122270 - onur-ozkan:fix-rmake-test-with-rpath-false,…
fmease Mar 16, 2024
7b7a7fc
Rollup merge of #122564 - Bryanskiy:delegation-fixes, r=compiler-errors
fmease Mar 16, 2024
4cbfa15
Rollup merge of #122577 - fmease:speculative-say-what, r=compiler-errors
fmease Mar 16, 2024
de0c2a4
Rollup merge of #122601 - joboet:ptr_replace, r=workingjubilee
fmease Mar 16, 2024
53515f3
Rollup merge of #122604 - jieyouxu:triagebot-mention-compiletest-run-…
fmease Mar 16, 2024
caa6131
Rollup merge of #122605 - osiewicz:metadata-register-crate-store-crat…
fmease Mar 16, 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
14 changes: 6 additions & 8 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(trait_ref, lowered_ty)
});

self.is_in_trait_impl = trait_ref.is_some();
let new_impl_items = self
.arena
.alloc_from_iter(impl_items.iter().map(|item| self.lower_impl_item_ref(item)));
Expand Down Expand Up @@ -978,13 +979,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
let trait_item_def_id = self
.resolver
.get_partial_res(i.id)
.map(|r| r.expect_full_res().opt_def_id())
.unwrap_or(None);
self.is_in_trait_impl = trait_item_def_id.is_some();

hir::ImplItemRef {
id: hir::ImplItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
ident: self.lower_ident(i.ident),
Expand All @@ -1000,7 +994,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
},
AssocItemKind::MacCall(..) => unimplemented!(),
},
trait_item_def_id,
trait_item_def_id: self
.resolver
.get_partial_res(i.id)
.map(|r| r.expect_full_res().opt_def_id())
.unwrap_or(None),
}
}

Expand Down
23 changes: 23 additions & 0 deletions tests/ui/delegation/duplicate-definition-inside-trait-impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![feature(fn_delegation)]
//~^ WARN the feature `fn_delegation` is incomplete

trait Trait {
fn foo(&self) -> u32 { 0 }
}

struct F;
struct S;

mod to_reuse {
use crate::S;

pub fn foo(_: &S) -> u32 { 0 }
}

impl Trait for S {
reuse to_reuse::foo { self }
reuse Trait::foo;
//~^ ERROR duplicate definitions with name `foo`
}

fn main() {}
23 changes: 23 additions & 0 deletions tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0201]: duplicate definitions with name `foo`:
--> $DIR/duplicate-definition-inside-trait-impl.rs:19:5
|
LL | fn foo(&self) -> u32 { 0 }
| -------------------------- item in trait
...
LL | reuse to_reuse::foo { self }
| ---------------------------- previous definition here
LL | reuse Trait::foo;
| ^^^^^^^^^^^^^^^^^ duplicate definition

warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/duplicate-definition-inside-trait-impl.rs:1:12
|
LL | #![feature(fn_delegation)]
| ^^^^^^^^^^^^^
|
= note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
= note: `#[warn(incomplete_features)]` on by default

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0201`.