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 11 pull requests #73599

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d08b1b
Clean up E0689 explanation
GuillaumeGomez Jun 18, 2020
0624a5a
Squashed all commits
rakshith-ravi Jun 20, 2020
fc60282
impl PartialEq<Vec<B>> for &[A], &mut [A]
sollyucko Apr 29, 2020
4896a06
Update stability attribute of new Vec PartialEq impls
dtolnay Jun 20, 2020
6374054
Fix typos in doc comments
JOE1994 Jun 21, 2020
e3d735d
Fix typo in error_codes doc
dario23 Jun 21, 2020
1c74ab4
Make is_freeze and is_copy_modulo_regions take TyCtxtAt
RalfJung Jun 21, 2020
467415d
deprecate wrapping_offset_from
RalfJung Jun 21, 2020
a657be4
Create E0765 error for unterminated double quote strings
GuillaumeGomez Jun 21, 2020
726b6f4
Miri: replace many bug! by span_bug!
RalfJung Jun 21, 2020
c14d85f
Update UI tests
GuillaumeGomez Jun 21, 2020
893077c
Update src/librustc_mir/monomorphize/collector.rs
JOE1994 Jun 21, 2020
fea5ab1
Prefer accessible paths in 'use' suggestions
da-x Jun 13, 2020
20866c5
Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, …
Aaron1011 Jun 21, 2020
2959352
Re-enable Clippy tests
Aaron1011 Jun 21, 2020
c062ce5
Rollup merge of #71660 - sollyucko:master, r=dtolnay
Manishearth Jun 21, 2020
103b0e3
Rollup merge of #72271 - rakshith-ravi:master, r=varkor
Manishearth Jun 21, 2020
fcea8a1
Rollup merge of #72623 - da-x:use-suggest-public-path, r=petrochenkov
Manishearth Jun 21, 2020
c1ca2d6
Rollup merge of #73472 - GuillaumeGomez:cleanup-e0689, r=Dylan-DPC
Manishearth Jun 21, 2020
7f687b9
Rollup merge of #73502 - GuillaumeGomez:add-e0764, r=estebank
Manishearth Jun 21, 2020
e78a0b3
Rollup merge of #73572 - JOE1994:patch-4, r=jonas-schievink
Manishearth Jun 21, 2020
fd4558e
Rollup merge of #73575 - dario23:typo-errorcodes-doc, r=matthewjasper
Manishearth Jun 21, 2020
cd7cc60
Rollup merge of #73578 - RalfJung:ty-ctxt-at, r=jonas-schievink
Manishearth Jun 21, 2020
8db431e
Rollup merge of #73580 - RalfJung:deprecate-wrapping-offset-from, r=A…
Manishearth Jun 21, 2020
02efde0
Rollup merge of #73582 - RalfJung:miri-span-bug, r=oli-obk
Manishearth Jun 21, 2020
8cabd20
Rollup merge of #73594 - Aaron1011:revert/move-fn-self-msg, r=petroch…
Manishearth Jun 21, 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
5 changes: 1 addition & 4 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,7 @@ impl Step for Clippy {

builder.add_rustc_lib_path(compiler, &mut cargo);

// FIXME: Disable clippy tests for now, they're failing on master
// (generally this would mean a toolstate failure but we don't have
// toolstate for clippy anymore).
// builder.run(&mut cargo.into());
builder.run(&mut cargo.into());
}
}

Expand Down
54 changes: 54 additions & 0 deletions src/liballoc/tests/vec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::borrow::Cow;
use std::collections::TryReserveError::*;
use std::fmt::Debug;
use std::mem::size_of;
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::vec::{Drain, IntoIter};
Expand Down Expand Up @@ -1573,3 +1574,56 @@ fn test_push_growth_strategy() {
}
}
}

macro_rules! generate_assert_eq_vec_and_prim {
($name:ident<$B:ident>($type:ty)) => {
fn $name<A: PartialEq<$B> + Debug, $B: Debug>(a: Vec<A>, b: $type) {
assert!(a == b);
assert_eq!(a, b);
}
};
}

generate_assert_eq_vec_and_prim! { assert_eq_vec_and_slice <B>(&[B]) }
generate_assert_eq_vec_and_prim! { assert_eq_vec_and_array_3<B>([B; 3]) }

#[test]
fn partialeq_vec_and_prim() {
assert_eq_vec_and_slice(vec![1, 2, 3], &[1, 2, 3]);
assert_eq_vec_and_array_3(vec![1, 2, 3], [1, 2, 3]);
}

macro_rules! assert_partial_eq_valid {
($a2:ident, $a3:ident; $b2:ident, $b3: ident) => {
assert!($a2 == $b2);
assert!($a2 != $b3);
assert!($a3 != $b2);
assert!($a3 == $b3);
assert_eq!($a2, $b2);
assert_ne!($a2, $b3);
assert_ne!($a3, $b2);
assert_eq!($a3, $b3);
};
}

#[test]
fn partialeq_vec_full() {
let vec2: Vec<_> = vec![1, 2];
let vec3: Vec<_> = vec![1, 2, 3];
let slice2: &[_] = &[1, 2];
let slice3: &[_] = &[1, 2, 3];
let slicemut2: &[_] = &mut [1, 2];
let slicemut3: &[_] = &mut [1, 2, 3];
let array2: [_; 2] = [1, 2];
let array3: [_; 3] = [1, 2, 3];
let arrayref2: &[_; 2] = &[1, 2];
let arrayref3: &[_; 3] = &[1, 2, 3];

assert_partial_eq_valid!(vec2,vec3; vec2,vec3);
assert_partial_eq_valid!(vec2,vec3; slice2,slice3);
assert_partial_eq_valid!(vec2,vec3; slicemut2,slicemut3);
assert_partial_eq_valid!(slice2,slice3; vec2,vec3);
assert_partial_eq_valid!(slicemut2,slicemut3; vec2,vec3);
assert_partial_eq_valid!(vec2,vec3; array2,array3);
assert_partial_eq_valid!(vec2,vec3; arrayref2,arrayref3);
}
27 changes: 16 additions & 11 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2342,12 +2342,12 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> {
}

macro_rules! __impl_slice_eq1 {
([$($vars:tt)*] $lhs:ty, $rhs:ty, $($constraints:tt)*) => {
#[stable(feature = "rust1", since = "1.0.0")]
([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => {
#[$stability]
impl<A, B, $($vars)*> PartialEq<$rhs> for $lhs
where
A: PartialEq<B>,
$($constraints)*
$($ty: $bound)?
{
#[inline]
fn eq(&self, other: &$rhs) -> bool { self[..] == other[..] }
Expand All @@ -2357,18 +2357,23 @@ macro_rules! __impl_slice_eq1 {
}
}

__impl_slice_eq1! { [] Vec<A>, Vec<B>, }
__impl_slice_eq1! { [] Vec<A>, &[B], }
__impl_slice_eq1! { [] Vec<A>, &mut [B], }
__impl_slice_eq1! { [] Cow<'_, [A]>, Vec<B>, A: Clone }
__impl_slice_eq1! { [] Cow<'_, [A]>, &[B], A: Clone }
__impl_slice_eq1! { [] Cow<'_, [A]>, &mut [B], A: Clone }
__impl_slice_eq1! { [const N: usize] Vec<A>, [B; N], [B; N]: LengthAtMost32 }
__impl_slice_eq1! { [const N: usize] Vec<A>, &[B; N], [B; N]: LengthAtMost32 }
__impl_slice_eq1! { [] Vec<A>, Vec<B>, #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [] Vec<A>, &[B], #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [] Vec<A>, &mut [B], #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [] &[A], Vec<B>, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] }
__impl_slice_eq1! { [] &mut [A], Vec<B>, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] }
__impl_slice_eq1! { [] Cow<'_, [A]>, Vec<B> where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [] Cow<'_, [A]>, &[B] where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [] Cow<'_, [A]>, &mut [B] where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [const N: usize] Vec<A>, [B; N] where [B; N]: LengthAtMost32, #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [const N: usize] Vec<A>, &[B; N] where [B; N]: LengthAtMost32, #[stable(feature = "rust1", since = "1.0.0")] }

// NOTE: some less important impls are omitted to reduce code bloat
// FIXME(Centril): Reconsider this?
//__impl_slice_eq1! { [const N: usize] Vec<A>, &mut [B; N], [B; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] [A; N], Vec<B>, [A; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] &[A; N], Vec<B>, [A; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] &mut [A; N], Vec<B>, [A; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, [B; N], [B; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], [B; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], [B; N]: LengthAtMost32 }
Expand Down
6 changes: 6 additions & 0 deletions src/libcore/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ impl<T: ?Sized> *const T {
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
/// ```
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
#[rustc_deprecated(
since = "1.46.0",
reason = "Pointer distances across allocation \
boundaries are not typically meaningful. \
Use integer subtraction if you really need this."
)]
#[inline]
pub fn wrapping_offset_from(self, origin: *const T) -> isize
where
Expand Down
7 changes: 7 additions & 0 deletions src/libcore/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,18 @@ impl<T: ?Sized> *mut T {
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
/// ```
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
#[rustc_deprecated(
since = "1.46.0",
reason = "Pointer distances across allocation \
boundaries are not typically meaningful. \
Use integer subtraction if you really need this."
)]
#[inline]
pub fn wrapping_offset_from(self, origin: *const T) -> isize
where
T: Sized,
{
#[allow(deprecated_in_future, deprecated)]
(self as *const T).wrapping_offset_from(origin)
}

Expand Down
24 changes: 5 additions & 19 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_span::source_map::{respan, DesugaringKind, ForLoopLoc, Span, Spanned};
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_target::asm;
use std::collections::hash_map::Entry;
Expand All @@ -25,7 +25,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
let mut span = e.span;
ensure_sufficient_stack(|| {
let kind = match e.kind {
ExprKind::Box(ref inner) => hir::ExprKind::Box(self.lower_expr(inner)),
Expand Down Expand Up @@ -54,7 +53,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::ExprKind::MethodCall(hir_seg, seg.ident.span, args, span)
}
ExprKind::Binary(binop, ref lhs, ref rhs) => {
span = self.mark_span_with_reason(DesugaringKind::Operator, e.span, None);
let binop = self.lower_binop(binop);
let lhs = self.lower_expr(lhs);
let rhs = self.lower_expr(rhs);
Expand Down Expand Up @@ -224,7 +222,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::Expr {
hir_id: self.lower_node_id(e.id),
kind,
span,
span: e.span,
attrs: e.attrs.iter().map(|a| self.lower_attr(a)).collect::<Vec<_>>().into(),
}
})
Expand All @@ -239,7 +237,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_binop(&mut self, b: BinOp) -> hir::BinOp {
let span = self.mark_span_with_reason(DesugaringKind::Operator, b.span, None);
Spanned {
node: match b.node {
BinOpKind::Add => hir::BinOpKind::Add,
Expand All @@ -261,7 +258,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
BinOpKind::Ge => hir::BinOpKind::Ge,
BinOpKind::Gt => hir::BinOpKind::Gt,
},
span,
span: b.span,
}
}

Expand Down Expand Up @@ -1363,14 +1360,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
body: &Block,
opt_label: Option<Label>,
) -> hir::Expr<'hir> {
let orig_head_span = head.span;
// expand <head>
let mut head = self.lower_expr_mut(head);
let desugared_span = self.mark_span_with_reason(
DesugaringKind::ForLoop(ForLoopLoc::Head),
orig_head_span,
None,
);
let desugared_span = self.mark_span_with_reason(DesugaringKind::ForLoop, head.span, None);
head.span = desugared_span;

let iter = Ident::with_dummy_span(sym::iter);
Expand Down Expand Up @@ -1465,16 +1457,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `mut iter => { ... }`
let iter_arm = self.arm(iter_pat, loop_expr);

let into_iter_span = self.mark_span_with_reason(
DesugaringKind::ForLoop(ForLoopLoc::IntoIter),
orig_head_span,
None,
);

// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
let into_iter_expr = {
let into_iter_path = &[sym::iter, sym::IntoIterator, sym::into_iter];
self.expr_call_std_path(into_iter_span, into_iter_path, arena_vec![self; head])
self.expr_call_std_path(desugared_span, into_iter_path, arena_vec![self; head])
};

let match_expr = self.arena.alloc(self.expr_match(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/traits/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
}

fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
ty.is_freeze(self.tcx(), ty::ParamEnv::reveal_all(), DUMMY_SP)
ty.is_freeze(self.tcx().at(DUMMY_SP), ty::ParamEnv::reveal_all())
}

fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ E0761: include_str!("./error_codes/E0761.md"),
E0762: include_str!("./error_codes/E0762.md"),
E0763: include_str!("./error_codes/E0763.md"),
E0764: include_str!("./error_codes/E0764.md"),
E0765: include_str!("./error_codes/E0765.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes/E0081.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A discrimant value is present more than once.
A discriminant value is present more than once.

Erroneous code example:

Expand Down
19 changes: 11 additions & 8 deletions src/librustc_error_codes/error_codes/E0689.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
This error indicates that the numeric value for the method being passed exists
but the type of the numeric value or binding could not be identified.
A method was called on an ambiguous numeric type.

The error happens on numeric literals:
Erroneous code example:

```compile_fail,E0689
2.0.neg();
2.0.neg(); // error!
```

and on numeric bindings without an identified concrete type:
This error indicates that the numeric value for the method being passed exists
but the type of the numeric value or binding could not be identified.

The error happens on numeric literals and on numeric bindings without an
identified concrete type:

```compile_fail,E0689
let x = 2.0;
Expand All @@ -19,8 +22,8 @@ Because of this, you must give the numeric literal or binding a type:
```
use std::ops::Neg;

let _ = 2.0_f32.neg();
let _ = 2.0_f32.neg(); // ok!
let x: f32 = 2.0;
let _ = x.neg();
let _ = (2.0 as f32).neg();
let _ = x.neg(); // ok!
let _ = (2.0 as f32).neg(); // ok!
```
13 changes: 13 additions & 0 deletions src/librustc_error_codes/error_codes/E0765.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
A double quote string (`"`) was not terminated.

Erroneous code example:

```compile_fail,E0765
let s = "; // error!
```

To fix this error, add the missing double quote at the end of the string:

```
let s = ""; // ok!
```
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let msg = if let Some(simple_ident) = pattern.simple_ident() {
match pattern.span.desugaring_kind() {
None => format!("consider giving `{}` {}", simple_ident, suffix),
Some(DesugaringKind::ForLoop(_)) => {
Some(DesugaringKind::ForLoop) => {
"the element type for this iterator is not specified".to_string()
}
_ => format!("this needs {}", suffix),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
return;
}
let param_env = ty::ParamEnv::empty();
if ty.is_copy_modulo_regions(cx.tcx, param_env, item.span) {
if ty.is_copy_modulo_regions(cx.tcx.at(item.span), param_env) {
return;
}
if can_type_implement_copy(cx.tcx, param_env, ty).is_ok() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,13 +1318,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
}
}

fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [Ident] {
fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [Symbol] {
let param_names = match self.kind(id) {
EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
_ => Lazy::empty(),
};
tcx.arena.alloc_from_iter(param_names.decode((self, tcx)))
tcx.arena.alloc_from_iter(param_names.decode(self))
}

fn exported_symbols(
Expand Down
16 changes: 11 additions & 5 deletions src/librustc_metadata/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt};
use rustc_serialize::{opaque, Encodable, Encoder, SpecializedEncoder, UseSpecializedEncodable};
use rustc_session::config::CrateType;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{self, ExternalSource, FileName, SourceFile, Span};
use rustc_target::abi::VariantIdx;
use std::hash::Hash;
Expand Down Expand Up @@ -1009,12 +1009,18 @@ impl EncodeContext<'tcx> {
}
}

fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Ident]> {
self.tcx.dep_graph.with_ignore(|| self.lazy(self.tcx.hir().body_param_names(body_id)))
fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Symbol]> {
self.tcx.dep_graph.with_ignore(|| {
let body = self.tcx.hir().body(body_id);
self.lazy(body.params.iter().map(|arg| match arg.pat.kind {
hir::PatKind::Binding(_, _, ident, _) => ident.name,
_ => kw::Invalid,
}))
})
}

fn encode_fn_param_names(&mut self, param_names: &[Ident]) -> Lazy<[Ident]> {
self.lazy(param_names.iter())
fn encode_fn_param_names(&mut self, param_names: &[Ident]) -> Lazy<[Symbol]> {
self.lazy(param_names.iter().map(|ident| ident.name))
}

fn encode_optimized_mir(&mut self, def_id: LocalDefId) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_serialize::opaque::Encoder;
use rustc_session::config::SymbolManglingVersion;
use rustc_session::CrateDisambiguator;
use rustc_span::edition::Edition;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::symbol::Symbol;
use rustc_span::{self, Span};
use rustc_target::spec::{PanicStrategy, TargetTriple};

Expand Down Expand Up @@ -327,7 +327,7 @@ struct ModData {
struct FnData {
asyncness: hir::IsAsync,
constness: hir::Constness,
param_names: Lazy<[Ident]>,
param_names: Lazy<[Symbol]>,
}

#[derive(RustcEncodable, RustcDecodable)]
Expand Down
Loading