diff --git a/build.rs b/build.rs index 46505c7882..715351dde5 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,7 @@ use std::process::Command; extern crate chrono; use std::env; -const COMPILER_DEPENDENT_BINARIES : &[&str] = &["dfpp", "cargo-dfpp", "dfpp-explorer"]; +const COMPILER_DEPENDENT_BINARIES: &[&str] = &["dfpp", "cargo-dfpp", "dfpp-explorer"]; fn add_link_arg_for_compiler_binaries(s: impl std::fmt::Display) { for bin in COMPILER_DEPENDENT_BINARIES { @@ -34,7 +34,7 @@ pub fn link_rustc_lib() { } else { "$ORIGIN" }; - add_link_search_path_for_compiler_binaries(&format!("{origin}/../toolchain/lib")); + add_link_search_path_for_compiler_binaries(format!("{origin}/../toolchain/lib")); if cfg!(target_os = "linux") { println!("cargo:rustc-link-search=native={}", rustup_lib.display()); } diff --git a/src/ana/algebra.rs b/src/ana/algebra.rs index 7d4f870e7a..b3b28aeec7 100644 --- a/src/ana/algebra.rs +++ b/src/ana/algebra.rs @@ -404,6 +404,7 @@ pub mod graph { graph } + #[allow(clippy::blocks_in_if_conditions)] pub fn reachable< B: Display + Copy + Hash + Eq + Ord, F: Hash + Eq + Display + Copy, diff --git a/src/ana/df.rs b/src/ana/df.rs index c1fd6f1085..e0d4a4d4ea 100644 --- a/src/ana/df.rs +++ b/src/ana/df.rs @@ -457,6 +457,7 @@ impl<'a, 'tcx, 'g, 's> FlowAnalysis<'a, 'tcx, 'g, 's> { self.tcx.hir().body_owned_by(self.def_id.expect_local()) } + #[allow(clippy::too_many_arguments)] pub fn new( tcx: TyCtxt<'tcx>, gli: GLI<'g>, diff --git a/src/ana/inline.rs b/src/ana/inline.rs index 98b5978600..dd4713ed4a 100644 --- a/src/ana/inline.rs +++ b/src/ana/inline.rs @@ -285,12 +285,7 @@ impl<'tcx, 'g, 's> Inliner<'tcx, 'g, 's> { } } - fn find_prunable_edges( - graph: &InlinedGraph<'g>, - ) -> HashSet<( - Node<(GlobalLocation<'g>, DefId)>, - Node<(GlobalLocation<'g>, DefId)>, - )> { + fn find_prunable_edges(graph: &InlinedGraph<'g>) -> EdgeSet<'g> { let graph = &graph.graph; graph .all_edges() @@ -938,6 +933,8 @@ impl<'tcx, 'g, 's> Inliner<'tcx, 'g, 's> { true } + #[allow(clippy::type_complexity)] + #[allow(clippy::too_many_arguments)] fn inline_one_function( &self, InlinedGraph { @@ -952,10 +949,7 @@ impl<'tcx, 'g, 's> Inliner<'tcx, 'g, 's> { outgoing: &[(SimpleLocation<(GlobalLocation<'g>, DefId)>, Edge)], arguments: &[Option], return_to: Option, - queue_for_pruning: &mut HashSet<( - SimpleLocation<(GlobalLocation<'g>, DefId)>, - SimpleLocation<(GlobalLocation<'g>, DefId)>, - )>, + queue_for_pruning: &mut EdgeSet<'g>, root_location: GlobalLocation<'g>, ) { let grw_to_inline = @@ -997,7 +991,6 @@ impl<'tcx, 'g, 's> Inliner<'tcx, 'g, 's> { .iter() .enumerate() .filter_map(|(a, actual_param)| Some(((*actual_param)?, (a + 1).into()))) - .into_iter() .chain(return_to.into_iter().map(|r| (r, mir::RETURN_PLACE))) .map(|(actual_param, formal_param)| { algebra::Equality::new( diff --git a/src/desc.rs b/src/desc.rs index f392e1e73c..7d0f018b84 100644 --- a/src/desc.rs +++ b/src/desc.rs @@ -298,7 +298,7 @@ impl Identifier { pub fn as_str(&self) -> &str { self.0.as_str() } - pub fn from_str(s: &str) -> Self { + pub fn new_intern(s: &str) -> Self { Self::new(Symbol::intern(s)) } } diff --git a/src/discover.rs b/src/discover.rs index d080b3ddbd..eb89a2c35e 100644 --- a/src/discover.rs +++ b/src/discover.rs @@ -19,7 +19,7 @@ use hir::{ }; use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_span::{symbol::Ident, Span, Symbol}; -use std::{cell::RefCell, rc::Rc, collections::hash_map::Entry}; +use std::{cell::RefCell, collections::hash_map::Entry, rc::Rc}; /// Values of this type can be matched against Rust attributes pub type AttrMatchT = Vec; @@ -36,6 +36,7 @@ pub type CallSiteAnnotations = HashMap, usize)>; /// read-only. pub type MarkedObjects = Rc, ObjectType)>>>; +#[allow(clippy::type_complexity)] /// This visitor traverses the items in the analyzed crate to discover /// annotations and analysis targets and store them in this struct. After the /// discovery phase [`Self::analyze`] is used to drive the @@ -302,7 +303,6 @@ impl<'tcx> intravisit::Visitor<'tcx> for CollectingVisitor<'tcx> { return; } - let node = self.tcx.hir().find(id).unwrap(); if let Some((def_id, obj_type, allow_prior)) = if let Some(decl) = node.fn_decl() { @@ -324,9 +324,11 @@ impl<'tcx> intravisit::Visitor<'tcx> for CollectingVisitor<'tcx> { | hir::Node::Ctor(hir::VariantData::Unit(..)) => { Some((id.expect_owner().def_id, ObjectType::Type, false)) } - hir::Node::Ctor(hir::VariantData::Tuple(_, _, _)) => { - Some((self.tcx.hir().parent_id(id).expect_owner().def_id, ObjectType::Type, true)) - } + hir::Node::Ctor(hir::VariantData::Tuple(_, _, _)) => Some(( + self.tcx.hir().parent_id(id).expect_owner().def_id, + ObjectType::Type, + true, + )), _ => None, } } { @@ -339,7 +341,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for CollectingVisitor<'tcx> { } Entry::Vacant(vac) => { vac.insert(val); - }, + } } } else { let e = match node { diff --git a/src/frg.rs b/src/frg.rs index ec8ce2d495..30c2d28e2e 100644 --- a/src/frg.rs +++ b/src/frg.rs @@ -121,7 +121,7 @@ where A: 'a, D: ?std::marker::Sized + DocAllocator<'a, A>, { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A>; + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A>; } lazy_static! { @@ -132,12 +132,12 @@ lazy_static! { "open", "and", "abstract", "extends", "none", "set" ] .into_iter() - .map(Identifier::from_str) + .map(Identifier::new_intern) .collect(); } impl<'a, A: 'a, D: DocAllocator<'a, A>> ToForge<'a, A, D> for Identifier { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { alloc .text("`") .append(alloc.text(if FORGE_RESERVED_SYMBOLS.contains(&self) { @@ -149,8 +149,8 @@ impl<'a, A: 'a, D: DocAllocator<'a, A>> ToForge<'a, A, D> for Identifier { } impl<'a, A: 'a, D: DocAllocator<'a, A>> ToForge<'a, A, D> for &'a Identifier { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { - (*self).as_forge(alloc) + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + (*self).build_forge(alloc) } } @@ -160,18 +160,18 @@ where &'a X: ToForge<'a, A, D>, &'a Y: ToForge<'a, A, D>, { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { alloc.forge_relation(self.0.iter().map(|(src, sinks)| { ( - std::iter::once(src.as_forge(alloc)), - sinks.iter().map(|sink| sink.as_forge(alloc)), + std::iter::once(src.build_forge(alloc)), + sinks.iter().map(|sink| sink.build_forge(alloc)), ) })) } } impl<'a, A: 'a, D: DocAllocator<'a, A>> ToForge<'a, A, D> for &'a str { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { alloc.text(self) } } @@ -191,7 +191,7 @@ fn data_sink_as_forge<'b, A, D: DocAllocator<'b, A>>( } impl<'a, A: 'a, D: DocAllocator<'a, A>> ToForge<'a, A, D> for &'a DataSink { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { match self { DataSink::Return => alloc.text("`Return"), DataSink::Argument { function, arg_slot } => { @@ -205,11 +205,11 @@ impl<'a, A: 'a, D: DocAllocator<'a, A>, T> ToForge<'a, A, D> for &'a HashSet where &'a T: ToForge<'a, A, D>, { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { if self.is_empty() { alloc.text("none") } else { - alloc.intersperse(self.iter().map(|w| w.as_forge(alloc)), "+") + alloc.intersperse(self.iter().map(|w| w.build_forge(alloc)), "+") } } } @@ -222,7 +222,7 @@ fn call_site_as_forge<'b, A, D: DocAllocator<'b, A>>( } impl<'a, A: 'a, D: DocAllocator<'a, A>> ToForge<'a, A, D> for &'a CallSite { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { call_site_as_forge(alloc, self) } } @@ -238,7 +238,7 @@ fn data_source_as_forge<'b, A, D: DocAllocator<'b, A>>( function: ctrl, position: *a as u16, } - .as_forge(alloc), + .build_forge(alloc), } } @@ -308,6 +308,8 @@ pub mod name { } use Qualifier::*; + + #[allow(clippy::type_complexity)] /// A description of the preamble of Forge `sig`s we always emit. /// /// These are in topological order, because the code generation just @@ -332,23 +334,24 @@ pub mod name { fn arr(from: &str, to: &str) -> String { from.to_string() + "->" + to } - let mut sigs = Vec::new(); - sigs.push((LABEL, Abstract, None, vec![])); - sigs.push((OBJ, Abstract, None, vec![(LABELS_REL, set(LABEL))])); - sigs.push((FUNCTION, No, Some(OBJ), vec![])); - sigs.push(( - SRC, - Abstract, - Some(OBJ), - match version { - V1 => vec![], - V2 => vec![ - (FLOW, set(SINK)), - (CTRL_FLOW, set(CALL_SITE)), - (TYPES, set(TYPE)), - ], - }, - )); + let mut sigs = vec![ + (LABEL, Abstract, None, vec![]), + (OBJ, Abstract, None, vec![(LABELS_REL, set(LABEL))]), + (FUNCTION, No, Some(OBJ), vec![]), + ( + SRC, + Abstract, + Some(OBJ), + match version { + V1 => vec![], + V2 => vec![ + (FLOW, set(SINK)), + (CTRL_FLOW, set(CALL_SITE)), + (TYPES, set(TYPE)), + ], + }, + ), + ]; match version { V1 => sigs.push(( FORMAL_PARAMETER, @@ -366,18 +369,18 @@ pub mod name { vec![(FORMAL_PARAMETER_FUNCTION, set(FUNCTION))], )), } - sigs.push((SINK, Abstract, Some(OBJ), vec![])); - sigs.push((RETURN, One, Some(SINK), vec![])); - //(CALL_SITE, Some(OBJ), vec![(FUN_REL, one(FUNCTION))])); - sigs.push(( - CALL_ARGUMENT, - No, - Some(SINK), - vec![(ARG_CALL_SITE, one(CALL_SITE))], - )); - sigs.push((TYPE, No, Some(OBJ), vec![(OTYPE_REL, set(TYPE))])); - //(CALL_ARGUMENT_OUTPUT, Some(SRC), vec![(RETURN_CALL_SITE, one(CALL_SITE))])); - sigs.push((CALL_SITE, No, Some(SRC), vec![(FUN_REL, one(FUNCTION))])); + sigs.extend([ + (SINK, Abstract, Some(OBJ), vec![]), + (RETURN, One, Some(SINK), vec![]), + ( + CALL_ARGUMENT, + No, + Some(SINK), + vec![(ARG_CALL_SITE, one(CALL_SITE))], + ), + (TYPE, No, Some(OBJ), vec![(OTYPE_REL, set(TYPE))]), + (CALL_SITE, No, Some(SRC), vec![(FUN_REL, one(FUNCTION))]), + ]); match version { V1 => sigs.push(( CTRL, @@ -422,7 +425,7 @@ fn hash_set_into_forge<'a, A: 'a, D: DocAllocator<'a, A>, T: ToForge<'a, A, D>>( if h.is_empty() { alloc.text("none") } else { - alloc.intersperse(h.into_iter().map(|w| w.as_forge(alloc)), "+") + alloc.intersperse(h.into_iter().map(|w| w.build_forge(alloc)), "+") } } @@ -487,7 +490,7 @@ struct FormalParameter { } impl<'a, A: 'a, D: DocAllocator<'a, A>> ToForge<'a, A, D> for FormalParameter { - fn as_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { + fn build_forge(self, alloc: &'a D) -> DocBuilder<'a, D, A> { alloc .text("`fp") .append(alloc.as_string(self.position)) @@ -619,22 +622,22 @@ impl ProgramDescription { .is_set(*arg_slot as u32) ) }) - .map(|s| s.as_forge(alloc)), + .map(|s| s.build_forge(alloc)), ) - .chain([id.as_forge(alloc)]) + .chain([id.build_forge(alloc)]) .chain(a.refinement.on_argument().into_iter_set_in_domain().map( |slot| { FormalParameter { function: *id, position: slot as u16, } - .as_forge(alloc) + .build_forge(alloc) }, )) // This is necessary because otherwise captured variables escape .collect::>() .into_iter(), - std::iter::once(Identifier::new(a.marker).as_forge(alloc)), + std::iter::once(Identifier::new(a.marker).build_forge(alloc)), ) }) })) @@ -646,7 +649,7 @@ impl ProgramDescription { anns.iter() .filter_map(Annotation::as_exception_annotation) .next() - .map(|_| id.as_forge(alloc)) + .map(|_| id.build_forge(alloc)) .into_iter(), std::iter::once(alloc.text(name::EXCEPTIONS_LABEL)), ) @@ -664,7 +667,7 @@ impl ProgramDescription { alloc.forge_relation(self.all_sinks().into_iter().filter_map(|src| { src.as_argument().map(|(function, _)| { ( - std::iter::once(src.as_forge(alloc)), + std::iter::once(src.build_forge(alloc)), std::iter::once(call_site_as_forge(alloc, function)), ) }) @@ -681,7 +684,7 @@ impl ProgramDescription { alloc.forge_relation(self.all_call_sites().into_iter().map(|src| { ( std::iter::once(call_site_as_forge(alloc, src)), - std::iter::once((&src.function).as_forge(alloc)), + std::iter::once((&src.function).build_forge(alloc)), ) })) } @@ -695,11 +698,11 @@ impl ProgramDescription { { alloc.forge_relation(self.annotations.iter().map(|(o, (anns, _))| { ( - std::iter::once(o.as_forge(alloc)), + std::iter::once(o.build_forge(alloc)), anns.iter() .filter_map(Annotation::as_otype_ann) .flat_map(|v| v.iter()) - .map(|t| t.as_forge(alloc)), + .map(|t| t.build_forge(alloc)), ) })) } @@ -711,9 +714,9 @@ impl ProgramDescription { D::Doc: Clone, { alloc.forge_relation(self.all_formal_parameters().into_iter().map(|p| { - let fn_forge = p.function.as_forge(alloc); + let fn_forge = p.function.build_forge(alloc); ( - std::iter::once(p.as_forge(alloc)), + std::iter::once(p.build_forge(alloc)), std::iter::once(fn_forge), ) })) @@ -733,14 +736,14 @@ impl ProgramDescription { 3, self.controllers.iter().map(|(e, ctrl)| { ( - std::iter::once(e.as_forge(alloc)), + std::iter::once(e.build_forge(alloc)), std::iter::once( alloc.hardline().append( alloc .forge_relation(ctrl.types.0.iter().map(|(i, desc)| { ( std::iter::once(data_source_as_forge(i, alloc, *e)), - desc.iter().map(|t| t.as_forge(alloc)), + desc.iter().map(|t| t.build_forge(alloc)), ) })) .indent(4), @@ -753,7 +756,7 @@ impl ProgramDescription { ctrl.types.0.iter().map(|(i, desc)| { ( std::iter::once(data_source_as_forge(i, alloc, *e)), - desc.iter().map(|t| t.as_forge(alloc)), + desc.iter().map(|t| t.build_forge(alloc)), ) }) })), @@ -775,7 +778,7 @@ impl ProgramDescription { 3, self.controllers.iter().map(|(e, ctrl)| { ( - std::iter::once(e.as_forge(alloc)), + std::iter::once(e.build_forge(alloc)), std::iter::once( alloc.hardline().append( //(&ctrl.data_flow).as_forge(alloc) @@ -786,7 +789,7 @@ impl ProgramDescription { std::iter::once(data_source_as_forge( source, alloc, *e, )), - sinks.iter().map(|snk| snk.as_forge(alloc)), + sinks.iter().map(|snk| snk.build_forge(alloc)), ) }, )) @@ -800,7 +803,7 @@ impl ProgramDescription { ctrl.data_flow.0.iter().map(|(src, snks)| { ( std::iter::once(data_source_as_forge(src, alloc, *e)), - snks.iter().map(|snk| snk.as_forge(alloc)), + snks.iter().map(|snk| snk.build_forge(alloc)), ) }) })), @@ -820,7 +823,7 @@ impl ProgramDescription { 3, self.controllers.iter().map(|(e, ctrl)| { ( - std::iter::once(e.as_forge(alloc)), + std::iter::once(e.build_forge(alloc)), std::iter::once( alloc.hardline().append( (alloc.forge_relation(ctrl.ctrl_flow.0.iter().map( @@ -885,7 +888,7 @@ impl ProgramDescription { alloc.lines( self.all_call_sites().into_iter().map(|cs| { alloc.lines( - [alloc.text("// ").append(cs.as_forge(alloc)).append(": "), + [alloc.text("// ").append(cs.build_forge(alloc)).append(": "), alloc.text("// ").append(format!("{:?}", tcx.def_path_debug_str(cs.location.innermost_function().into_def_id(tcx)))), alloc.text("// ").append(format!("{}", cs.location)), ]) @@ -908,7 +911,7 @@ impl ProgramDescription { alloc .text(l.as_str().to_owned()) .append(" = ") - .append(l.as_forge(alloc)) + .append(l.build_forge(alloc)) })), alloc.text(name::CALL_SITE).append(" = ").append( hash_set_into_call_site_forge(self.all_call_sites(), alloc), @@ -1063,8 +1066,8 @@ impl ProgramDescription { .flat_map(|label| label.refinement.on_argument().into_iter_set_in_domain().map(|i| ( - std::iter::once(FormalParameter { position: i as u16, function: *ident }.as_forge(alloc)), - std::iter::once(ident.as_forge(alloc).append("->").append(label.marker.as_str()))))) + std::iter::once(FormalParameter { position: i as u16, function: *ident }.build_forge(alloc)), + std::iter::once(ident.build_forge(alloc).append("->").append(label.marker.as_str()))))) ) ) .indent(4) @@ -1087,8 +1090,8 @@ impl ProgramDescription { ) ).collect::>(); - (std::iter::once(ctrl.as_forge(alloc)), - call_sites.into_iter().map(|cs| cs.as_forge(alloc)) + (std::iter::once(ctrl.build_forge(alloc)), + call_sites.into_iter().map(|cs| cs.build_forge(alloc)) ) }) ) diff --git a/src/ir/global_location.rs b/src/ir/global_location.rs index 25330a8344..80f28ac558 100644 --- a/src/ir/global_location.rs +++ b/src/ir/global_location.rs @@ -169,7 +169,7 @@ pub trait IsGlobalLocation: Sized + std::fmt::Display { /// It this location is top-level (i.e. `self.next() == None`), then return /// the `location` field. - fn as_local(self) -> Option { + fn as_local(&self) -> Option { if self.is_at_root() { Some(self.outermost_location()) } else { diff --git a/src/ir/regal.rs b/src/ir/regal.rs index 8bec166d44..2a051a3f5e 100644 --- a/src/ir/regal.rs +++ b/src/ir/regal.rs @@ -283,39 +283,33 @@ impl Body> { let non_transitive_aliases = crate::ana::non_transitive_aliases::compute(tcx, def_id, body_with_facts); - let dependencies_for = |location: DisplayViaDebug<_>, - arg, - is_mut_arg| - -> Dependencies> { - use rustc_ast::Mutability; - let ana = flow_analysis.state_at(*location); - let mutability = if false && is_mut_arg { - Mutability::Mut - } else { - Mutability::Not + let dependencies_for = + |location: DisplayViaDebug<_>, arg| -> Dependencies> { + use rustc_ast::Mutability; + let ana = flow_analysis.state_at(*location); + let mutability = Mutability::Not; + // Not sure this is necessary anymore because I changed the analysis + // to transitively propagate in cases where a subplace is modified + let reachable_values = non_transitive_aliases.reachable_values(arg, mutability); + // debug!("Reachable values for {arg:?} are {reachable_values:?}"); + // debug!( + // " Children are {:?}", + // reachable_values + // .into_iter() + // .flat_map(|a| non_transitive_aliases.children(*a)) + // .collect::>() + // ); + let deps = reachable_values + .iter() + .flat_map(|p| non_transitive_aliases.children(*p)) + // Commenting out this filter because reachable values doesn't + // always contain all relevant subplaces + //.filter(|p| !is_mut_arg || p != &arg) + .flat_map(|place| ana.deps(non_transitive_aliases.normalize(place))) + .map(|&(dep_loc, _dep_place)| (*domain.value(dep_loc)).into()) + .collect(); + deps }; - // Not sure this is necessary anymore because I changed the analysis - // to transitively propagate in cases where a subplace is modified - let reachable_values = non_transitive_aliases.reachable_values(arg, mutability); - // debug!("Reachable values for {arg:?} are {reachable_values:?}"); - // debug!( - // " Children are {:?}", - // reachable_values - // .into_iter() - // .flat_map(|a| non_transitive_aliases.children(*a)) - // .collect::>() - // ); - let deps = reachable_values - .iter() - .flat_map(|p| non_transitive_aliases.children(*p)) - // Commenting out this filter because reachable values doesn't - // always contain all relevant subplaces - //.filter(|p| !is_mut_arg || p != &arg) - .flat_map(|place| ana.deps(non_transitive_aliases.normalize(place))) - .map(|&(dep_loc, _dep_place)| (*domain.value(dep_loc)).into()) - .collect(); - deps - }; let mut call_argument_equations = HashSet::new(); let mut next_new_local = get_highest_local(body); let calls = body @@ -351,7 +345,7 @@ impl Body> { )); next_new_local }; - (local, dependencies_for(bbloc, a, false)) + (local, dependencies_for(bbloc, a)) }) }) .collect(), @@ -402,11 +396,11 @@ impl Body> { .map(DisplayViaDebug) .flat_map(|loc| { return_arg_deps.iter_mut().for_each(|(i, s)| { - for d in dependencies_for(loc, *i, true) { + for d in dependencies_for(loc, *i) { s.insert(d); } }); - dependencies_for(loc, mir::Place::return_place(), false).into_iter() + dependencies_for(loc, mir::Place::return_place()).into_iter() }) .collect(); @@ -448,11 +442,7 @@ impl Body> { /// if this is the right thing to do. fn recursive_ctrl_deps< 'tcx, - F: FnMut( - DisplayViaDebug, - mir::Place<'tcx>, - bool, - ) -> Dependencies>, + F: FnMut(DisplayViaDebug, mir::Place<'tcx>) -> Dependencies>, >( ctrl_ana: &ControlDependencies, bb: mir::BasicBlock, @@ -470,11 +460,8 @@ fn recursive_ctrl_deps< let terminator = body.basic_blocks[block].terminator(); if let mir::TerminatorKind::SwitchInt { discr, .. } = &terminator.kind { if let Some(discr_place) = discr.place() { - let deps = dependencies_for( - DisplayViaDebug(body.terminator_loc(block)), - discr_place, - false, - ); + let deps = + dependencies_for(DisplayViaDebug(body.terminator_loc(block)), discr_place); for d in &deps { if let Target::Call(loc) = d { seen.insert(loc.block); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index ef692a2884..309d67d99e 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -116,11 +116,11 @@ pub trait GenericArgExt<'tcx> { /// Generic arguments can reference non-type things (in particular constants /// and lifetimes). If it is a type, then this extracts that type, otherwise /// `None`. - fn as_type(self) -> Option>; + fn as_type(&self) -> Option>; } impl<'tcx> GenericArgExt<'tcx> for ty::subst::GenericArg<'tcx> { - fn as_type(self) -> Option> { + fn as_type(&self) -> Option> { match self.unpack() { ty::subst::GenericArgKind::Type(t) => Some(t), _ => None, @@ -272,11 +272,11 @@ pub trait LocationExt { /// to refer to function arguments. Those locations are not recognized the /// rustc functions that operate on MIR and thus need to be filtered before /// doing things such as indexing into a `mir::Body`. - fn is_real(self, body: &mir::Body) -> bool; + fn is_real(&self, body: &mir::Body) -> bool; } impl LocationExt for Location { - fn is_real(self, body: &mir::Body) -> bool { + fn is_real(&self, body: &mir::Body) -> bool { body.basic_blocks.get(self.block).map(|bb| // Its `<=` because if len == statement_index it refers to the // terminator @@ -656,7 +656,7 @@ impl IntoDefId for Res { /// Creates an `Identifier` for this `HirId` pub fn identifier_for_item(tcx: TyCtxt, did: D) -> Identifier { let did = did.into_def_id(tcx); - Identifier::from_str(&format!( + Identifier::new_intern(&format!( "{}_{:x}", tcx.opt_item_name(did) .or_else(|| { diff --git a/src/utils/resolve.rs b/src/utils/resolve.rs index b5a8b468ee..f2b8f33d2c 100644 --- a/src/utils/resolve.rs +++ b/src/utils/resolve.rs @@ -190,7 +190,7 @@ pub fn def_path_res<'a>(tcx: TyCtxt, path: &[&'a str]) -> Result: Sized + Copy { fn function(self, name: &str) -> FnRef<'g> { FnRef { graph: self.graph(), - ident: Identifier::from_str(name), + ident: Identifier::new_intern(name), } } fn ctrl(self, name: &str) -> CtrlRef<'g> { - let ident = Identifier::from_str(name); + let ident = Identifier::new_intern(name); CtrlRef { graph: self.graph(), ident,