1
Fork 0

Fix tests

This commit is contained in:
Ryan Levick 2021-01-05 16:46:50 +01:00 committed by Ryan Levick
parent f49ed7a6b7
commit a6d926d80d
17 changed files with 32 additions and 17 deletions

View file

@ -24,7 +24,7 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
debug!("preparing the RPATH!"); debug!("preparing the RPATH!");
let libs = config.used_crates.clone(); let libs = config.used_crates;
let libs = libs.iter().filter_map(|&(_, ref l)| l.option()).collect::<Vec<_>>(); let libs = libs.iter().filter_map(|&(_, ref l)| l.option()).collect::<Vec<_>>();
let rpaths = get_rpaths(config, &libs); let rpaths = get_rpaths(config, &libs);
let mut flags = rpaths_to_flags(&rpaths); let mut flags = rpaths_to_flags(&rpaths);

View file

@ -46,6 +46,14 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
{ {
// Check that we're dealing with a trait method // Check that we're dealing with a trait method
if let Some(trait_id) = cx.tcx.trait_of_item(did) { if let Some(trait_id) = cx.tcx.trait_of_item(did) {
// Check we're dealing with one of the traits we care about
if ![sym::Clone, sym::Deref, sym::Borrow]
.iter()
.any(|s| cx.tcx.is_diagnostic_item(*s, trait_id))
{
return;
}
let substs = cx.typeck_results().node_substs(expr.hir_id); let substs = cx.typeck_results().node_substs(expr.hir_id);
// We can't resolve on types that recursively require monomorphization, // We can't resolve on types that recursively require monomorphization,
// so check that we don't need to perfom substitution // so check that we don't need to perfom substitution
@ -54,7 +62,6 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
// Resolve the trait method instance // Resolve the trait method instance
if let Ok(Some(i)) = ty::Instance::resolve(cx.tcx, param_env, did, substs) { if let Ok(Some(i)) = ty::Instance::resolve(cx.tcx, param_env, did, substs) {
// Check that it implements the noop diagnostic // Check that it implements the noop diagnostic
tracing::debug!("Resolves to: {:?}", i.def_id());
if [ if [
sym::noop_method_borrow, sym::noop_method_borrow,
sym::noop_method_clone, sym::noop_method_clone,

View file

@ -12,7 +12,6 @@ use rustc_target::spec::abi;
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt; use std::fmt;
use std::ops::Deref;
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable)] #[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable)]
pub struct ExpectedFound<T> { pub struct ExpectedFound<T> {
@ -548,7 +547,6 @@ impl<T> Trait<T> for X {
TargetFeatureCast(def_id) => { TargetFeatureCast(def_id) => {
let attrs = self.get_attrs(*def_id); let attrs = self.get_attrs(*def_id);
let target_spans = attrs let target_spans = attrs
.deref()
.iter() .iter()
.filter(|attr| attr.has_name(sym::target_feature)) .filter(|attr| attr.has_name(sym::target_feature))
.map(|attr| attr.span); .map(|attr| attr.span);

View file

@ -165,7 +165,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
self.consume_operand(location, value); self.consume_operand(location, value);
// Invalidate all borrows of local places // Invalidate all borrows of local places
let borrow_set = self.borrow_set.clone(); let borrow_set = self.borrow_set;
let resume = self.location_table.start_index(resume.start_location()); let resume = self.location_table.start_index(resume.start_location());
for (i, data) in borrow_set.iter_enumerated() { for (i, data) in borrow_set.iter_enumerated() {
if borrow_of_local_data(data.borrowed_place) { if borrow_of_local_data(data.borrowed_place) {
@ -177,7 +177,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
} }
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => { TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
// Invalidate all borrows of local places // Invalidate all borrows of local places
let borrow_set = self.borrow_set.clone(); let borrow_set = self.borrow_set;
let start = self.location_table.start_index(location); let start = self.location_table.start_index(location);
for (i, data) in borrow_set.iter_enumerated() { for (i, data) in borrow_set.iter_enumerated() {
if borrow_of_local_data(data.borrowed_place) { if borrow_of_local_data(data.borrowed_place) {
@ -369,7 +369,7 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
); );
let tcx = self.tcx; let tcx = self.tcx;
let body = self.body; let body = self.body;
let borrow_set = self.borrow_set.clone(); let borrow_set = self.borrow_set;
let indices = self.borrow_set.indices(); let indices = self.borrow_set.indices();
each_borrow_involving_path( each_borrow_involving_path(
self, self,
@ -377,7 +377,7 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
body, body,
location, location,
(sd, place), (sd, place),
&borrow_set.clone(), borrow_set,
indices, indices,
|this, borrow_index, borrow| { |this, borrow_index, borrow| {
match (rw, borrow.kind) { match (rw, borrow.kind) {

View file

@ -51,7 +51,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
PatKind::Constant { value } => Test { PatKind::Constant { value } => Test {
span: match_pair.pattern.span, span: match_pair.pattern.span,
kind: TestKind::Eq { value, ty: match_pair.pattern.ty.clone() }, kind: TestKind::Eq { value, ty: match_pair.pattern.ty },
}, },
PatKind::Range(range) => { PatKind::Range(range) => {

View file

@ -129,6 +129,7 @@ symbols! {
BTreeMap, BTreeMap,
BTreeSet, BTreeSet,
BinaryHeap, BinaryHeap,
Borrow,
C, C,
CString, CString,
Center, Center,
@ -141,6 +142,7 @@ symbols! {
Decodable, Decodable,
Decoder, Decoder,
Default, Default,
Deref,
Encodable, Encodable,
Encoder, Encoder,
Eq, Eq,

View file

@ -819,7 +819,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
sig.decl sig.decl
.inputs .inputs
.iter() .iter()
.map(|arg| match arg.clone().kind { .map(|arg| match arg.kind {
hir::TyKind::Tup(ref tys) => ArgKind::Tuple( hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
Some(arg.span), Some(arg.span),
vec![("_".to_owned(), "_".to_owned()); tys.len()], vec![("_".to_owned(), "_".to_owned()); tys.len()],

View file

@ -165,7 +165,7 @@ crate fn evaluate_goal<'tcx>(
// let's just ignore that // let's just ignore that
let sol = Canonical { let sol = Canonical {
max_universe: ty::UniverseIndex::from_usize(0), max_universe: ty::UniverseIndex::from_usize(0),
variables: obligation.variables.clone(), variables: obligation.variables,
value: QueryResponse { value: QueryResponse {
var_values: CanonicalVarValues { var_values: IndexVec::new() } var_values: CanonicalVarValues { var_values: IndexVec::new() }
.make_identity(tcx), .make_identity(tcx),

View file

@ -465,7 +465,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let expected_arg_tys = self.expected_inputs_for_expected_output( let expected_arg_tys = self.expected_inputs_for_expected_output(
call_expr.span, call_expr.span,
expected, expected,
fn_sig.output().clone(), fn_sig.output(),
fn_sig.inputs(), fn_sig.inputs(),
); );

View file

@ -711,7 +711,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}); });
let ret_ty = ret_coercion.borrow().expected_ty(); let ret_ty = ret_coercion.borrow().expected_ty();
let return_expr_ty = self.check_expr_with_hint(return_expr, ret_ty.clone()); let return_expr_ty = self.check_expr_with_hint(return_expr, ret_ty);
ret_coercion.borrow_mut().coerce( ret_coercion.borrow_mut().coerce(
self, self,
&self.cause(return_expr.span, ObligationCauseCode::ReturnValue(return_expr.hir_id)), &self.cause(return_expr.span, ObligationCauseCode::ReturnValue(return_expr.hir_id)),

View file

@ -153,6 +153,7 @@
/// [`HashMap<K, V>`]: ../../std/collections/struct.HashMap.html /// [`HashMap<K, V>`]: ../../std/collections/struct.HashMap.html
/// [`String`]: ../../std/string/struct.String.html /// [`String`]: ../../std/string/struct.String.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "Borrow"]
pub trait Borrow<Borrowed: ?Sized> { pub trait Borrow<Borrowed: ?Sized> {
/// Immutably borrows from an owned value. /// Immutably borrows from an owned value.
/// ///

View file

@ -104,6 +104,7 @@
/// [impls]: #implementors /// [impls]: #implementors
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[lang = "clone"] #[lang = "clone"]
#[rustc_diagnostic_item = "Clone"]
pub trait Clone: Sized { pub trait Clone: Sized {
/// Returns a copy of the value. /// Returns a copy of the value.
/// ///

View file

@ -60,6 +60,7 @@
#[doc(alias = "*")] #[doc(alias = "*")]
#[doc(alias = "&*")] #[doc(alias = "&*")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "Deref"]
pub trait Deref { pub trait Deref {
/// The resulting type after dereferencing. /// The resulting type after dereferencing.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]

View file

@ -1,6 +1,8 @@
// run-pass // run-pass
// pretty-expanded FIXME #23616 // pretty-expanded FIXME #23616
#![allow(noop_method_call)]
struct NoClone; struct NoClone;
fn main() { fn main() {

View file

@ -14,5 +14,6 @@ mod y {
pub fn main() { pub fn main() {
use x::*; use x::*;
#[allow(noop_method_call)]
(&0).deref(); (&0).deref();
} }

View file

@ -29,5 +29,6 @@ m!(y);
fn main() { fn main() {
use crate::y::*; use crate::y::*;
#[allow(noop_method_call)]
(&()).deref(); (&()).deref();
} }

View file

@ -3,6 +3,7 @@
// check-pass // check-pass
#![feature(decl_macro, rustc_attrs)] #![feature(decl_macro, rustc_attrs)]
#![allow(noop_method_call)]
mod x { mod x {
pub use std::ops::Not as _; pub use std::ops::Not as _;