Skip to content

Commit

Permalink
Merge pull request #190 from stargazing-dino/remove_unused
Browse files Browse the repository at this point in the history
Fixes for CI
  • Loading branch information
janhohenheim authored May 17, 2024
2 parents 1d5ccba + 393efe2 commit 3ba3cb8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 57 deletions.
20 changes: 0 additions & 20 deletions crates/bevy_plugin/tests/test_asset_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use anyhow::{bail, Result};
use bevy::prelude::*;
use bevy::utils::Instant;
use bevy_yarnspinner::prelude::*;
use bevy_yarnspinner::UnderlyingYarnLine;
use utils::prelude::*;

mod utils;
Expand Down Expand Up @@ -198,22 +197,3 @@ fn does_not_load_asset_with_invalid_type() -> Result<()> {
assert!(asset.is_none());
Ok(())
}

trait AssetProviderExt {
fn get_assets_for_id(&self, id: &str) -> LineAssets;
}

impl<T> AssetProviderExt for T
where
T: AssetProvider + ?Sized,
{
fn get_assets_for_id(&self, id: &str) -> LineAssets {
let line_id = LineId(id.to_owned());
let yarn_line = UnderlyingYarnLine {
id: line_id,
text: String::new(),
attributes: vec![],
};
T::get_assets(self, &yarn_line)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub(crate) fn add_initial_value_registrations(
}
}

compilation.declarations = state.derived_variable_declarations.clone();
compilation
.declarations
.clone_from(&state.derived_variable_declarations);
state
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) fn clean_up_diagnostics(mut state: CompilationIntermediate) -> Compil
if state.diagnostics.has_errors() {
state.result = Some(Err(CompilerError(state.diagnostics.clone())));
} else if let Some(Ok(compilation)) = state.result.as_mut() {
compilation.warnings = state.diagnostics.clone();
compilation.warnings.clone_from(&state.diagnostics);
}
state
}
15 changes: 0 additions & 15 deletions crates/compiler/src/compiler/antlr_rust_ext.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
//! Contains functionality provided in the C# implementation of ANTLR but not (yet?) in antlr4rust.
use crate::parser::generated::yarnspinnerparser::YarnSpinnerParserContextType;
use crate::parser::ActualTokenStream;
use crate::prelude::generated::yarnspinnerparser::YarnSpinnerParserContext;
use crate::prelude::ContextRefExt;
use antlr_rust::int_stream::IntStream;
use antlr_rust::rule_context::RuleContext;
use antlr_rust::token::{CommonToken, Token, TOKEN_DEFAULT_CHANNEL};
use antlr_rust::token_factory::{CommonTokenFactory, TokenFactory};
use antlr_rust::token_stream::TokenStream;
use antlr_rust::tree::ErrorNode;
use antlr_rust::InputStream;
use better_any::TidExt;
use std::rc::Rc;
Expand Down Expand Up @@ -209,17 +205,6 @@ pub(crate) trait YarnSpinnerParserContextExt<'input>:
.filter_map(|child| child.downcast_rc::<T>().ok())
.nth(pos)
}

/// Adapted from <https://github.com/antlr/antlr4/blob/8dcc6526cfb154d688497f31cf1e0904801c6df2/runtime/CSharp/src/ParserRuleContext.cs#L220>
fn add_error_node(
&self,
bad_token: CommonToken<'input>,
) -> Rc<ErrorNode<'input, YarnSpinnerParserContextType>> {
let error_node = Rc::new(ErrorNode::new(Box::new(bad_token)));
error_node.set_parent(&Some(self.ref_to_rc()));
self.add_child(error_node.clone());
error_node
}
}
impl<'input, T: YarnSpinnerParserContext<'input> + ?Sized> YarnSpinnerParserContextExt<'input>
for T
Expand Down
8 changes: 5 additions & 3 deletions crates/compiler/src/listeners/compiler_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ impl<'input> YarnSpinnerParserListener<'input> for CompilerListener<'input> {
// Duplicate node name! We'll have caught this during the
// declarations pass, so no need to issue an error here.
}
self.current_debug_info.node_name = name.clone();
self.current_debug_info.file_name = self.file.name.clone();
self.current_debug_info.node_name.clone_from(name);
self.current_debug_info
.file_name
.clone_from(&self.file.name);
self.debug_infos
.borrow_mut()
.push(self.current_debug_info.clone());
Expand Down Expand Up @@ -130,7 +132,7 @@ impl<'input> YarnSpinnerParserListener<'input> for CompilerListener<'input> {
match header_key {
"title" => {
// Set the name of the node
current_node.name = header_value.clone();
current_node.name.clone_from(&header_value);
}
"tags" => {
// Split the list of tags by spaces, and use that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ impl<'input> YarnSpinnerParserVisitorCompat<'input> for StringTableGeneratorVisi
for header in ctx.header_all() {
let header_key = header.header_key.as_ref().unwrap().get_text();
if header_key == "title" {
self.current_node_name =
header.header_value.as_ref().unwrap().get_text().to_owned();
header
.header_value
.as_ref()
.unwrap()
.get_text()
.clone_into(&mut self.current_node_name)
} else if header_key == "tags" {
let header_value = header
.header_value
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/src/visitors/type_check_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl<'input> YarnSpinnerParserVisitorCompat<'input> for TypeCheckVisitor<'input>
let Type::Function(function_type) = &mut declaration.r#type else {
unreachable!();
};
function_type.parameters[i] = supplied_type.clone();
function_type.parameters[i].clone_from(&supplied_type);
expected_type = &supplied_type;
}
if !supplied_type.is_sub_type_of(expected_type) {
Expand Down
12 changes: 0 additions & 12 deletions crates/core/src/types/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,6 @@ impl_type! {
Type::Boolean => [bool,],
}

// The macro has problems with the following expansions

trait StrRefExt {
fn r#type() -> Type;
}

impl StrRefExt for &str {
fn r#type() -> Type {
Type::String
}
}

impl From<&str> for Type {
fn from(_value: &str) -> Self {
Type::String
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/src/virtual_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl VirtualMachine {

pub(crate) fn set_language_code(&mut self, language_code: impl Into<Option<Language>>) {
let language_code = language_code.into();
self.language_code = language_code.clone();
self.language_code.clone_from(&language_code);
self.line_parser.set_language_code(language_code.clone());
self.text_provider.set_language(language_code);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/yarnspinner/tests/test_base/test_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl TestPlan {
});
} else {
self.next_expected_step = current_step.expected_step_type;
self.next_step_value = current_step.value.clone();
self.next_step_value.clone_from(&current_step.value);
return;
}
}
Expand Down

0 comments on commit 3ba3cb8

Please sign in to comment.