Skip to content

Commit 9754b06

Browse files
committed
rustc: Remove support for old_impl_check
This commit removes compiler support for the `old_impl_check` attribute which should in theory be entirely removed now. The last remaining use of it in the standard library has been updated by moving the type parameter on the `old_io::Acceptor` trait into an associated type. As a result, this is a breaking change for all current users of the deprecated `old_io::Acceptor` trait. Code can be migrated by using the `Connection` associated type instead. [breaking-change]
1 parent 557d434 commit 9754b06

File tree

7 files changed

+23
-40
lines changed

7 files changed

+23
-40
lines changed

src/librustc_typeck/collect.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -2208,18 +2208,10 @@ fn enforce_impl_ty_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
22082208
idx: index as u32,
22092209
name: ty_param.ident.name };
22102210
if !input_parameters.contains(&param_ty) {
2211-
if ty::has_attr(tcx, impl_def_id, "old_impl_check") {
2212-
tcx.sess.span_warn(
2213-
ty_param.span,
2214-
&format!("the type parameter `{}` is not constrained by the \
2215-
impl trait, self type, or predicates",
2216-
param_ty.user_string(tcx)));
2217-
} else {
2218-
span_err!(tcx.sess, ty_param.span, E0207,
2219-
"the type parameter `{}` is not constrained by the \
2220-
impl trait, self type, or predicates",
2221-
param_ty.user_string(tcx));
2222-
}
2211+
span_err!(tcx.sess, ty_param.span, E0207,
2212+
"the type parameter `{}` is not constrained by the \
2213+
impl trait, self type, or predicates",
2214+
param_ty.user_string(tcx));
22232215
}
22242216
}
22252217
}

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
#![feature(lang_items)]
115115
#![feature(libc)]
116116
#![feature(linkage, thread_local, asm)]
117-
#![feature(old_impl_check)]
118117
#![feature(optin_builtin_traits)]
119118
#![feature(rand)]
120119
#![feature(staged_api)]

src/libstd/old_io/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1588,9 +1588,7 @@ pub trait Seek {
15881588
/// connections.
15891589
///
15901590
/// Doing so produces some sort of Acceptor.
1591-
pub trait Listener<T, A: Acceptor<T>>
1592-
: PhantomFn<T,T> // FIXME should be an assoc type anyhow
1593-
{
1591+
pub trait Listener<A: Acceptor> {
15941592
/// Spin up the listener and start queuing incoming connections
15951593
///
15961594
/// # Error
@@ -1601,13 +1599,16 @@ pub trait Listener<T, A: Acceptor<T>>
16011599
}
16021600

16031601
/// An acceptor is a value that presents incoming connections
1604-
pub trait Acceptor<T> {
1602+
pub trait Acceptor {
1603+
/// Type of connection that is accepted by this acceptor.
1604+
type Connection;
1605+
16051606
/// Wait for and accept an incoming connection
16061607
///
16071608
/// # Error
16081609
///
16091610
/// Returns `Err` if an I/O error is encountered.
1610-
fn accept(&mut self) -> IoResult<T>;
1611+
fn accept(&mut self) -> IoResult<Self::Connection>;
16111612

16121613
/// Create an iterator over incoming connection attempts.
16131614
///
@@ -1628,11 +1629,10 @@ pub struct IncomingConnections<'a, A: ?Sized +'a> {
16281629
inc: &'a mut A,
16291630
}
16301631

1631-
#[old_impl_check]
1632-
impl<'a, T, A: ?Sized + Acceptor<T>> Iterator for IncomingConnections<'a, A> {
1633-
type Item = IoResult<T>;
1632+
impl<'a, A: ?Sized + Acceptor> Iterator for IncomingConnections<'a, A> {
1633+
type Item = IoResult<A::Connection>;
16341634

1635-
fn next(&mut self) -> Option<IoResult<T>> {
1635+
fn next(&mut self) -> Option<IoResult<A::Connection>> {
16361636
Some(self.inc.accept())
16371637
}
16381638
}

src/libstd/old_io/net/pipe.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl UnixListener {
202202
}
203203
}
204204

205-
impl Listener<UnixStream, UnixAcceptor> for UnixListener {
205+
impl Listener<UnixAcceptor> for UnixListener {
206206
fn listen(self) -> IoResult<UnixAcceptor> {
207207
self.inner.listen()
208208
.map(|inner| UnixAcceptor { inner: inner })
@@ -250,7 +250,8 @@ impl UnixAcceptor {
250250
}
251251
}
252252

253-
impl Acceptor<UnixStream> for UnixAcceptor {
253+
impl Acceptor for UnixAcceptor {
254+
type Connection = UnixStream;
254255
fn accept(&mut self) -> IoResult<UnixStream> {
255256
self.inner.accept().map(|s| {
256257
UnixStream { inner: s }

src/libstd/old_io/net/tcp.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl TcpListener {
338338
}
339339
}
340340

341-
impl Listener<TcpStream, TcpAcceptor> for TcpListener {
341+
impl Listener<TcpAcceptor> for TcpListener {
342342
fn listen(self) -> IoResult<TcpAcceptor> {
343343
self.inner.listen(128).map(|a| TcpAcceptor { inner: a })
344344
}
@@ -453,7 +453,8 @@ impl TcpAcceptor {
453453
}
454454
}
455455

456-
impl Acceptor<TcpStream> for TcpAcceptor {
456+
impl Acceptor for TcpAcceptor {
457+
type Connection = TcpStream;
457458
fn accept(&mut self) -> IoResult<TcpStream> {
458459
self.inner.accept().map(TcpStream::new)
459460
}

src/libstd/old_io/result.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<S: Seek> Seek for IoResult<S> {
5858
}
5959
}
6060

61-
impl<T, A: Acceptor<T>, L: Listener<T, A>> Listener<T, A> for IoResult<L> {
61+
impl<A: Acceptor, L: Listener<A>> Listener<A> for IoResult<L> {
6262
fn listen(self) -> IoResult<A> {
6363
match self {
6464
Ok(listener) => listener.listen(),
@@ -67,8 +67,9 @@ impl<T, A: Acceptor<T>, L: Listener<T, A>> Listener<T, A> for IoResult<L> {
6767
}
6868
}
6969

70-
impl<T, A: Acceptor<T>> Acceptor<T> for IoResult<A> {
71-
fn accept(&mut self) -> IoResult<T> {
70+
impl<A: Acceptor> Acceptor for IoResult<A> {
71+
type Connection = A::Connection;
72+
fn accept(&mut self) -> IoResult<A::Connection> {
7273
match *self {
7374
Ok(ref mut acceptor) => acceptor.accept(),
7475
Err(ref e) => Err(e.clone()),

src/libsyntax/feature_gate.rs

-11
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
102102
// A way to temporarily opt out of the new orphan rules. This will *never* be accepted.
103103
("old_orphan_check", "1.0.0", Deprecated),
104104

105-
// A way to temporarily opt out of the new impl rules. This will *never* be accepted.
106-
("old_impl_check", "1.0.0", Deprecated),
107-
108105
// OIBIT specific features
109106
("optin_builtin_traits", "1.0.0", Active),
110107

@@ -280,7 +277,6 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
280277

281278
// FIXME: #19470 this shouldn't be needed forever
282279
("old_orphan_check", Whitelisted),
283-
("old_impl_check", Whitelisted),
284280
("rustc_paren_sugar", Whitelisted), // FIXME: #18101 temporary unboxed closure hack
285281

286282
// Crate level attributes
@@ -595,13 +591,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
595591
i.span,
596592
"the new orphan check rules will eventually be strictly enforced");
597593
}
598-
599-
if attr::contains_name(&i.attrs[..],
600-
"old_impl_check") {
601-
self.gate_feature("old_impl_check",
602-
i.span,
603-
"`#[old_impl_check]` will be removed in the future");
604-
}
605594
}
606595

607596
_ => {}

0 commit comments

Comments
 (0)