Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #73923

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
46bfc48
Added proper explanation of ErrorCode-E0687
Polkaverse May 10, 2020
1d0378c
impl From<char> for String
matthiaskrgr Jun 17, 2020
2cde493
add test for char into string
matthiaskrgr Jun 18, 2020
224bc05
Fix allow_internal_unstable with rustc_const_unstable
nbdd0121 Jun 26, 2020
fc239e8
Make `likely` and `unlikely` const
nbdd0121 Jun 26, 2020
779b05d
Fix ICE for lib features
nbdd0121 Jun 26, 2020
8b43012
Update src/librustc_mir/interpret/intrinsics.rs
nbdd0121 Jun 27, 2020
7231e57
Fix wording for anonymous parameter name help
nop Jun 28, 2020
bb82e76
Advertise correct stable version for const control flow
ecstatic-morse Jun 29, 2020
1d7ba5f
stop taking references in Relate
lcnr Jun 24, 2020
71b45b9
change `skip_binder` to use T by value
lcnr Jun 24, 2020
f632bd1
remove unused `TypeError::ProjectionBoundsLength`
lcnr Jun 24, 2020
69e4990
update `equal_up_to_regions`
lcnr Jun 30, 2020
f74a7d3
Clean up E0712 explanation
GuillaumeGomez Jun 30, 2020
0889d79
remove duplicate tests
lcnr Jun 30, 2020
0d26512
Add missing backtick in `ty_error_with_message`
JohnTitor Jul 1, 2020
7616cd9
`#[deny(unsafe_op_in_unsafe_fn)]` in libstd/fs.rs
eltonlaw Jul 1, 2020
b438811
enable unsafe_op_in_unsafe_fn lint
eltonlaw Jul 1, 2020
ce57e7e
Rollup merge of #72071 - PankajChaudhary5:ErrorCode-E0687, r=davidtwco
Dylan-DPC Jul 1, 2020
14ecee5
Rollup merge of #73466 - matthiaskrgr:char_into_string, r=dtolnay
Dylan-DPC Jul 1, 2020
51a0cfd
Rollup merge of #73705 - lcnr:skip_binder, r=nikomatsakis
Dylan-DPC Jul 1, 2020
ea718a6
Rollup merge of #73778 - nbdd0121:const_likely, r=oli-obk
Dylan-DPC Jul 1, 2020
e8decdc
Rollup merge of #73828 - nop:fix/parameter-name-help, r=estebank
Dylan-DPC Jul 1, 2020
16ed9a9
Rollup merge of #73868 - ecstatic-morse:fix-stable-version, r=jonas-s…
Dylan-DPC Jul 1, 2020
30d0db9
Rollup merge of #73892 - GuillaumeGomez:cleanup-e0712, r=Dylan-DPC
Dylan-DPC Jul 1, 2020
32e74ae
Rollup merge of #73898 - lcnr:issue61383, r=jonas-schievink
Dylan-DPC Jul 1, 2020
9d37005
Rollup merge of #73906 - JohnTitor:missing-bt, r=jonas-schievink
Dylan-DPC Jul 1, 2020
b37816d
Rollup merge of #73909 - eltonlaw:unsafe-libstd-fs-rs, r=sfackler
Dylan-DPC Jul 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2518,3 +2518,11 @@ impl DoubleEndedIterator for Drain<'_> {

#[stable(feature = "fused", since = "1.26.0")]
impl FusedIterator for Drain<'_> {}

#[stable(feature = "from_char_for_string", since = "1.46.0")]
impl From<char> for String {
#[inline]
fn from(c: char) -> Self {
c.to_string()
}
}
7 changes: 7 additions & 0 deletions src/liballoc/tests/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,10 @@ fn test_try_reserve_exact() {
}
}
}

#[test]
fn test_from_char() {
assert_eq!(String::from('a'), 'a'.to_string());
let s: String = 'x'.into();
assert_eq!(s, 'x'.to_string());
}
2 changes: 2 additions & 0 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ extern "rust-intrinsic" {
/// Any use other than with `if` statements will probably not have an effect.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
pub fn likely(b: bool) -> bool;

/// Hints to the compiler that branch condition is likely to be false.
Expand All @@ -960,6 +961,7 @@ extern "rust-intrinsic" {
/// Any use other than with `if` statements will probably not have an effect.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
pub fn unlikely(b: bool) -> bool;

/// Executes a breakpoint trap, for inspection by a debugger.
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#![feature(const_slice_from_raw_parts)]
#![feature(const_slice_ptr_len)]
#![feature(const_type_name)]
#![feature(const_likely)]
#![feature(custom_inner_attributes)]
#![feature(decl_macro)]
#![feature(doc_cfg)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ E0668: include_str!("./error_codes/E0668.md"),
E0669: include_str!("./error_codes/E0669.md"),
E0670: include_str!("./error_codes/E0670.md"),
E0671: include_str!("./error_codes/E0671.md"),
E0687: include_str!("./error_codes/E0687.md"),
E0689: include_str!("./error_codes/E0689.md"),
E0690: include_str!("./error_codes/E0690.md"),
E0691: include_str!("./error_codes/E0691.md"),
Expand Down Expand Up @@ -613,7 +614,6 @@ E0766: include_str!("./error_codes/E0766.md"),
E0640, // infer outlives requirements
// E0645, // trait aliases not finished
E0667, // `impl Trait` in projections
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
// E0694, // an unknown tool name found in scoped attributes
// E0702, // replaced with a generic attribute input check
Expand Down
36 changes: 36 additions & 0 deletions src/librustc_error_codes/error_codes/E0687.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
In-band lifetimes cannot be used in `fn`/`Fn` syntax.

Erroneous code examples:

```compile_fail,E0687
#![feature(in_band_lifetimes)]

fn foo(x: fn(&'a u32)) {} // error!

fn bar(x: &Fn(&'a u32)) {} // error!

fn baz(x: fn(&'a u32), y: &'a u32) {} // error!

struct Foo<'a> { x: &'a u32 }

impl Foo<'a> {
fn bar(&self, x: fn(&'a u32)) {} // error!
}
```

Lifetimes used in `fn` or `Fn` syntax must be explicitly
declared using `<...>` binders. For example:

```
fn foo<'a>(x: fn(&'a u32)) {} // ok!

fn bar<'a>(x: &Fn(&'a u32)) {} // ok!

fn baz<'a>(x: fn(&'a u32), y: &'a u32) {} // ok!

struct Foo<'a> { x: &'a u32 }

impl<'a> Foo<'a> {
fn bar(&self, x: fn(&'a u32)) {} // ok!
}
```
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0712.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This error occurs because a borrow of a thread-local variable was made inside a
function which outlived the lifetime of the function.
A borrow of a thread-local variable was made inside a function which outlived
the lifetime of the function.

Erroneous code example:

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_feature/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ declare_features! (
/// Allows using subslice patterns, `[a, .., b]` and `[a, xs @ .., b]`.
(accepted, slice_patterns, "1.42.0", Some(62254), None),
/// Allows the use of `if` and `match` in constants.
(accepted, const_if_match, "1.45.0", Some(49146), None),
(accepted, const_if_match, "1.46.0", Some(49146), None),
/// Allows the use of `loop` and `while` in constants.
(accepted, const_loop, "1.45.0", Some(52000), None),
(accepted, const_loop, "1.46.0", Some(52000), None),

// -------------------------------------------------------------------------
// feature-group-end: accepted features
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_infer/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace_exp(a_is_expected, a, b).sub(&a, &b)
self.trace_exp(a_is_expected, a, b).sub(a, b)
}

/// Makes `actual <: expected`. For example, if type-checking a
Expand All @@ -109,15 +109,15 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace_exp(a_is_expected, a, b).eq(&a, &b)
self.trace_exp(a_is_expected, a, b).eq(a, b)
}

/// Makes `expected <: actual`.
pub fn eq<T>(self, expected: T, actual: T) -> InferResult<'tcx, ()>
where
T: ToTrace<'tcx>,
{
self.trace(expected, actual).eq(&expected, &actual)
self.trace(expected, actual).eq(expected, actual)
}

pub fn relate<T>(self, expected: T, variance: ty::Variance, actual: T) -> InferResult<'tcx, ()>
Expand Down Expand Up @@ -147,7 +147,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace(expected, actual).lub(&expected, &actual)
self.trace(expected, actual).lub(expected, actual)
}

/// Computes the greatest-lower-bound, or mutual subtype, of two
Expand All @@ -157,7 +157,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace(expected, actual).glb(&expected, &actual)
self.trace(expected, actual).glb(expected, actual)
}

/// Sets the "trace" values that will be used for
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
impl<'a, 'tcx> Trace<'a, 'tcx> {
/// Makes `a <: b` where `a` may or may not be expected (if
/// `a_is_expected` is true, then `a` is expected).
pub fn sub<T>(self, a: &T, b: &T) -> InferResult<'tcx, ()>
pub fn sub<T>(self, a: T, b: T) -> InferResult<'tcx, ()>
where
T: Relate<'tcx>,
{
Expand All @@ -203,7 +203,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {

/// Makes `a == b`; the expectation is set by the call to
/// `trace()`.
pub fn eq<T>(self, a: &T, b: &T) -> InferResult<'tcx, ()>
pub fn eq<T>(self, a: T, b: T) -> InferResult<'tcx, ()>
where
T: Relate<'tcx>,
{
Expand All @@ -218,7 +218,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
})
}

pub fn lub<T>(self, a: &T, b: &T) -> InferResult<'tcx, T>
pub fn lub<T>(self, a: T, b: T) -> InferResult<'tcx, T>
where
T: Relate<'tcx>,
{
Expand All @@ -233,7 +233,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
})
}

pub fn glb<T>(self, a: &T, b: &T) -> InferResult<'tcx, T>
pub fn glb<T>(self, a: T, b: T) -> InferResult<'tcx, T>
where
T: Relate<'tcx>,
{
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_infer/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
},
ty::Variance::Invariant,
)
.relate(&v1, &v2)?;
.relate(v1, v2)?;
}

(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
Expand All @@ -285,7 +285,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
},
ty::Variance::Invariant,
)
.relate(&v1, &v2)?;
.relate(v1, v2)?;
}

_ => {
Expand All @@ -302,7 +302,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
// Screen out `'a: 'a` cases -- we skip the binder here but
// only compare the inner values to one another, so they are still at
// consistent binding levels.
let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
let ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
if k1 != r2.into() { Some(r_c) } else { None }
}),
);
Expand Down Expand Up @@ -526,7 +526,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
unsubstituted_region_constraints.iter().map(move |constraint| {
let constraint = substitute_value(self.tcx, result_subst, constraint);
let &ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below

Obligation::new(
cause.clone(),
Expand Down
20 changes: 10 additions & 10 deletions src/librustc_infer/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
// to associate causes/spans with each of the relations in
// the stack to get this right.
match dir {
EqTo => self.equate(a_is_expected).relate(&a_ty, &b_ty),
SubtypeOf => self.sub(a_is_expected).relate(&a_ty, &b_ty),
EqTo => self.equate(a_is_expected).relate(a_ty, b_ty),
SubtypeOf => self.sub(a_is_expected).relate(a_ty, b_ty),
SupertypeOf => {
self.sub(a_is_expected).relate_with_variance(ty::Contravariant, &a_ty, &b_ty)
self.sub(a_is_expected).relate_with_variance(ty::Contravariant, a_ty, b_ty)
}
}?;

Expand Down Expand Up @@ -379,7 +379,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
param_env: self.param_env,
};

let ty = match generalize.relate(&ty, &ty) {
let ty = match generalize.relate(ty, ty) {
Ok(ty) => ty,
Err(e) => {
debug!("generalize: failure {:?}", e);
Expand Down Expand Up @@ -490,8 +490,8 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {

fn binders<T>(
&mut self,
a: &ty::Binder<T>,
b: &ty::Binder<T>,
a: ty::Binder<T>,
b: ty::Binder<T>,
) -> RelateResult<'tcx, ty::Binder<T>>
where
T: Relate<'tcx>,
Expand Down Expand Up @@ -519,8 +519,8 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
variance: ty::Variance,
a: &T,
b: &T,
a: T,
b: T,
) -> RelateResult<'tcx, T> {
let old_ambient_variance = self.ambient_variance;
self.ambient_variance = self.ambient_variance.xform(variance);
Expand Down Expand Up @@ -552,7 +552,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
match probe {
TypeVariableValue::Known { value: u } => {
debug!("generalize: known value {:?}", u);
self.relate(&u, &u)
self.relate(u, u)
}
TypeVariableValue::Unknown { universe } => {
match self.ambient_variance {
Expand Down Expand Up @@ -655,7 +655,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
let variable_table = &mut inner.const_unification_table();
let var_value = variable_table.probe_value(vid);
match var_value.val {
ConstVariableValue::Known { value: u } => self.relate(&u, &u),
ConstVariableValue::Known { value: u } => self.relate(u, u),
ConstVariableValue::Unknown { universe } => {
if self.for_universe.can_name(universe) {
Ok(c)
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_infer/infer/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
_: ty::Variance,
a: &T,
b: &T,
a: T,
b: T,
) -> RelateResult<'tcx, T> {
self.relate(a, b)
}
Expand Down Expand Up @@ -124,8 +124,8 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {

fn binders<T>(
&mut self,
a: &ty::Binder<T>,
b: &ty::Binder<T>,
a: ty::Binder<T>,
b: ty::Binder<T>,
) -> RelateResult<'tcx, ty::Binder<T>>
where
T: Relate<'tcx>,
Expand All @@ -136,7 +136,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
} else {
// Fast path for the common case.
self.relate(a.skip_binder(), b.skip_binder())?;
Ok(a.clone())
Ok(a)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_infer/infer/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
variance: ty::Variance,
a: &T,
b: &T,
a: T,
b: T,
) -> RelateResult<'tcx, T> {
match variance {
ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b),
Expand Down Expand Up @@ -85,8 +85,8 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {

fn binders<T>(
&mut self,
a: &ty::Binder<T>,
b: &ty::Binder<T>,
a: ty::Binder<T>,
b: ty::Binder<T>,
) -> RelateResult<'tcx, ty::Binder<T>>
where
T: Relate<'tcx>,
Expand All @@ -112,8 +112,8 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx,

fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()> {
let mut sub = self.fields.sub(self.a_is_expected);
sub.relate(&v, &a)?;
sub.relate(&v, &b)?;
sub.relate(v, a)?;
sub.relate(v, b)?;
Ok(())
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_infer/infer/higher_ranked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use rustc_middle::ty::{self, Binder, TypeFoldable};
impl<'a, 'tcx> CombineFields<'a, 'tcx> {
pub fn higher_ranked_sub<T>(
&mut self,
a: &Binder<T>,
b: &Binder<T>,
a: Binder<T>,
b: Binder<T>,
a_is_expected: bool,
) -> RelateResult<'tcx, Binder<T>>
where
Expand All @@ -33,20 +33,20 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
self.infcx.commit_if_ok(|_| {
// First, we instantiate each bound region in the supertype with a
// fresh placeholder region.
let (b_prime, _) = self.infcx.replace_bound_vars_with_placeholders(b);
let (b_prime, _) = self.infcx.replace_bound_vars_with_placeholders(&b);

// Next, we instantiate each bound region in the subtype
// with a fresh region variable. These region variables --
// but no other pre-existing region variables -- can name
// the placeholders.
let (a_prime, _) =
self.infcx.replace_bound_vars_with_fresh_vars(span, HigherRankedType, a);
self.infcx.replace_bound_vars_with_fresh_vars(span, HigherRankedType, &a);

debug!("a_prime={:?}", a_prime);
debug!("b_prime={:?}", b_prime);

// Compare types now that bound regions have been replaced.
let result = self.sub(a_is_expected).relate(&a_prime, &b_prime)?;
let result = self.sub(a_is_expected).relate(a_prime, b_prime)?;

debug!("higher_ranked_sub: OK result={:?}", result);

Expand Down
Loading