Rollup merge of #91002 - petrochenkov:nosynth, r=davidtwco

rustc: Remove `#[rustc_synthetic]`

This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.

Noticed while reviewing https://github.com/rust-lang/rust/pull/90947.
This commit is contained in:
Yuki Okushi 2021-11-19 02:22:59 +09:00 committed by GitHub
commit 08c1639fd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 37 additions and 163 deletions

View file

@ -459,9 +459,7 @@ impl Clean<Generics> for hir::Generics<'_> {
// scans them first.
fn is_impl_trait(param: &hir::GenericParam<'_>) -> bool {
match param.kind {
hir::GenericParamKind::Type { synthetic, .. } => {
synthetic == Some(hir::SyntheticTyParamKind::ImplTrait)
}
hir::GenericParamKind::Type { synthetic, .. } => synthetic,
_ => false,
}
}
@ -560,7 +558,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
assert_eq!(param.index, 0);
return None;
}
if synthetic == Some(hir::SyntheticTyParamKind::ImplTrait) {
if synthetic {
impl_trait.insert(param.index.into(), vec![]);
return None;
}

View file

@ -1238,20 +1238,9 @@ impl WherePredicate {
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
crate enum GenericParamDefKind {
Lifetime {
outlives: Vec<Lifetime>,
},
Type {
did: DefId,
bounds: Vec<GenericBound>,
default: Option<Box<Type>>,
synthetic: Option<hir::SyntheticTyParamKind>,
},
Const {
did: DefId,
ty: Box<Type>,
default: Option<Box<String>>,
},
Lifetime { outlives: Vec<Lifetime> },
Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
Const { did: DefId, ty: Box<Type>, default: Option<Box<String>> },
}
impl GenericParamDefKind {
@ -1285,7 +1274,7 @@ impl GenericParamDef {
crate fn is_synthetic_type_param(&self) -> bool {
match self.kind {
GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => false,
GenericParamDefKind::Type { ref synthetic, .. } => synthetic.is_some(),
GenericParamDefKind::Type { synthetic, .. } => synthetic,
}
}

View file

@ -1,28 +0,0 @@
#![feature(rustc_attrs)]
fn func<#[rustc_synthetic] T>(_: T) {}
struct Foo;
impl Foo {
pub fn func<#[rustc_synthetic] T>(_: T) {}
}
struct Bar<S> {
t: S
}
impl<S> Bar<S> {
pub fn func<#[rustc_synthetic] T>(_: T) {}
}
fn main() {
func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
func(42); // Ok
Foo::func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
Foo::func(42); // Ok
Bar::<i8>::func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
Bar::<i8>::func(42); // Ok
}

View file

@ -1,30 +0,0 @@
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/synthetic-param.rs:20:12
|
LL | func::<u8>(42);
| ^^ explicit generic argument not allowed
|
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
= help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/synthetic-param.rs:23:17
|
LL | Foo::func::<u8>(42);
| ^^ explicit generic argument not allowed
|
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
= help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/synthetic-param.rs:26:23
|
LL | Bar::<i8>::func::<u8>(42);
| ^^ explicit generic argument not allowed
|
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
= help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0632`.

View file

@ -3,10 +3,8 @@ use clippy_utils::source::snippet;
use clippy_utils::{match_def_path, paths};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{
self as hir, GenericArg, GenericBounds, GenericParamKind, HirId, Lifetime, MutTy, Mutability, Node, QPath,
SyntheticTyParamKind, TyKind,
};
use rustc_hir::{self as hir, GenericArg, GenericBounds, GenericParamKind};
use rustc_hir::{HirId, Lifetime, MutTy, Mutability, Node, QPath, TyKind};
use rustc_lint::LateContext;
use super::BORROWED_BOX;
@ -105,7 +103,7 @@ fn get_bounds_if_impl_trait<'tcx>(cx: &LateContext<'tcx>, qpath: &QPath<'_>, id:
if let Some(did) = cx.qpath_res(qpath, id).opt_def_id();
if let Some(Node::GenericParam(generic_param)) = cx.tcx.hir().get_if_local(did);
if let GenericParamKind::Type { synthetic, .. } = generic_param.kind;
if synthetic == Some(SyntheticTyParamKind::ImplTrait);
if synthetic;
then {
Some(generic_param.bounds)
} else {