Constructors don't receive `this` as the first argument
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Start by tracing constructor translation and the generated Rust representations for normal, copy, and move constructors; the issue gives no source files or tests to target. Read the related issues #582 and #248 for context, then locate the translation tests covering constructors. Done means constructors receive prebuilt storage through an explicit this argument, and copy/move translation avoids the extra construction and Clone behavior described here.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Normal constructors and copy/move constructors/assignments all receive this as an implicit first argument.
Our constructor translation instead receives no this and returns by value.
This has performance implications as described in #582 but most importantly it has wrong semantics:
- self referential constructors are broken (#248)
- copy/move constructors and assignments introduce calls that C++ does not have:
impl S {
pub fn copy_from(o: Ptr<S>) -> Self {
let __this: Counted = Self {
... // It constructs a fake __this that might have side effects
};
... body of copy ctor ...
__this
}
}
impl Clone for S {
fn clone(&self) -> Self {
// builds a fake argument for copy_from that might have side effects
let __src: Value<S> = Rc::new(RefCell::new(S { ... }));
S::copy_from(__src.as_pointer())
// drops the fake __src and the fields inside it
}
}
For 1, the solution is to build the storage before calling the constructor:
impl S {
pub fn new(this: Ptr<Self>) {
this.a = 1;
this.b = 2;
}
}
let s: Value<S> = Rc::new(RefCell::new(/* uninitialized storage of S */));
S::new(s.as_pointer());
For 2, the solution is to explicitly pass this to the copy ctor and stop using the Clone trait:
impl S for CopyConstructible {
pub fn copy_from(this: Ptr<S>, o: Ptr<S>) {
... body of copy ctor ...
}
}
- Linguagem predominante
- Rust
- Estrelas
- 310
- Forks
- 18
- Merge médio
- 9h 46min
- PRs com merge (30d)
- 82
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de Cpp2Rust/cpp2rust
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
Cpp2Rust/cpp2rust#610 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 15/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 22/100
Mantenedores costumam responder em até 1 dia
Todas as issues de Cpp2Rust/cpp2rust
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
kashsuks/Pinel#172 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 69/100
Mantenedores costumam responder em até 1 dia
-
test_a_503_raises_unavailable_error fails on macOS about one run in sixTalvez já em andamento @naman-modi assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
bug ui
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
userFRM/egui-charts#4168 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia