diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index b0cabc6275f5a..5fdadd0b4b41b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2263,13 +2263,22 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { trait_impls.non_blanket_impls().len() ) }; - + let mut suggestions = vec![( + trait_path_segment.ident.span.shrink_to_lo(), + format!("<{} as ", self.tcx.def_path(impl_def_id).to_string_no_crate_verbose()) + )]; + if let Some(generic_arg) = trait_path_segment.args { + let between_span = trait_path_segment.ident.span.between(generic_arg.span_ext); + // get rid of :: between Trait and + // must be '::' between them, otherwise the parser won't accept the code + suggestions.push((between_span, "".to_string(),)); + suggestions.push((generic_arg.span_ext.shrink_to_hi(), format!(">"))); + } else { + suggestions.push((trait_path_segment.ident.span.shrink_to_hi(), format!(">"))); + } err.multipart_suggestion( message, - vec![ - (trait_path_segment.ident.span.shrink_to_lo(), format!("<{} as ", self.tcx.def_path(impl_def_id).to_string_no_crate_verbose())), - (trait_path_segment.ident.span.shrink_to_hi(), format!(">")) - ], + suggestions, Applicability::MaybeIncorrect ); } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index fff26547be075..698fc81c58775 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1425,7 +1425,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let mut spans_and_needs_box = vec![]; match liberated_sig.output().kind() { - ty::Dynamic(predicates, _, _) => { + ty::Dynamic(predicates, _, ty::Dyn) => { let cause = ObligationCause::misc(ret_ty.span, fn_hir_id); let param_env = ty::ParamEnv::empty(); diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index eb5271aaf7e38..9e991cc03a0c8 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1245,13 +1245,11 @@ h3.variant { font-weight: 600; font-size: 1.125rem; margin-bottom: 10px; - border-bottom: none; } .sub-variant h4 { font-size: 1rem; font-weight: 400; - border-bottom: none; margin-top: 0; margin-bottom: 0; } diff --git a/src/test/ui/stats/hir-stats.rs b/src/test/ui/stats/hir-stats.rs index 5102574d4be3e..a24b3ada57e59 100644 --- a/src/test/ui/stats/hir-stats.rs +++ b/src/test/ui/stats/hir-stats.rs @@ -1,7 +1,6 @@ // check-pass // compile-flags: -Zhir-stats // only-x86_64 -// ignore-stage1 // The aim here is to include at least one of every different type of top-level // AST/HIR node reported by `-Zhir-stats`. diff --git a/src/test/ui/type/issue-101866.rs b/src/test/ui/type/issue-101866.rs new file mode 100644 index 0000000000000..d332c4adb0060 --- /dev/null +++ b/src/test/ui/type/issue-101866.rs @@ -0,0 +1,15 @@ +trait TraitA { + fn func(); +} + +struct StructA {} + +impl TraitA for StructA { + fn func() {} +} + +fn main() { + TraitA::::func(); + //~^ ERROR: cannot call associated function on trait without specifying the corresponding `impl` type [E0790] + //~| help: use the fully-qualified path to the only available implementation +} diff --git a/src/test/ui/type/issue-101866.stderr b/src/test/ui/type/issue-101866.stderr new file mode 100644 index 0000000000000..788e54b938190 --- /dev/null +++ b/src/test/ui/type/issue-101866.stderr @@ -0,0 +1,18 @@ +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/issue-101866.rs:12:5 + | +LL | fn func(); + | ---------- `TraitA::func` defined here +... +LL | TraitA::::func(); + | ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use the fully-qualified path to the only available implementation + | +LL - TraitA::::func(); +LL + <::StructA as TraitA>::func(); + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0790`.