Skip to content

Commit

Permalink
Auto merge of rust-lang#78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 16 pull requests

Successful merges:

 - rust-lang#76635 (Add [T]::as_chunks(_mut))
 - rust-lang#77703 (add system-llvm-libunwind config option)
 - rust-lang#78219 (Prefer to use `print_def_path`)
 - rust-lang#78298 (Add test for bad NLL higher-ranked subtype)
 - rust-lang#78332 (Update description for error E0308)
 - rust-lang#78342 (Use check-pass in single-use-lifetime ui tests)
 - rust-lang#78347 (Add lexicographical comparison doc)
 - rust-lang#78348 (Make some functions private that don't have to be public)
 - rust-lang#78349 (Use its own `TypeckResults` to avoid ICE)
 - rust-lang#78375 (Use ? in core/std macros)
 - rust-lang#78377 (Fix typo in debug statement)
 - rust-lang#78388 (Add some regression tests)
 - rust-lang#78394 (fix(docs): typo in BufWriter documentation)
 - rust-lang#78396 (Add compiler support for LLVM's x86_64 ERMSB feature)
 - rust-lang#78405 (Fix typo in lint description)
 - rust-lang#78412 (Improve formatting of hash collections docs)

Failed merges:

r? `@ghost`
  • Loading branch information
bors committed Oct 27, 2020
2 parents a4d30a7 + 4236d27 commit 28f03ac
Show file tree
Hide file tree
Showing 51 changed files with 558 additions and 262 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("bmi1", None),
("bmi2", None),
("cmpxchg16b", Some(sym::cmpxchg16b_target_feature)),
("ermsb", Some(sym::ermsb_target_feature)),
("f16c", Some(sym::f16c_target_feature)),
("fma", None),
("fxsr", None),
Expand Down
32 changes: 20 additions & 12 deletions compiler/rustc_error_codes/src/error_codes/E0308.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
Expected type did not match the received type.

Erroneous code example:
Erroneous code examples:

```compile_fail,E0308
let x: i32 = "I am not a number!";
// ~~~ ~~~~~~~~~~~~~~~~~~~~
// | |
// | initializing expression;
// | compiler infers type `&str`
// |
// type `i32` assigned to variable `x`
fn plus_one(x: i32) -> i32 {
x + 1
}
plus_one("Not a number");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`
if "Not a bool" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}
let x: f32 = "Not a float";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when the compiler is unable to infer the concrete type of a
variable. It can occur in several cases, the most common being a mismatch
between two types: the type the author explicitly assigned, and the type the
compiler inferred.
This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
1 change: 1 addition & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ declare_features! (
(active, rtm_target_feature, "1.35.0", Some(44839), None),
(active, f16c_target_feature, "1.36.0", Some(44839), None),
(active, riscv_target_feature, "1.45.0", Some(44839), None),
(active, ermsb_target_feature, "1.49.0", Some(44839), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates (target features)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ pub trait PrettyPrinter<'tcx>:
let span = self.tcx().hir().span(hir_id);
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
} else {
p!(write("@{}", self.tcx().def_path_str(did)));
p!(write("@"), print_def_path(did, substs));
}
} else {
p!(print_def_path(did, substs));
Expand Down Expand Up @@ -694,7 +694,7 @@ pub trait PrettyPrinter<'tcx>:
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
}
} else {
p!(write("@{}", self.tcx().def_path_str(did)));
p!(write("@"), print_def_path(did, substs));
}
} else {
p!(print_def_path(did, substs));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let arm_end_blocks: Vec<_> = arm_candidates
.into_iter()
.map(|(arm, candidate)| {
debug!("lowering arm {:?}\ncanidate = {:?}", arm, candidate);
debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate);

let arm_source_info = self.source_info(arm.span);
let arm_scope = (arm.scope, arm_source_info);
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_save_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,14 @@ impl<'tcx> SaveContext<'tcx> {
})
| Node::Ty(&hir::Ty { kind: hir::TyKind::Path(ref qpath), .. }) => match qpath {
hir::QPath::Resolved(_, path) => path.res,
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
.maybe_typeck_results
.map_or(Res::Err, |typeck_results| typeck_results.qpath_res(qpath, hir_id)),
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
// #75962: `self.typeck_results` may be different from the `hir_id`'s result.
if self.tcx.has_typeck_results(hir_id.owner.to_def_id()) {
self.tcx.typeck(hir_id.owner).qpath_res(qpath, hir_id)
} else {
Res::Err
}
}
},

Node::Binding(&hir::Pat {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_save_analysis/src/sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
} else {
let start = offset + prefix.len() + 5;
let end = start + name.len();
// FIXME should put the proper path in there, not elipses.
// FIXME should put the proper path in there, not ellipsis.
Ok(Signature {
text: prefix + "...::" + &name,
defs: vec![],
Expand All @@ -272,7 +272,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
}
hir::TyKind::Path(hir::QPath::TypeRelative(ty, segment)) => {
let nested_ty = ty.make(offset + 1, id, scx)?;
let prefix = format!("<{}>::", nested_ty.text,);
let prefix = format!("<{}>::", nested_ty.text);

let name = path_segment_to_string(segment);
let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
Expand Down Expand Up @@ -551,7 +551,7 @@ impl<'hir> Sig for hir::Item<'hir> {
// FIXME where clause
}
hir::ItemKind::ForeignMod(_) => Err("extern mod"),
hir::ItemKind::GlobalAsm(_) => Err("glboal asm"),
hir::ItemKind::GlobalAsm(_) => Err("global asm"),
hir::ItemKind::ExternCrate(_) => Err("extern crate"),
hir::ItemKind::OpaqueTy(..) => Err("opaque type"),
// FIXME should implement this (e.g., pub use).
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,7 @@ declare_lint! {
}

declare_lint! {
/// The `uninhabited_static` lint detects uninhbaited statics.
/// The `uninhabited_static` lint detects uninhabited statics.
///
/// ### Example
///
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ symbols! {
encode,
env,
eq,
ermsb_target_feature,
err,
exact_div,
except,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2409,6 +2409,7 @@ fn from_target_feature(
Some(sym::movbe_target_feature) => rust_features.movbe_target_feature,
Some(sym::rtm_target_feature) => rust_features.rtm_target_feature,
Some(sym::f16c_target_feature) => rust_features.f16c_target_feature,
Some(sym::ermsb_target_feature) => rust_features.ermsb_target_feature,
Some(name) => bug!("unknown target feature gate {}", name),
None => true,
};
Expand Down
3 changes: 2 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ changelog-seen = 2
#test-compare-mode = false

# Use LLVM libunwind as the implementation for Rust's unwinder.
#llvm-libunwind = false
# Accepted values are 'in-tree' (formerly true), 'system' or 'no' (formerly false).
#llvm-libunwind = 'no'

# Enable Windows Control Flow Guard checks in the standard library.
# This only applies from stage 1 onwards, and only for Windows targets.
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,7 @@ __impl_slice_eq1! { [const N: usize] Vec<A>, &[B; N], #[stable(feature = "rust1"
//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], }
//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], }

/// Implements comparison of vectors, lexicographically.
/// Implements comparison of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialOrd> PartialOrd for Vec<T> {
#[inline]
Expand All @@ -2578,7 +2578,7 @@ impl<T: PartialOrd> PartialOrd for Vec<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Eq> Eq for Vec<T> {}

/// Implements ordering of vectors, lexicographically.
/// Implements ordering of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Ord for Vec<T> {
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl<T: PartialOrd, const N: usize> PartialOrd for [T; N] {
}
}

/// Implements comparison of arrays lexicographically.
/// Implements comparison of arrays [lexicographically](Ord#lexicographical-comparison).
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord, const N: usize> Ord for [T; N] {
#[inline]
Expand Down
12 changes: 11 additions & 1 deletion library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,19 @@ impl<T: Ord> Ord for Reverse<T> {
/// ## Derivable
///
/// This trait can be used with `#[derive]`. When `derive`d on structs, it will produce a
/// lexicographic ordering based on the top-to-bottom declaration order of the struct's members.
/// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering based on the top-to-bottom declaration order of the struct's members.
/// When `derive`d on enums, variants are ordered by their top-to-bottom discriminant order.
///
/// ## Lexicographical comparison
///
/// Lexicographical comparison is an operation with the following properties:
/// - Two sequences are compared element by element.
/// - The first mismatching element defines which sequence is lexicographically less or greater than the other.
/// - If one sequence is a prefix of another, the shorter sequence is lexicographically less than the other.
/// - If two sequence have equivalent elements and are of the same length, then the sequences are lexicographically equal.
/// - An empty sequence is lexicographically less than any non-empty sequence.
/// - Two empty sequences are lexicographically equal.
///
/// ## How can I implement `Ord`?
///
/// `Ord` requires that the type also be [`PartialOrd`] and [`Eq`] (which requires [`PartialEq`]).
Expand Down
16 changes: 8 additions & 8 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,7 @@ pub trait Iterator {
Product::product(self)
}

/// Lexicographically compares the elements of this [`Iterator`] with those
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
/// of another.
///
/// # Examples
Expand All @@ -2873,7 +2873,7 @@ pub trait Iterator {
self.cmp_by(other, |x, y| x.cmp(&y))
}

/// Lexicographically compares the elements of this [`Iterator`] with those
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
/// of another with respect to the specified comparison function.
///
/// # Examples
Expand Down Expand Up @@ -2925,7 +2925,7 @@ pub trait Iterator {
}
}

/// Lexicographically compares the elements of this [`Iterator`] with those
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
/// of another.
///
/// # Examples
Expand All @@ -2949,7 +2949,7 @@ pub trait Iterator {
self.partial_cmp_by(other, |x, y| x.partial_cmp(&y))
}

/// Lexicographically compares the elements of this [`Iterator`] with those
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
/// of another with respect to the specified comparison function.
///
/// # Examples
Expand Down Expand Up @@ -3089,7 +3089,7 @@ pub trait Iterator {
!self.eq(other)
}

/// Determines if the elements of this [`Iterator`] are lexicographically
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
/// less than those of another.
///
/// # Examples
Expand All @@ -3110,7 +3110,7 @@ pub trait Iterator {
self.partial_cmp(other) == Some(Ordering::Less)
}

/// Determines if the elements of this [`Iterator`] are lexicographically
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
/// less or equal to those of another.
///
/// # Examples
Expand All @@ -3131,7 +3131,7 @@ pub trait Iterator {
matches!(self.partial_cmp(other), Some(Ordering::Less | Ordering::Equal))
}

/// Determines if the elements of this [`Iterator`] are lexicographically
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
/// greater than those of another.
///
/// # Examples
Expand All @@ -3152,7 +3152,7 @@ pub trait Iterator {
self.partial_cmp(other) == Some(Ordering::Greater)
}

/// Determines if the elements of this [`Iterator`] are lexicographically
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
/// greater than or equal to those of another.
///
/// # Examples
Expand Down
Loading

0 comments on commit 28f03ac

Please sign in to comment.