From d246b2cc9cef47df836cadae1d274cad21e20558 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Mon, 31 Dec 2018 02:01:34 +0000 Subject: [PATCH] Cosmetic improvements and fixes to stderr files --- src/librustc/hir/map/collector.rs | 2 +- src/librustc/hir/map/definitions.rs | 18 +++---- src/librustc/hir/mod.rs | 33 ++++++++---- src/librustc/infer/resolve.rs | 2 +- src/librustc/lint/builtin.rs | 17 ++---- src/librustc/traits/mod.rs | 2 +- src/librustc/traits/object_safety.rs | 6 +-- src/librustc/traits/project.rs | 26 ++++----- src/librustc/traits/select.rs | 10 ++-- src/librustc/ty/codec.rs | 7 ++- src/librustc/ty/context.rs | 7 ++- src/librustc/ty/mod.rs | 24 +++++++-- src/librustc/ty/subst.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_lint/builtin.rs | 30 +++++------ src/librustc_resolve/lib.rs | 2 +- src/librustc_typeck/astconv.rs | 53 +++---------------- src/librustc_typeck/collect.rs | 47 ++++++++-------- src/test/run-pass/issues/issue-33140.stderr | 26 --------- .../traits/trait-object-auto-dedup.rs | 9 ++-- .../traits/trait-object-auto-dedup.stderr | 50 ----------------- src/test/ui/issues/issue-33140.rs | 6 +-- src/test/ui/issues/issue-33140.stderr | 17 ++---- src/test/ui/lint/lint-duplicate-traits.rs | 17 ------ src/test/ui/lint/lint-duplicate-traits.stderr | 37 ------------- .../lint-incoherent-auto-trait-objects.rs | 2 - .../lint-incoherent-auto-trait-objects.stderr | 22 +------- .../traits/trait-object-auto-dedup-in-impl.rs | 15 +++--- .../trait-object-auto-dedup-in-impl.stderr | 33 ++++-------- .../trivial-bounds-inconsistent-projection.rs | 3 +- ...vial-bounds-inconsistent-projection.stderr | 14 ++--- src/test/ui/type/type-alias-bounds.rs | 38 ++++++------- src/test/ui/type/type-alias-bounds.stderr | 34 ++++++------ src/test/ui/type/type-check-defaults.rs | 8 +-- src/test/ui/type/type-check-defaults.stderr | 32 +++++------ 35 files changed, 232 insertions(+), 421 deletions(-) delete mode 100644 src/test/run-pass/issues/issue-33140.stderr delete mode 100644 src/test/run-pass/traits/trait-object-auto-dedup.stderr delete mode 100644 src/test/ui/lint/lint-duplicate-traits.rs delete mode 100644 src/test/ui/lint/lint-duplicate-traits.stderr diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 78acea9f58814..69fc1cbb55f31 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -14,7 +14,7 @@ use syntax_pos::Span; use ich::StableHashingContext; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; -/// A Visitor that walks over the HIR and collects Nodes into a HIR map +/// A visitor that walks over the HIR and collects `Node`s into a HIR map. pub(super) struct NodeCollector<'a, 'hir> { /// The crate krate: &'hir Crate, diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 22b148c0adec2..e25ba12b56b27 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -260,9 +260,9 @@ impl DefPath { DefPath { data: data, krate: krate } } - /// Returns a string representation of the DefPath without + /// Returns a string representation of the `DefPath` without /// the crate-prefix. This method is useful if you don't have - /// a TyCtxt available. + /// a `TyCtxt` available. pub fn to_string_no_crate(&self) -> String { let mut s = String::with_capacity(self.data.len() * 16); @@ -271,13 +271,13 @@ impl DefPath { "::{}[{}]", component.data.as_interned_str(), component.disambiguator) - .unwrap(); + .unwrap(); } s } - /// Return filename friendly string of the DefPah with the + /// Returns filename-friendly string of the `DefPath` with the /// crate-prefix. pub fn to_string_friendly(&self, crate_imported_name: F) -> String where F: FnOnce(CrateNum) -> Symbol @@ -295,16 +295,16 @@ impl DefPath { "{}[{}]", component.data.as_interned_str(), component.disambiguator) - .unwrap(); + .unwrap(); } } s } - /// Return filename friendly string of the DefPah without + /// Returns filename-friendly string of the `DefPath` without /// the crate-prefix. This method is useful if you don't have - /// a TyCtxt available. + /// a `TyCtxt` available. pub fn to_filename_friendly_no_crate(&self) -> String { let mut s = String::with_capacity(self.data.len() * 16); @@ -319,7 +319,7 @@ impl DefPath { "{}[{}]", component.data.as_interned_str(), component.disambiguator) - .unwrap(); + .unwrap(); } } s @@ -659,7 +659,7 @@ impl DefPathData { GlobalMetaData(name) => { return name } - // note that this does not show up in user printouts + // Note that this does not show up in user print-outs. CrateRoot => "{{root}}", Impl => "{{impl}}", Misc => "{{?}}", diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index d4f34dc073d14..5d0a4d6a100f0 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -10,6 +10,7 @@ pub use self::PrimTy::*; pub use self::UnOp::*; pub use self::UnsafeSource::*; +use errors::FatalError; use hir::def::Def; use hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; use util::nodemap::{NodeMap, FxHashSet}; @@ -607,7 +608,7 @@ pub enum SyntheticTyParamKind { ImplTrait } -/// A `where` clause in a definition +/// A `where` clause in a definition. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct WhereClause { pub id: NodeId, @@ -626,7 +627,7 @@ impl WhereClause { } } -/// A single predicate in a `where` clause +/// A single predicate in a `where` clause. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum WherePredicate { /// A type binding (e.g., `for<'c> Foo: Send + Clone + 'c`). @@ -2053,6 +2054,20 @@ pub struct TraitRef { pub hir_ref_id: HirId, } +impl TraitRef { + /// Get the `DefId` of the referenced trait. It _must_ actually be a trait or trait alias. + pub fn trait_def_id(&self) -> DefId { + match self.path.def { + Def::Trait(did) => did, + Def::TraitAlias(did) => did, + Def::Err => { + FatalError.raise(); + } + _ => unreachable!(), + } + } +} + #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct PolyTraitRef { /// The `'a` in `<'a> Foo<&'a T>`. @@ -2484,7 +2499,7 @@ impl CodegenFnAttrs { } } - /// True if `#[inline]` or `#[inline(always)]` is present. + /// Returns whether `#[inline]` or `#[inline(always)]` is present. pub fn requests_inline(&self) -> bool { match self.inline { InlineAttr::Hint | InlineAttr::Always => true, @@ -2492,17 +2507,17 @@ impl CodegenFnAttrs { } } - /// True if it looks like this symbol needs to be exported, for example: + /// Returns whether it looks like this symbol needs to be exported, for example: /// - /// * `#[no_mangle]` is present - /// * `#[export_name(...)]` is present - /// * `#[linkage]` is present + /// * `#[no_mangle]` is present. + /// * `#[export_name(...)]` is present. + /// * `#[linkage]` is present. pub fn contains_extern_indicator(&self) -> bool { self.flags.contains(CodegenFnAttrFlags::NO_MANGLE) || self.export_name.is_some() || match self.linkage { - // these are private, make sure we don't try to consider - // them external + // These are private, so make sure we don't try to consider + // them external. None | Some(Linkage::Internal) | Some(Linkage::Private) => false, diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index f6131c01b372f..a623c04cad56f 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -119,7 +119,7 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, 'tcx> /// then an `Err` result is returned. pub fn fully_resolve<'a, 'gcx, 'tcx, T>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, value: &T) -> FixupResult - where T : TypeFoldable<'tcx> + where T: TypeFoldable<'tcx> { let mut full_resolver = FullTypeResolver { infcx: infcx, err: None }; let result = value.fold_with(&mut full_resolver); diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index f28df7a4be3e4..ecdfe03be21e7 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -353,9 +353,10 @@ declare_lint! { } declare_lint! { - pub DUPLICATE_AUTO_TRAITS_IN_TRAIT_OBJECTS, - Warn, - "duplicate auto traits in trait object bounds" + pub DEPRECATED_IN_FUTURE, + Allow, + "detects use of items that will be deprecated in a future version", + report_in_external_macro: true } /// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`. @@ -367,13 +368,6 @@ pub mod parser { } } -declare_lint! { - pub DEPRECATED_IN_FUTURE, - Allow, - "detects use of items that will be deprecated in a future version", - report_in_external_macro: true -} - /// Does nothing as a lint pass, but registers some `Lint`s /// that are used by other parts of the compiler. #[derive(Copy, Clone)] @@ -436,9 +430,8 @@ impl LintPass for HardwiredLints { PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, MACRO_USE_EXTERN_CRATE, MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, - DUPLICATE_AUTO_TRAITS_IN_TRAIT_OBJECTS, - parser::QUESTION_MARK_MACRO_SEP, DEPRECATED_IN_FUTURE, + parser::QUESTION_MARK_MACRO_SEP, ) } } diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 33124b49e6242..4cb228ebe4f05 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -898,7 +898,7 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>( param_env: ty::ParamEnv<'tcx>, value: &T) -> Result>> - where T : TypeFoldable<'tcx> + where T: TypeFoldable<'tcx> { debug!("fully_normalize_with_fulfillcx(value={:?})", value); let selcx = &mut SelectionContext::new(infcx); diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 1554afdeefdaf..ba1bdee1db97d 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -173,9 +173,9 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { predicates .predicates .iter() - .map(|(predicate, _)| predicate.subst_supertrait(self, &trait_ref)) - .any(|predicate| { - match predicate { + .map(|(pred, _)| pred.subst_supertrait(self, &trait_ref)) + .any(|pred| { + match pred { ty::Predicate::Trait(ref data) => { // In the case of a trait predicate, we can skip the "self" type. data.skip_binder().input_types().skip(1).any(|t| t.has_self_ty()) diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 952b37b89f2d4..6324e6733ee36 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -78,10 +78,10 @@ pub type ProjectionTyObligation<'tcx> = /// When attempting to resolve `::Name` ... #[derive(Debug)] pub enum ProjectionTyError<'tcx> { - /// ...we found multiple sources of information and couldn't resolve the ambiguity. + /// ... we found multiple sources of information and couldn't resolve the ambiguity. TooManyCandidates, - /// ...an error occurred matching `T : TraitRef` + /// ... an error occurred matching `T: TraitRef`. TraitSelectionError(SelectionError<'tcx>), } @@ -92,13 +92,13 @@ pub struct MismatchedProjectionTypes<'tcx> { #[derive(PartialEq, Eq, Debug)] enum ProjectionTyCandidate<'tcx> { - // from a where-clause in the env or object type + // From a where-clause in the env or object type. ParamEnv(ty::PolyProjectionPredicate<'tcx>), - // from the definition of `Trait` when you have something like <::B as Trait2>::C + // From the definition of `Trait` when you have something like `<::B as Trait2>::C`. TraitDef(ty::PolyProjectionPredicate<'tcx>), - // from a "impl" (or a "pseudo-impl" returned by select) + // From a "impl" (or a "pseudo-impl" returned by select). Select(Selection<'tcx>), } @@ -270,7 +270,7 @@ pub fn normalize<'a, 'b, 'gcx, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'gcx cause: ObligationCause<'tcx>, value: &T) -> Normalized<'tcx, T> - where T : TypeFoldable<'tcx> + where T: TypeFoldable<'tcx> { normalize_with_depth(selcx, param_env, cause, 0, value) } @@ -284,7 +284,7 @@ pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>( value: &T) -> Normalized<'tcx, T> - where T : TypeFoldable<'tcx> + where T: TypeFoldable<'tcx> { debug!("normalize_with_depth(depth={}, value={:?})", depth, value); let mut normalizer = AssociatedTypeNormalizer::new(selcx, param_env, cause, depth); @@ -386,7 +386,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, // handle normalization within binders because // otherwise we wind up a need to normalize when doing // trait matching (since you can have a trait - // obligation like `for<'a> T::B : Fn(&'a int)`), but + // obligation like `for<'a> T::B: Fn(&'a int)`), but // we can't normalize with bound regions in scope. So // far now we just ignore binders but only normalize // if all bound regions are gone (and then we still @@ -948,7 +948,7 @@ fn assemble_candidates_from_param_env<'cx, 'gcx, 'tcx>( /// /// ``` /// trait Foo { -/// type FooT : Bar +/// type FooT: Bar /// } /// ``` /// @@ -1139,8 +1139,8 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>( // fn foo(...) { } // ``` // - // If the user writes `::Foo`, then the `T - // : SomeTrait` binding does not help us decide what the + // If the user writes `::Foo`, then the + // `T: SomeTrait` binding does not help us decide what the // type `Foo` is (at least, not more specifically than // what we already knew). // @@ -1150,10 +1150,10 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>( // fn bar>(...) { ... } // ``` // - // Doesn't the `T : Sometrait` predicate help + // Doesn't the `T: Sometrait` predicate help // resolve `T::Foo`? And of course it does, but in fact // that single predicate is desugared into two predicates - // in the compiler: a trait predicate (`T : SomeTrait`) and a + // in the compiler: a trait predicate (`T: SomeTrait`) and a // projection. And the projection where clause is handled // in `assemble_candidates_from_param_env`. false diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 06154c2c72225..288eb4b9a0c35 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -3812,19 +3812,19 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { let mut predicates: Vec<_> = predicates .predicates .iter() - .flat_map(|(predicate, _)| { - let predicate = normalize_with_depth( + .flat_map(|(pred, _)| { + let pred = normalize_with_depth( self, param_env, cause.clone(), recursion_depth, - &predicate.subst(tcx, substs), + &pred.subst(tcx, substs), ); - predicate.obligations.into_iter().chain(Some(Obligation { + pred.obligations.into_iter().chain(Some(Obligation { cause: cause.clone(), recursion_depth, param_env, - predicate: predicate.value, + predicate: pred.value, })) }) .collect(); diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 6429e3249c4c5..07e2683efa62e 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -107,7 +107,6 @@ pub fn encode_predicates<'tcx, E, C>(encoder: &mut E, } pub trait TyDecoder<'a, 'tcx: 'a>: Decoder { - fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>; fn peek_byte(&self) -> u8; @@ -168,8 +167,8 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D) Ok(ty::GenericPredicates { parent: Decodable::decode(decoder)?, predicates: (0..decoder.read_usize()?).map(|_| { - // Handle shorthands first, if we have an usize > 0x80. - let predicate = if decoder.positioned_at_shorthand() { + // Handle shorthands first, if we have an usize greater than `0x80`. + let pred = if decoder.positioned_at_shorthand() { let pos = decoder.read_usize()?; assert!(pos >= SHORTHAND_OFFSET); let shorthand = pos - SHORTHAND_OFFSET; @@ -178,7 +177,7 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D) } else { ty::Predicate::decode(decoder) }?; - Ok((predicate, Decodable::decode(decoder)?)) + Ok((pred, Decodable::decode(decoder)?)) }) .collect::, _>>()?, }) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 93a0affff5907..d6a148baa09f1 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -16,8 +16,7 @@ use lint::{self, Lint}; use ich::{StableHashingContext, NodeIdHashingMode}; use infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use infer::outlives::free_region_map::FreeRegionMap; -use middle::cstore::CrateStoreDyn; -use middle::cstore::EncodedMetadata; +use middle::cstore::{CrateStoreDyn, EncodedMetadata}; use middle::lang_items; use middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use middle::stability; @@ -1366,7 +1365,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn def_path_debug_str(self, def_id: DefId) -> String { // We are explicitly not going through queries here in order to get - // crate name and disambiguator since this code is called from debug!() + // crate name and disambiguator since this code is called from `debug!()` // statements within the query system and we'd run into endless // recursion otherwise. let (crate_name, crate_disambiguator) = if def_id.is_local() { @@ -1390,7 +1389,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } // Note that this is *untracked* and should only be used within the query - // system if the result is otherwise tracked through queries + // system if the result is otherwise tracked through queries. pub fn crate_data_as_rc_any(self, cnum: CrateNum) -> Lrc { self.cstore.crate_data_as_rc_any(cnum) } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index c6904d04bf1cd..9f7297440a411 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1223,11 +1223,15 @@ impl<'tcx> PolyTraitPredicate<'tcx> { // ok to skip binder since trait def-id does not care about regions self.skip_binder().def_id() } + + pub fn self_ty(&self) -> Binder> { + self.map_bound(|p| p.self_ty()) + } } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] -pub struct OutlivesPredicate(pub A, pub B); // `A: B` -pub type PolyOutlivesPredicate = ty::Binder>; +pub struct OutlivesPredicate(pub A, pub B); // `A: B` +pub type PolyOutlivesPredicate = ty::Binder>; pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate, ty::Region<'tcx>>; pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate, @@ -1235,6 +1239,16 @@ pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate, pub type PolyRegionOutlivesPredicate<'tcx> = ty::Binder>; pub type PolyTypeOutlivesPredicate<'tcx> = ty::Binder>; +impl PolyOutlivesPredicate { + pub fn var(&self) -> Binder { + self.map_bound(|pred| pred.0) + } + + pub fn value(&self) -> Binder { + self.map_bound(|pred| pred.1) + } +} + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct SubtypePredicate<'tcx> { pub a_is_expected: bool, @@ -1276,11 +1290,11 @@ impl<'tcx> PolyProjectionPredicate<'tcx> { // This is because here `self` has a `Binder` and so does our // return value, so we are preserving the number of binding // levels. - self.map_bound(|predicate| predicate.projection_ty.trait_ref(tcx)) + self.map_bound(|pred| pred.projection_ty.trait_ref(tcx)) } pub fn ty(&self) -> Binder> { - self.map_bound(|predicate| predicate.ty) + self.map_bound(|pred| pred.ty) } /// The `DefId` of the `TraitItem` for the associated type. @@ -1345,7 +1359,7 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> { } } -// A custom iterator used by Predicate::walk_tys. +// A custom iterator used by `Predicate::walk_tys`. enum WalkTysIter<'tcx, I, J, K> where I: Iterator>, J: Iterator>, diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 64e7af815b4bf..71a157f239dad 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -362,7 +362,7 @@ pub trait Subst<'tcx>: Sized { -> Self; } -impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T { +impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { fn subst_spanned<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &[Kind<'tcx>], span: Option) diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 66303ab71b25f..e60452c857006 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -1352,7 +1352,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { match *region { ty::ReScope(scope) => { Some(self.tcx.sess.source_map().end_point( - scope.span(self.tcx, &self.region_scope_tree))) + scope.span(self.tcx, &self.region_scope_tree))) } _ => None } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index cd4cbcc13a6f2..e6f9766f62817 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -13,10 +13,13 @@ //! `LintPass` (also, note that such lints will need to be defined in //! `rustc::lint::builtin`, not here). //! -//! If you define a new `LintPass`, you will also need to add it to the -//! `add_builtin!` or `add_builtin_with_new!` invocation in `lib.rs`. -//! Use the former for unit-like structs and the latter for structs with -//! a `pub fn new()`. +//! If you define a new `EarlyLintPass`, you will also need to add it to the +//! `add_early_builtin!` or `add_early_builtin_with_new!` invocation in +//! `lib.rs`. Use the former for unit-like structs and the latter for structs +//! with a `pub fn new()`. +//! +//! If you define a new `LateLintPass`, you will also need to add it to the +//! `late_lint_methods!` invocation in `lib.rs`. use rustc::hir::def::Def; use rustc::hir::def_id::DefId; @@ -46,7 +49,7 @@ use rustc::hir::intravisit::FnKind; use nonstandard_style::{MethodLateContext, method_context}; -// hardwired lints from librustc +// Hardwired lints from librustc pub use lint::builtin::*; declare_lint! { @@ -217,7 +220,7 @@ impl LintPass for UnsafeCode { impl UnsafeCode { fn report_unsafe(&self, cx: &LateContext, span: Span, desc: &'static str) { - // This comes from a macro that has #[allow_internal_unsafe]. + // This comes from a macro that has `#[allow_internal_unsafe]`. if span.allows_unsafe() { return; } @@ -229,7 +232,7 @@ impl UnsafeCode { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { if let hir::ExprKind::Block(ref blk, _) = e.node { - // Don't warn about generated blocks, that'll just pollute the output. + // Don't warn about generated blocks; that'll just pollute the output. if blk.rules == hir::UnsafeBlock(hir::UserProvided) { self.report_unsafe(cx, blk.span, "usage of an `unsafe` block"); } @@ -289,7 +292,7 @@ declare_lint! { } pub struct MissingDoc { - /// Stack of whether #[doc(hidden)] is set + /// Stack of whether `#[doc(hidden)]` is set /// at each level which has lint attributes. doc_hidden_stack: Vec, @@ -328,7 +331,7 @@ impl MissingDoc { // Only check publicly-visible items, using the result from the privacy pass. // It's an option so the crate root can also use this function (it doesn't - // have a NodeId). + // have a `NodeId`). if let Some(id) = id { if !cx.access_levels.is_exported(id) { return; @@ -399,7 +402,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { hir::ItemKind::Struct(..) => "a struct", hir::ItemKind::Union(..) => "a union", hir::ItemKind::Trait(.., ref trait_item_refs) => { - // Issue #11592, traits are always considered exported, even when private. + // Issue #11592: traits are always considered exported, even when private. if let hir::VisibilityKind::Inherited = it.vis.node { self.private_traits.insert(it.id); for trait_item_ref in trait_item_refs { @@ -411,7 +414,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } hir::ItemKind::Ty(..) => "a type alias", hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) => { - // If the trait is private, add the impl items to private_traits so they don't get + // If the trait is private, add the impl items to `private_traits` so they don't get // reported for missing docs. let real_trait = trait_ref.path.def.def_id(); if let Some(node_id) = cx.tcx.hir().as_local_node_id(real_trait) { @@ -1320,7 +1323,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints { use rustc::ty::fold::TypeFoldable; use rustc::ty::Predicate::*; - if cx.tcx.features().trivial_bounds { let def_id = cx.tcx.hir().local_def_id(item.id); let predicates = cx.tcx.predicates_of(def_id); @@ -1590,7 +1592,7 @@ impl EarlyLintPass for KeywordIdents { }, }; - // don't lint `r#foo` + // Don't lint `r#foo`. if is_raw_ident(ident) { return; } @@ -1837,8 +1839,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements { ); err.emit(); } - } } - } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index cf949b62a634e..84d53c277540d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2742,7 +2742,7 @@ impl<'a> Resolver<'a> { fn check_trait_item(&mut self, ident: Ident, ns: Namespace, span: Span, err: F) where F: FnOnce(Name, &str) -> ResolutionError { - // If there is a TraitRef in scope for an impl, then the method must be in the + // If there is a `TraitRef` in scope for an impl, then the method must be in the // trait. if let Some((module, _)) = self.current_trait_ref { if self.resolve_ident_in_module( diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7993ece6d2ef2..c0734d0d8124f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2,7 +2,7 @@ //! The main routine here is `ast_ty_to_ty()`; each use is is parameterized by //! an instance of `AstConv`. -use errors::{Applicability, FatalError, DiagnosticId}; +use errors::{Applicability, DiagnosticId}; use hir::{self, GenericArg, GenericArgs}; use hir::def::Def; use hir::def_id::DefId; @@ -29,7 +29,6 @@ use util::nodemap::FxHashMap; use std::collections::BTreeSet; use std::iter; -use std::ops::Range; use std::slice; use super::{check_type_alias_enum_variants_enabled}; @@ -690,26 +689,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { { self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1); - let trait_def_id = self.trait_def_id(trait_ref); self.ast_path_to_mono_trait_ref(trait_ref.path.span, - trait_def_id, + trait_ref.trait_def_id(), self_ty, trait_ref.path.segments.last().unwrap()) } - /// Get the `DefId` of the given trait ref. It _must_ actually be a trait or trait alias. - fn trait_def_id(&self, trait_ref: &hir::TraitRef) -> DefId { - let path = &trait_ref.path; - match path.def { - Def::Trait(trait_def_id) => trait_def_id, - Def::TraitAlias(alias_def_id) => alias_def_id, - Def::Err => { - FatalError.raise(); - } - _ => unreachable!(), - } - } - /// The given trait-ref must actually be a trait. pub(super) fn instantiate_poly_trait_ref_inner(&self, trait_ref: &hir::TraitRef, @@ -718,7 +703,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { speculative: bool) -> (ty::PolyTraitRef<'tcx>, Option>) { - let trait_def_id = self.trait_def_id(trait_ref); + let trait_def_id = trait_ref.trait_def_id(); debug!("instantiate_poly_trait_ref({:?}, def_id={:?})", trait_ref, trait_def_id); @@ -955,7 +940,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { } fn conv_object_ty_poly_trait_ref(&self, - node_id: ast::NodeId, span: Span, trait_bounds: &[hir::PolyTraitRef], lifetime: &hir::Lifetime) @@ -1143,33 +1127,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { let extra_principal_trait = auto_traits.iter().skip(1).any( |tr| tr.trait_ref().def_id() == principal.def_id()); - // Lint duplicate auto traits, and then remove duplicates. + // Remove duplicate auto traits. auto_traits.sort_by_key(|i| i.trait_ref().def_id()); - let emit_dup_traits_err = |range: Range| { - let mut err = tcx.struct_span_lint_node( - lint::builtin::DUPLICATE_AUTO_TRAITS_IN_TRAIT_OBJECTS, - node_id, - auto_traits[range.clone()].iter().map(|i| i.bottom().1).collect::>(), - &format!("duplicate auto trait `{}` found in trait object", - auto_traits[range.start].trait_ref())); - err.label_with_exp_info(&auto_traits[range.start], "first use of auto trait"); - for i in (range.start + 1)..range.end { - err.label_with_exp_info(&auto_traits[i], "subsequent use of auto trait"); - } - err.emit(); - }; - let mut seq_start = 0; - for i in 1..auto_traits.len() { - if auto_traits[i].trait_ref().def_id() != auto_traits[i - 1].trait_ref().def_id() { - if i - seq_start > 1 { - emit_dup_traits_err(seq_start..i); - } - seq_start = i; - } - } - if auto_traits.len() - seq_start > 1 { - emit_dup_traits_err(seq_start..auto_traits.len()); - } auto_traits.dedup_by_key(|i| i.trait_ref().def_id()); // If principal is auto trait, remove it from list of auto traits. @@ -1794,7 +1753,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { tcx.mk_fn_ptr(self.ty_of_fn(bf.unsafety, bf.abi, &bf.decl)) } hir::TyKind::TraitObject(ref bounds, ref lifetime) => { - self.conv_object_ty_poly_trait_ref(ast_ty.id, ast_ty.span, bounds, lifetime) + self.conv_object_ty_poly_trait_ref(ast_ty.span, bounds, lifetime) } hir::TyKind::Path(hir::QPath::Resolved(ref maybe_qself, ref path)) => { debug!("ast_ty_to_ty: maybe_qself={:?} path={:?}", maybe_qself, path); @@ -2026,7 +1985,7 @@ impl<'a, 'gcx, 'tcx> Bounds<'tcx> { pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, param_ty: Ty<'tcx>) -> Vec<(ty::Predicate<'tcx>, Span)> { - // If it could be sized, and is, add the sized predicate. + // If it could be sized, and is, add the `Sized` predicate. let sized_predicate = self.implicitly_sized.and_then(|span| { tcx.lang_items().sized_trait().map(|sized| { let trait_ref = ty::TraitRef { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index d5e606e7cfc53..38d800fc62788 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -21,11 +21,10 @@ use middle::lang_items::SizedTraitLangItem; use middle::resolve_lifetime as rl; use middle::weak_lang_items; use rustc::mir::mono::Linkage; +use rustc::ty::{self, AdtKind, Binder, Predicate, ToPolyTraitRef, Ty, TyCtxt}; use rustc::ty::query::Providers; use rustc::ty::subst::Substs; -use rustc::ty::util::Discr; -use rustc::ty::util::IntTypeExt; -use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt}; +use rustc::ty::util::{Discr, IntTypeExt}; use rustc::ty::{ReprOptions, ToPredicate}; use rustc::util::captures::Captures; use rustc::util::nodemap::FxHashMap; @@ -327,7 +326,7 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> { param_id: ast::NodeId, ty: Ty<'tcx>, only_self_bounds: OnlySelfBounds, - ) -> Vec<(ty::Predicate<'tcx>, Span)> { + ) -> Vec<(Predicate<'tcx>, Span)> { let from_ty_params = ast_generics .params .iter() @@ -673,7 +672,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad } /// Ensures that the super-predicates of the trait with def-id -/// trait_def_id are converted and stored. This also ensures that +/// `trait_def_id` are converted and stored. This also ensures that /// the transitive super-predicates are converted; fn super_predicates_of<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -695,7 +694,7 @@ fn super_predicates_of<'a, 'tcx>( let icx = ItemCtxt::new(tcx, trait_def_id); - // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo : Bar + Zed`. + // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`. let self_param_ty = tcx.mk_self_type(); let superbounds1 = compute_bounds(&icx, self_param_ty, bounds, SizedByDefault::No, item.span); @@ -717,7 +716,7 @@ fn super_predicates_of<'a, 'tcx>( // which will, in turn, reach indirect supertraits. for &(pred, span) in &superbounds { debug!("superbound: {:?}", pred); - if let ty::Predicate::Trait(bound) = pred { + if let Predicate::Trait(bound) = pred { tcx.at(span).super_predicates_of(bound.def_id()); } } @@ -1460,7 +1459,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig let inputs = fields .iter() .map(|f| tcx.type_of(tcx.hir().local_def_id(f.id))); - ty::Binder::bind(tcx.mk_fn_sig( + Binder::bind(tcx.mk_fn_sig( inputs, ty, false, @@ -1661,8 +1660,8 @@ fn explicit_predicates_of<'a, 'tcx>( /// Preserving the order of insertion is important here so as not to break /// compile-fail UI tests. struct UniquePredicates<'tcx> { - predicates: Vec<(ty::Predicate<'tcx>, Span)>, - uniques: FxHashSet<(ty::Predicate<'tcx>, Span)>, + predicates: Vec<(Predicate<'tcx>, Span)>, + uniques: FxHashSet<(Predicate<'tcx>, Span)>, } impl<'tcx> UniquePredicates<'tcx> { @@ -1673,13 +1672,13 @@ fn explicit_predicates_of<'a, 'tcx>( } } - fn push(&mut self, value: (ty::Predicate<'tcx>, Span)) { + fn push(&mut self, value: (Predicate<'tcx>, Span)) { if self.uniques.insert(value) { self.predicates.push(value); } } - fn extend, Span)>>(&mut self, iter: I) { + fn extend, Span)>>(&mut self, iter: I) { for value in iter { self.push(value); } @@ -1827,7 +1826,7 @@ fn explicit_predicates_of<'a, 'tcx>( param.bounds.iter().for_each(|bound| match bound { hir::GenericBound::Outlives(lt) => { let bound = AstConv::ast_region_to_region(&icx, <, None); - let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound)); + let outlives = Binder::bind(ty::OutlivesPredicate(region, bound)); predicates.push((outlives.to_predicate(), lt.span)); } _ => bug!(), @@ -1851,7 +1850,7 @@ fn explicit_predicates_of<'a, 'tcx>( } } - // Add in the bounds that appear in the where-clause + // Add in the bounds that appear in the where-clause. let where_clause = &ast_generics.where_clause; for predicate in &where_clause.predicates { match predicate { @@ -1859,7 +1858,7 @@ fn explicit_predicates_of<'a, 'tcx>( let ty = icx.to_ty(&bound_pred.bounded_ty); // Keep the type around in a dummy predicate, in case of no bounds. - // That way, `where Ty:` is not a complete noop (see #53696) and `Ty` + // That way, `where Ty:` is not a complete no-op (see #53696) and `Ty` // is still checked for WF. if bound_pred.bounds.is_empty() { if let ty::Param(_) = ty.sty { @@ -1873,7 +1872,7 @@ fn explicit_predicates_of<'a, 'tcx>( let span = bound_pred.bounded_ty.span; let predicate = ty::OutlivesPredicate(ty, tcx.mk_region(ty::ReEmpty)); predicates.push( - (ty::Predicate::TypeOutlives(ty::Binder::dummy(predicate)), span) + (Predicate::TypeOutlives(Binder::dummy(predicate)), span) ); } } @@ -1898,8 +1897,8 @@ fn explicit_predicates_of<'a, 'tcx>( &hir::GenericBound::Outlives(ref lifetime) => { let region = AstConv::ast_region_to_region(&icx, lifetime, None); - let pred = ty::Binder::bind(ty::OutlivesPredicate(ty, region)); - predicates.push((ty::Predicate::TypeOutlives(pred), lifetime.span)) + let pred = Binder::bind(ty::OutlivesPredicate(ty, region)); + predicates.push((Predicate::TypeOutlives(pred), lifetime.span)) } } } @@ -1914,9 +1913,9 @@ fn explicit_predicates_of<'a, 'tcx>( } _ => bug!(), }; - let pred = ty::Binder::bind(ty::OutlivesPredicate(r1, r2)); + let pred = Binder::bind(ty::OutlivesPredicate(r1, r2)); - (ty::Predicate::RegionOutlives(pred), span) + (Predicate::RegionOutlives(pred), span) })) } @@ -1953,7 +1952,7 @@ fn explicit_predicates_of<'a, 'tcx>( let mut predicates = predicates.predicates; // Subtle: before we store the predicates into the tcx, we - // sort them so that predicates like `T: Foo` come + // sort them so that predicates like `T: Foo` come // before uses of `U`. This avoids false ambiguity errors // in trait checking. See `setup_constraining_predicates` // for details. @@ -2049,7 +2048,7 @@ fn predicates_from_bound<'tcx>( astconv: &dyn AstConv<'tcx, 'tcx>, param_ty: Ty<'tcx>, bound: &hir::GenericBound, -) -> Vec<(ty::Predicate<'tcx>, Span)> { +) -> Vec<(Predicate<'tcx>, Span)> { match *bound { hir::GenericBound::Trait(ref tr, hir::TraitBoundModifier::None) => { let mut projections = Vec::new(); @@ -2062,8 +2061,8 @@ fn predicates_from_bound<'tcx>( } hir::GenericBound::Outlives(ref lifetime) => { let region = astconv.ast_region_to_region(lifetime, None); - let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region)); - vec![(ty::Predicate::TypeOutlives(pred), lifetime.span)] + let pred = Binder::bind(ty::OutlivesPredicate(param_ty, region)); + vec![(Predicate::TypeOutlives(pred), lifetime.span)] } hir::GenericBound::Trait(_, hir::TraitBoundModifier::Maybe) => vec![], } diff --git a/src/test/run-pass/issues/issue-33140.stderr b/src/test/run-pass/issues/issue-33140.stderr deleted file mode 100644 index 2777ddda93098..0000000000000 --- a/src/test/run-pass/issues/issue-33140.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: duplicate auto trait `std::marker::Sync` found in trait object - --> $DIR/issue-33140.rs:33:21 - | -LL | impl Trait2 for dyn Sync + Send + Sync { - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - | - = note: #[warn(duplicate_auto_traits_in_trait_objects)] on by default - -warning: duplicate auto trait `std::marker::Sync` found in trait object - --> $DIR/issue-33140.rs:54:21 - | -LL | assert_eq!(::uvw(), true); - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - -warning: duplicate auto trait `std::marker::Sync` found in trait object - --> $DIR/issue-33140.rs:33:21 - | -LL | impl Trait2 for dyn Sync + Send + Sync { - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - diff --git a/src/test/run-pass/traits/trait-object-auto-dedup.rs b/src/test/run-pass/traits/trait-object-auto-dedup.rs index 98a386e4c6e1d..39d25eb7fe05b 100644 --- a/src/test/run-pass/traits/trait-object-auto-dedup.rs +++ b/src/test/run-pass/traits/trait-object-auto-dedup.rs @@ -1,14 +1,15 @@ // run-pass + #![allow(unused_assignments)] + // Test that duplicate auto trait bounds in trait objects don't create new types. #[allow(unused_assignments)] - use std::marker::Send as SendAlias; // A dummy trait for the non-auto trait. trait Trait {} -// A dummy struct to implement Trait, Send, and . +// A dummy struct to implement `Trait` and `Send`. struct Struct; impl Trait for Struct {} @@ -23,12 +24,12 @@ impl dyn Trait + Send + Send { } fn main() { - // 1. Moving into a variable with more Sends and back. + // 1. Moving into a variable with more `Send`s and back. let mut dyn_trait_send = Box::new(Struct) as Box; let dyn_trait_send_send: Box = dyn_trait_send; dyn_trait_send = dyn_trait_send_send; - // 2. Calling methods with different number of Sends. + // 2. Calling methods with different number of `Send`s. let dyn_trait_send = Box::new(Struct) as Box; takes_dyn_trait_send_send(dyn_trait_send); diff --git a/src/test/run-pass/traits/trait-object-auto-dedup.stderr b/src/test/run-pass/traits/trait-object-auto-dedup.stderr deleted file mode 100644 index f4f35b4cbb0ee..0000000000000 --- a/src/test/run-pass/traits/trait-object-auto-dedup.stderr +++ /dev/null @@ -1,50 +0,0 @@ -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup.rs:28:49 - | -LL | fn takes_dyn_trait_send_send(_: Box) {} - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - | - = note: #[warn(duplicate_auto_traits_in_trait_objects)] on by default - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup.rs:29:54 - | -LL | fn takes_dyn_trait_send_sendalias(_: Box) {} - | ^^^^ ^^^^^^^^^ subsequent use of auto trait - | | - | first use of auto trait - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup.rs:31:18 - | -LL | impl dyn Trait + Send + Send { - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup.rs:38:46 - | -LL | let dyn_trait_send_send: Box = dyn_trait_send; - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup.rs:45:67 - | -LL | let dyn_trait_send_send = Box::new(Struct) as Box; - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup.rs:28:49 - | -LL | fn takes_dyn_trait_send_send(_: Box) {} - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - diff --git a/src/test/ui/issues/issue-33140.rs b/src/test/ui/issues/issue-33140.rs index 3925562ded90d..1be6422e46df2 100644 --- a/src/test/ui/issues/issue-33140.rs +++ b/src/test/ui/issues/issue-33140.rs @@ -27,14 +27,14 @@ impl Trait2 for dyn Send + Sync { impl Trait2 for dyn Sync + Send + Sync { //~^ ERROR conflicting implementations //~| hard error -//~^^^ WARNING duplicate auto trait `std::marker::Sync` found in trait object [duplicate_auto_traits_in_trait_objects] fn uvw() -> bool { true } } struct Foo(T); impl Foo { - fn abc() -> bool { //~ ERROR duplicate definitions with name `abc` - //~| hard error + fn abc() -> bool { + //~^ ERROR duplicate definitions with name `abc` + //~| hard error false } } diff --git a/src/test/ui/issues/issue-33140.stderr b/src/test/ui/issues/issue-33140.stderr index 05d8c7fb90018..4e61178957977 100644 --- a/src/test/ui/issues/issue-33140.stderr +++ b/src/test/ui/issues/issue-33140.stderr @@ -1,13 +1,3 @@ -warning: duplicate auto trait `std::marker::Sync` found in trait object - --> $DIR/issue-33140.rs:27:21 - | -LL | impl Trait2 for dyn Sync + Send + Sync { - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - | - = note: #[warn(duplicate_auto_traits_in_trait_objects)] on by default - error: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) --> $DIR/issue-33140.rs:13:1 | @@ -38,10 +28,11 @@ LL | impl Trait2 for dyn Sync + Send + Sync { = note: for more information, see issue #56484 error: duplicate definitions with name `abc` (E0592) - --> $DIR/issue-33140.rs:36:5 + --> $DIR/issue-33140.rs:35:5 | -LL | / fn abc() -> bool { //~ ERROR duplicate definitions with name `abc` -LL | | //~| hard error +LL | / fn abc() -> bool { +LL | | //~^ ERROR duplicate definitions with name `abc` +LL | | //~| hard error LL | | false LL | | } | |_____^ duplicate definitions for `abc` diff --git a/src/test/ui/lint/lint-duplicate-traits.rs b/src/test/ui/lint/lint-duplicate-traits.rs deleted file mode 100644 index 5af67ed48e960..0000000000000 --- a/src/test/ui/lint/lint-duplicate-traits.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-pass - -#![feature(trait_alias)] - -trait Foo {} -trait Bar {} -trait Baz {} - -trait SyncAlias = Sync; - -impl Foo for dyn Send {} - -impl Bar for dyn Send + Send {} - -impl Baz for dyn Send + Sync + Send + SyncAlias {} - -fn main() {} diff --git a/src/test/ui/lint/lint-duplicate-traits.stderr b/src/test/ui/lint/lint-duplicate-traits.stderr deleted file mode 100644 index 07fe56f6d5c8f..0000000000000 --- a/src/test/ui/lint/lint-duplicate-traits.stderr +++ /dev/null @@ -1,37 +0,0 @@ -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/lint-duplicate-traits.rs:13:18 - | -LL | impl Bar for dyn Send + Send {} - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - | - = note: #[warn(duplicate_auto_traits_in_trait_objects)] on by default - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/lint-duplicate-traits.rs:15:18 - | -LL | impl Baz for dyn Send + Sync + Send + SyncAlias {} - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - -warning: duplicate auto trait `std::marker::Sync` found in trait object - --> $DIR/lint-duplicate-traits.rs:15:25 - | -LL | trait SyncAlias = Sync; - | ---- subsequent use of auto trait -... -LL | impl Baz for dyn Send + Sync + Send + SyncAlias {} - | ^^^^ ^^^^^^^^^ - | | - | first use of auto trait - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/lint-duplicate-traits.rs:13:18 - | -LL | impl Bar for dyn Send + Send {} - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - diff --git a/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs b/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs index 621cb6149ea89..0d18965ee7338 100644 --- a/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs +++ b/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs @@ -7,7 +7,6 @@ impl Foo for dyn Send {} impl Foo for dyn Send + Send {} //~^ ERROR conflicting implementations //~| hard error -//~^^^ WARNING duplicate auto trait `std::marker::Send` found in trait object [duplicate_auto_traits_in_trait_objects] impl Foo for dyn Send + Sync {} @@ -18,6 +17,5 @@ impl Foo for dyn Sync + Send {} impl Foo for dyn Send + Sync + Send {} //~^ ERROR conflicting implementations //~| hard error -//~^^^ WARNING duplicate auto trait `std::marker::Send` found in trait object [duplicate_auto_traits_in_trait_objects] fn main() {} diff --git a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr index 686987dd3ad12..3703552b9ccee 100644 --- a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr +++ b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr @@ -1,21 +1,3 @@ -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/lint-incoherent-auto-trait-objects.rs:7:18 - | -LL | impl Foo for dyn Send + Send {} - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - | - = note: #[warn(duplicate_auto_traits_in_trait_objects)] on by default - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/lint-incoherent-auto-trait-objects.rs:18:18 - | -LL | impl Foo for dyn Send + Sync + Send {} - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + 'static)`: (E0119) --> $DIR/lint-incoherent-auto-trait-objects.rs:7:1 | @@ -30,7 +12,7 @@ LL | impl Foo for dyn Send + Send {} = note: for more information, see issue #56484 error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) - --> $DIR/lint-incoherent-auto-trait-objects.rs:14:1 + --> $DIR/lint-incoherent-auto-trait-objects.rs:13:1 | LL | impl Foo for dyn Send + Sync {} | ---------------------------- first implementation here @@ -42,7 +24,7 @@ LL | impl Foo for dyn Sync + Send {} = note: for more information, see issue #56484 error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Sync + std::marker::Send + 'static)`: (E0119) - --> $DIR/lint-incoherent-auto-trait-objects.rs:18:1 + --> $DIR/lint-incoherent-auto-trait-objects.rs:17:1 | LL | impl Foo for dyn Sync + Send {} | ---------------------------- first implementation here diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs b/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs index 5ac53b190ed9c..2b888cea4bb89 100644 --- a/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs +++ b/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs @@ -1,7 +1,5 @@ -// ignore-tidy-linelength - // Checks to make sure that `dyn Trait + Send` and `dyn Trait + Send + Send` are the same type. -// Issue: #47010 +// See issue #47010. struct Struct; @@ -11,15 +9,18 @@ trait Trait {} type Send1 = Trait + Send; type Send2 = Trait + Send + Send; -//~^ WARNING duplicate auto trait `std::marker::Send` found in trait object [duplicate_auto_traits_in_trait_objects] fn main () {} impl Trait + Send { - fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test` + fn test(&self) { + //~^ ERROR duplicate definitions with name `test` + println!("one"); + } } impl Trait + Send + Send { -//~^ WARNING duplicate auto trait `std::marker::Send` found in trait object [duplicate_auto_traits_in_trait_objects] - fn test(&self) { println!("two"); } + fn test(&self) { + println!("two"); + } } diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr b/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr index 13a8431bf981e..4520e02aa7217 100644 --- a/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr +++ b/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr @@ -1,29 +1,16 @@ -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup-in-impl.rs:13:22 - | -LL | type Send2 = Trait + Send + Send; - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - | - = note: #[warn(duplicate_auto_traits_in_trait_objects)] on by default - -warning: duplicate auto trait `std::marker::Send` found in trait object - --> $DIR/trait-object-auto-dedup-in-impl.rs:22:14 - | -LL | impl Trait + Send + Send { - | ^^^^ ^^^^ subsequent use of auto trait - | | - | first use of auto trait - error[E0592]: duplicate definitions with name `test` - --> $DIR/trait-object-auto-dedup-in-impl.rs:19:5 + --> $DIR/trait-object-auto-dedup-in-impl.rs:16:5 | -LL | fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `test` +LL | / fn test(&self) { +LL | | //~^ ERROR duplicate definitions with name `test` +LL | | println!("one"); +LL | | } + | |_____^ duplicate definitions for `test` ... -LL | fn test(&self) { println!("two"); } - | ----------------------------------- other definition for `test` +LL | / fn test(&self) { +LL | | println!("two"); +LL | | } + | |_____- other definition for `test` error: aborting due to previous error diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs index fa2daeb11e916..f02e5973b569c 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs @@ -1,5 +1,6 @@ // run-pass -// Check that global bounds result in the expected choice of associated type + +// Check that global bounds result in the expected choice of associated type. #![feature(trivial_bounds)] #![allow(unused)] diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr index 561614dc52892..4d91700113a14 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr @@ -1,5 +1,5 @@ warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:21:8 + --> $DIR/trivial-bounds-inconsistent-projection.rs:22:8 | LL | B: A | ^ @@ -7,37 +7,37 @@ LL | B: A = note: #[warn(trivial_bounds)] on by default warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:28:8 + --> $DIR/trivial-bounds-inconsistent-projection.rs:29:8 | LL | B: A | ^^^^^^^^^^ warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:35:8 + --> $DIR/trivial-bounds-inconsistent-projection.rs:36:8 | LL | B: A | ^^^^^^^^^ warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:42:8 + --> $DIR/trivial-bounds-inconsistent-projection.rs:43:8 | LL | B: A + A | ^^^^^^^^^^ warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:42:21 + --> $DIR/trivial-bounds-inconsistent-projection.rs:43:21 | LL | B: A + A | ^ warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:49:8 + --> $DIR/trivial-bounds-inconsistent-projection.rs:50:8 | LL | B: A + A | ^^^^^^^^^ warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:49:20 + --> $DIR/trivial-bounds-inconsistent-projection.rs:50:20 | LL | B: A + A | ^ diff --git a/src/test/ui/type/type-alias-bounds.rs b/src/test/ui/type/type-alias-bounds.rs index e2be2b9890251..6f77e1ff2b533 100644 --- a/src/test/ui/type/type-alias-bounds.rs +++ b/src/test/ui/type/type-alias-bounds.rs @@ -1,44 +1,46 @@ -// Test ignored_generic_bounds lint warning about bounds in type aliases +// Test `ignored_generic_bounds` lint warning about bounds in type aliases. // compile-pass +// ignore-tidy-linelength + #![allow(dead_code)] use std::rc::Rc; -type SVec = Vec; +type SVec = Vec; //~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] type S2Vec where T: Send = Vec; //~^ WARN where clauses are not enforced in type aliases [type_alias_bounds] -type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); +type VVec<'b, 'a: 'b + 'b> = (&'b u32, Vec<&'a i32>); //~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] -type WVec<'b, T: 'b+'b> = (&'b u32, Vec); +type WVec<'b, T: 'b + 'b> = (&'b u32, Vec); //~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); //~^ WARN where clauses are not enforced in type aliases [type_alias_bounds] -static STATIC : u32 = 0; +static STATIC: u32 = 0; fn foo<'a>(y: &'a i32) { // If any of the bounds above would matter, the code below would be rejected. // This can be seen when replacing the type aliases above by newtype structs. // (The type aliases have no unused parameters to make that a valid transformation.) - let mut x : SVec<_> = Vec::new(); + let mut x: SVec<_> = Vec::new(); x.push(Rc::new(42)); // is not send - let mut x : S2Vec<_> = Vec::new(); - x.push(Rc::new(42)); // is not send + let mut x: S2Vec<_> = Vec::new(); + x.push(Rc::new(42)); // is not `Send` - let mut x : VVec<'static, 'a> = (&STATIC, Vec::new()); - x.1.push(y); // 'a: 'static does not hold + let mut x: VVec<'static, 'a> = (&STATIC, Vec::new()); + x.1.push(y); // `'a: 'static` does not hold - let mut x : WVec<'static, &'a i32> = (&STATIC, Vec::new()); - x.1.push(y); // &'a i32: 'static does not hold + let mut x: WVec<'static, &'a i32> = (&STATIC, Vec::new()); + x.1.push(y); // `&'a i32: 'static` does not hold - let mut x : W2Vec<'static, &'a i32> = (&STATIC, Vec::new()); - x.1.push(y); // &'a i32: 'static does not hold + let mut x: W2Vec<'static, &'a i32> = (&STATIC, Vec::new()); + x.1.push(y); // `&'a i32: 'static` does not hold } -// Bounds are not checked either, i.e., the definition is not necessarily well-formed +// Bounds are not checked either, i.e., the definition is not necessarily well-formed. struct Sendable(T); type MySendable = Sendable; // no error here! @@ -47,9 +49,9 @@ trait Bound { type Assoc; } type T1 = U::Assoc; //~ WARN not enforced in type aliases type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases -// This errors -// type T3 = U::Assoc; -// Do this instead +// This errors: +// `type T3 = U::Assoc;` +// Do this instead: type T4 = ::Assoc; // Make sure the help about associatd types is not shown incorrectly diff --git a/src/test/ui/type/type-alias-bounds.stderr b/src/test/ui/type/type-alias-bounds.stderr index b13e400105210..365aae1abb2c7 100644 --- a/src/test/ui/type/type-alias-bounds.stderr +++ b/src/test/ui/type/type-alias-bounds.stderr @@ -1,14 +1,14 @@ warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:8:14 + --> $DIR/type-alias-bounds.rs:10:14 | -LL | type SVec = Vec; - | ^^^^ ^^^^ +LL | type SVec = Vec; + | ^^^^ ^^^^ | = note: #[warn(type_alias_bounds)] on by default = help: the bound will not be checked when the type alias is used, and should be removed warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:10:21 + --> $DIR/type-alias-bounds.rs:12:21 | LL | type S2Vec where T: Send = Vec; | ^^^^^^^ @@ -16,23 +16,23 @@ LL | type S2Vec where T: Send = Vec; = help: the clause will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:12:19 + --> $DIR/type-alias-bounds.rs:14:19 | -LL | type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); - | ^^ ^^ +LL | type VVec<'b, 'a: 'b + 'b> = (&'b u32, Vec<&'a i32>); + | ^^ ^^ | = help: the bound will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:14:18 + --> $DIR/type-alias-bounds.rs:16:18 | -LL | type WVec<'b, T: 'b+'b> = (&'b u32, Vec); - | ^^ ^^ +LL | type WVec<'b, T: 'b + 'b> = (&'b u32, Vec); + | ^^ ^^ | = help: the bound will not be checked when the type alias is used, and should be removed warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:16:25 + --> $DIR/type-alias-bounds.rs:18:25 | LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); | ^^^^^ ^^^^^ @@ -40,33 +40,33 @@ LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); = help: the clause will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:47:12 + --> $DIR/type-alias-bounds.rs:49:12 | LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^ | = help: the bound will not be checked when the type alias is used, and should be removed help: use fully disambiguated paths (i.e., `::Assoc`) to refer to associated types in type aliases - --> $DIR/type-alias-bounds.rs:47:21 + --> $DIR/type-alias-bounds.rs:49:21 | LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^^^^ warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:48:18 + --> $DIR/type-alias-bounds.rs:50:18 | LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^^^^ | = help: the clause will not be checked when the type alias is used, and should be removed help: use fully disambiguated paths (i.e., `::Assoc`) to refer to associated types in type aliases - --> $DIR/type-alias-bounds.rs:48:29 + --> $DIR/type-alias-bounds.rs:50:29 | LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^^^^ warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:56:12 + --> $DIR/type-alias-bounds.rs:58:12 | LL | type T5 = ::Assoc; //~ WARN not enforced in type aliases | ^^^^^ @@ -74,7 +74,7 @@ LL | type T5 = ::Assoc; //~ WARN not enforced in type ali = help: the bound will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:57:12 + --> $DIR/type-alias-bounds.rs:59:12 | LL | type T6 = ::std::vec::Vec; //~ WARN not enforced in type aliases | ^^^^^ diff --git a/src/test/ui/type/type-check-defaults.rs b/src/test/ui/type/type-check-defaults.rs index 5748c9bcff8cb..ec3975c53967c 100644 --- a/src/test/ui/type/type-check-defaults.rs +++ b/src/test/ui/type/type-check-defaults.rs @@ -8,20 +8,20 @@ struct WellFormed>(Z); struct WellFormedNoBounds>(Z); //~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32` -struct Bounds(T); +struct Bounds(T); //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] -struct WhereClause(T) where T: Copy; +struct WhereClause(T) where T: Copy; //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] -trait TraitBound {} +trait TraitBound {} //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] trait Super { } trait Base: Super { } //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied [E0277] -trait ProjectionPred> where T::Item : Add {} +trait ProjectionPred> where T::Item: Add {} //~^ ERROR cannot add `u8` to `i32` [E0277] fn main() { } diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index a46d79ec3183e..1792391ad8f1e 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -27,38 +27,38 @@ LL | struct Foo>(T, U); error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:11:1 | -LL | struct Bounds(T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` +LL | struct Bounds(T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | note: required by `Bounds` --> $DIR/type-check-defaults.rs:11:1 | -LL | struct Bounds(T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct Bounds(T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:14:1 | -LL | struct WhereClause(T) where T: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` +LL | struct WhereClause(T) where T: Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | note: required by `WhereClause` --> $DIR/type-check-defaults.rs:14:1 | -LL | struct WhereClause(T) where T: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct WhereClause(T) where T: Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:17:1 | -LL | trait TraitBound {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` +LL | trait TraitBound {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | note: required by `TraitBound` --> $DIR/type-check-defaults.rs:17:1 | -LL | trait TraitBound {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait TraitBound {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:21:1 @@ -76,15 +76,15 @@ LL | trait Super { } error[E0277]: cannot add `u8` to `i32` --> $DIR/type-check-defaults.rs:24:1 | -LL | trait ProjectionPred> where T::Item : Add {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u8` +LL | trait ProjectionPred> where T::Item: Add {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u8` | = help: the trait `std::ops::Add` is not implemented for `i32` note: required by `ProjectionPred` --> $DIR/type-check-defaults.rs:24:1 | -LL | trait ProjectionPred> where T::Item : Add {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait ProjectionPred> where T::Item: Add {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors