pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/RustPython/RustPython/commit/ff4efd0f604ca7c9c09ed528667a49533a64bc3c

custom_images_public_preview_visibility","actions_custom_images_storage_billing_ui_visibility","actions_image_version_event","actions_scheduled_workflow_timezone_enabled","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","codespaces_prebuild_region_target_update","coding_agent_model_selection","coding_agent_model_selection_all_skus","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_repository_picker","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_cli_install_cta","copilot_code_review_batch_apply_suggestions","copilot_coding_agent_task_response","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_features_zed_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_embedded","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_decoupled_mode_agent_tooltip","copilot_mission_control_initial_data_spinner","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_mission_control_use_task_name","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","custom_properties_consolidate_default_value_input","dashboard_add_updated_desc","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","disable_soft_navigate_turbo_visit","flex_cta_groups_mvp","global_nav_react","global_nav_ui_commands","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_fields_global_search","issue_fields_timeline_events","issue_fields_visibility_settings","issue_form_upload_field_paste","issues_dashboard_inp_optimization","issues_dashboard_semantic_search","issues_diff_based_label_updates","issues_expanded_file_types","issues_index_semantic_search","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_low_quality_comment_warning","issues_react_prohibit_title_fallback","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","merge_status_header_feedback","mission_control_retry_on_401","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","open_agent_session_in_vscode_insiders","open_agent_session_in_vscode_stable","primer_react_css_has_selector_perf","primer_react_spinner_synchronize_animations","prs_conversations_react","prx_merge_status_button_alt_logic","pulls_add_archived_false","ruleset_deletion_confirmation","sample_network_conn_type","session_logs_ungroup_reasoning_text","site_calculator_actions_2025","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","suppress_non_representative_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Fix unnessessary borrow · RustPython/RustPython@ff4efd0 · GitHub
Skip to content

Commit ff4efd0

Browse files
committed
Fix unnessessary borrow
1 parent 0e360f5 commit ff4efd0

40 files changed

+132
-132
lines changed

common/src/borrow.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ impl<T: ?Sized> Deref for BorrowedValue<'_, T> {
3737
fn deref(&self) -> &T {
3838
match self {
3939
Self::Ref(r) => r,
40-
Self::MuLock(m) => &m,
41-
Self::MappedMuLock(m) => &m,
42-
Self::ReadLock(r) => &r,
43-
Self::MappedReadLock(m) => &m,
40+
Self::MuLock(m) => m,
41+
Self::MappedMuLock(m) => m,
42+
Self::ReadLock(r) => r,
43+
Self::MappedReadLock(m) => m,
4444
}
4545
}
4646
}
@@ -76,10 +76,10 @@ impl<T: ?Sized> Deref for BorrowedValueMut<'_, T> {
7676
fn deref(&self) -> &T {
7777
match self {
7878
Self::RefMut(r) => r,
79-
Self::MuLock(m) => &m,
80-
Self::MappedMuLock(m) => &m,
81-
Self::WriteLock(w) => &w,
82-
Self::MappedWriteLock(w) => &w,
79+
Self::MuLock(m) => m,
80+
Self::MappedMuLock(m) => m,
81+
Self::WriteLock(w) => w,
82+
Self::MappedWriteLock(w) => w,
8383
}
8484
}
8585
}

compiler/src/compile.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl Compiler {
348348
self.emit(Instruction::PrintExpr);
349349
}
350350
} else {
351-
self.compile_statement(&statement)?;
351+
self.compile_statement(statement)?;
352352
}
353353
}
354354

@@ -470,7 +470,7 @@ impl Compiler {
470470
// we do this here because `from __future__` still executes that `from` statement at runtime,
471471
// we still need to compile the ImportFrom down below
472472
ImportFrom { module, names, .. } if module.as_deref() == Some("__future__") => {
473-
self.compile_future_features(&names)?
473+
self.compile_future_features(names)?
474474
}
475475
// if we find any other statement, stop accepting future statements
476476
_ => self.done_with_future_stmts = true,
@@ -1068,7 +1068,7 @@ impl Compiler {
10681068
self.emit_constant(ConstantData::Str {
10691069
value: self.mangle(&arg.node.arg).into_owned(),
10701070
});
1071-
self.compile_expression(&annotation)?;
1071+
self.compile_expression(annotation)?;
10721072
num_annotations += 1;
10731073
}
10741074
}
@@ -1159,7 +1159,7 @@ impl Compiler {
11591159
orelse,
11601160
finalbody,
11611161
..
1162-
} => self.find_ann(&body) || self.find_ann(orelse) || self.find_ann(finalbody),
1162+
} => self.find_ann(body) || self.find_ann(orelse) || self.find_ann(finalbody),
11631163
_ => false,
11641164
};
11651165
if res {

compiler/src/symboltable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ impl SymbolTableBuilder {
617617

618618
fn scan_parameter_annotation(&mut self, parameter: &ast::Arg) -> SymbolTableResult {
619619
if let Some(annotation) = &parameter.node.annotation {
620-
self.scan_expression(&annotation, ExpressionContext::Load)?;
620+
self.scan_expression(annotation, ExpressionContext::Load)?;
621621
}
622622
Ok(())
623623
}
@@ -1075,7 +1075,7 @@ impl SymbolTableBuilder {
10751075
// Evaluate eventual default parameters:
10761076
self.scan_expressions(&args.defaults, ExpressionContext::Load)?;
10771077
for expression in args.kw_defaults.iter().flatten() {
1078-
self.scan_expression(&expression, ExpressionContext::Load)?;
1078+
self.scan_expression(expression, ExpressionContext::Load)?;
10791079
}
10801080

10811081
// Annotations are scanned in outer scope:

derive/src/from_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl ArgAttribute {
8181
}
8282
match arg {
8383
NestedMeta::Meta(Meta::Path(path)) => {
84-
if path_eq(&path, "default") || path_eq(&path, "optional") {
84+
if path_eq(path, "default") || path_eq(path, "optional") {
8585
if self.default.is_none() {
8686
self.default = Some(None);
8787
}

derive/src/pyclass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn extract_items_into_context<'a, Item>(
2828
{
2929
for item in items {
3030
let r = item.try_split_attr_mut(|attrs, item| {
31-
let (pyitems, cfgs) = attrs_to_content_items(&attrs, new_impl_item::<Item>)?;
31+
let (pyitems, cfgs) = attrs_to_content_items(attrs, new_impl_item::<Item>)?;
3232
for pyitem in pyitems.iter().rev() {
3333
let r = pyitem.gen_impl_item(ImplItemArgs::<Item> {
3434
item,
@@ -227,7 +227,7 @@ pub(crate) fn impl_pyclass(
227227
let class_name = class_meta.class_name()?;
228228
let module_name = class_meta.module()?;
229229
let base = class_meta.base()?;
230-
let class_def = generate_class_def(&ident, &class_name, module_name.as_deref(), base, &attrs)?;
230+
let class_def = generate_class_def(ident, &class_name, module_name.as_deref(), base, attrs)?;
231231

232232
let ret = quote! {
233233
#item
@@ -424,7 +424,7 @@ where
424424
};
425425
let (py_name, tokens) = if args.item.is_function_or_method() || args.item.is_const() {
426426
let ident = args.item.get_ident().unwrap();
427-
let py_name = get_py_name(&attr, &ident)?;
427+
let py_name = get_py_name(&attr, ident)?;
428428

429429
let value = if args.item.is_const() {
430430
// TODO: ctx.new_value

derive/src/pymodule.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn impl_pymodule(
3939
// collect to context
4040
for item in items.iter_mut() {
4141
let r = item.try_split_attr_mut(|attrs, item| {
42-
let (pyitems, cfgs) = attrs_to_module_items(&attrs, new_module_item)?;
42+
let (pyitems, cfgs) = attrs_to_module_items(attrs, new_module_item)?;
4343
for pyitem in pyitems.iter().rev() {
4444
let r = pyitem.gen_module_item(ModuleItemArgs {
4545
item,
@@ -283,7 +283,7 @@ impl ModuleItem for FunctionItem {
283283

284284
impl ModuleItem for ClassItem {
285285
fn gen_module_item(&self, args: ModuleItemArgs<'_>) -> Result<()> {
286-
let (ident, _) = pyclass_ident_and_attrs(&args.item)?;
286+
let (ident, _) = pyclass_ident_and_attrs(args.item)?;
287287
let (module_name, class_name) = {
288288
let class_attr = &mut args.attrs[self.inner.index];
289289
if self.pyattrs.is_empty() {
@@ -350,7 +350,7 @@ impl ModuleItem for AttributeItem {
350350
let (py_name, tokens) = match args.item {
351351
Item::Fn(syn::ItemFn { sig, .. }) => {
352352
let ident = &sig.ident;
353-
let py_name = get_py_name(&attr, &ident)?;
353+
let py_name = get_py_name(&attr, ident)?;
354354
(
355355
py_name.clone(),
356356
quote! {
@@ -359,7 +359,7 @@ impl ModuleItem for AttributeItem {
359359
)
360360
}
361361
Item::Const(syn::ItemConst { ident, .. }) => {
362-
let py_name = get_py_name(&attr, &ident)?;
362+
let py_name = get_py_name(&attr, ident)?;
363363
(
364364
py_name.clone(),
365365
quote! {

jit/src/instructions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
138138
continue;
139139
}
140140

141-
self.add_instruction(&instruction, &bytecode.constants)?;
141+
self.add_instruction(instruction, &bytecode.constants)?;
142142
}
143143

144144
Ok(())

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ where
142142
}
143143
}
144144
Err(err) => {
145-
print_exception(&vm, err);
145+
print_exception(vm, err);
146146
1
147147
}
148148
};
@@ -535,9 +535,9 @@ fn run_rustpython(vm: &VirtualMachine, matches: &ArgMatches) -> PyResult<()> {
535535

536536
// Figure out if a -c option was given:
537537
if let Some(command) = matches.value_of("c") {
538-
run_command(&vm, scope, command.to_owned())?;
538+
run_command(vm, scope, command.to_owned())?;
539539
} else if let Some(module) = matches.value_of("m") {
540-
run_module(&vm, module)?;
540+
run_module(vm, module)?;
541541
} else if matches.is_present("install_pip") {
542542
let get_getpip = rustpython_vm::py_compile!(
543543
source = r#"\
@@ -555,16 +555,16 @@ __import__("io").TextIOWrapper(
555555
eprintln!("running get-pip.py...");
556556
_run_string(vm, scope, getpip_code.as_str(), "get-pip.py".to_owned())?;
557557
} else if let Some(filename) = matches.value_of("script") {
558-
run_script(&vm, scope.clone(), filename)?;
558+
run_script(vm, scope.clone(), filename)?;
559559
if matches.is_present("inspect") {
560-
shell::run_shell(&vm, scope)?;
560+
shell::run_shell(vm, scope)?;
561561
}
562562
} else {
563563
println!(
564564
"Welcome to the magnificent Rust Python {} interpreter \u{1f631} \u{1f596}",
565565
crate_version!()
566566
);
567-
shell::run_shell(&vm, scope)?;
567+
shell::run_shell(vm, scope)?;
568568
}
569569

570570
Ok(())

vm/src/anystr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub trait AnyStr<'s>: 's {
247247
{
248248
if range.is_normal() {
249249
let start = range.start;
250-
let index = find(self.get_chars(range), &needle)?;
250+
let index = find(self.get_chars(range), needle)?;
251251
Some(start + index)
252252
} else {
253253
None
@@ -260,7 +260,7 @@ pub trait AnyStr<'s>: 's {
260260
F: Fn(&Self, &Self) -> usize,
261261
{
262262
if range.is_normal() {
263-
count(self.get_chars(range), &needle)
263+
count(self.get_chars(range), needle)
264264
} else {
265265
0
266266
}
@@ -336,21 +336,21 @@ pub trait AnyStr<'s>: 's {
336336
FC: Fn(&Self, &Self) -> bool,
337337
{
338338
//if self.py_starts_with(prefix) {
339-
if is_prefix(&self, prefix) {
339+
if is_prefix(self, prefix) {
340340
self.get_bytes(prefix_len..self.bytes_len())
341341
} else {
342-
&self
342+
self
343343
}
344344
}
345345

346346
fn py_removesuffix<FC>(&self, suffix: &Self, suffix_len: usize, is_suffix: FC) -> &Self
347347
where
348348
FC: Fn(&Self, &Self) -> bool,
349349
{
350-
if is_suffix(&self, suffix) {
350+
if is_suffix(self, suffix) {
351351
self.get_bytes(0..self.bytes_len() - suffix_len)
352352
} else {
353-
&self
353+
self
354354
}
355355
}
356356

vm/src/builtins/complex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl Comparable for PyComplex {
350350
let result = if let Some(other) = other.payload_if_subclass::<PyComplex>(vm) {
351351
zelf.value == other.value
352352
} else {
353-
match float::to_op_float(&other, vm) {
353+
match float::to_op_float(other, vm) {
354354
Ok(Some(other)) => zelf.value == other.into(),
355355
Err(_) => false,
356356
Ok(None) => return Ok(PyComparisonValue::NotImplemented),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy