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 16 pull requests #78421

Merged
merged 34 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
652f34d
Add [T]::as_chunks_mut (as unstable)
scottmcm Sep 12, 2020
66fa42a
allow using the system-wide llvm-libunwind as the unwinder
Keruspe Oct 8, 2020
6fdd53b
Prefer to use `print_def_path`
JohnTitor Oct 22, 2020
5923218
Add test for bad NLL higher-ranked subtype
Aaron1011 Oct 23, 2020
cc468c0
Use check-pass in single-use-lifetime ui test suite
oliviacrain Oct 25, 2020
e218380
Make some functions private that don't have to be public
jyn514 Oct 25, 2020
88d3967
Use its own `TypeckResults` to avoid ICE
JohnTitor Oct 25, 2020
4f34537
Fix small typos
JohnTitor Oct 25, 2020
666afba
Update description for error E0308
PoignardAzur Oct 24, 2020
9de1518
Fix typo in debug statement
LeSeulArtichaut Oct 25, 2020
04c0018
Use ? in core/std macros
taiki-e Oct 25, 2020
a4ba179
fix(docs): typo in BufWriter documentation
rubik Oct 26, 2020
ad552bc
Add compiler support for LLVM's x86 ERMSB feature
josephlr Oct 26, 2020
42844ed
Add lexicographical comparison doc
Rustin170506 Oct 25, 2020
74a9891
Fix typo in lint description
notriddle Oct 26, 2020
94ed945
Add some regression tests
camelid Oct 26, 2020
4641d2e
Add FIXME note to const generics test
camelid Oct 26, 2020
59f1088
Improve formatting of hash collections docs
camelid Oct 26, 2020
13e88d6
Rollup merge of #76635 - scottmcm:slice-as-chunks, r=LukasKalbertodt
JohnTitor Oct 26, 2020
2c307fa
Rollup merge of #77703 - Keruspe:system-libunwind, r=Mark-Simulacrum
JohnTitor Oct 26, 2020
f3c9437
Rollup merge of #78219 - JohnTitor:print-def-path, r=estebank
JohnTitor Oct 26, 2020
9d7db48
Rollup merge of #78298 - Aaron1011:fix/nll-ranked-test, r=Mark-Simula…
JohnTitor Oct 26, 2020
0b72ca6
Rollup merge of #78332 - PoignardAzur:doc_E0308, r=camelid
JohnTitor Oct 26, 2020
afdd148
Rollup merge of #78342 - oliviacrain:checkmate-pass, r=Mark-Simulacrum
JohnTitor Oct 26, 2020
727e93d
Rollup merge of #78347 - Rustin-Liu:rustin-patch-doc, r=kennytm
JohnTitor Oct 26, 2020
ae54425
Rollup merge of #78348 - jyn514:pub-crate, r=GuillaumeGomez
JohnTitor Oct 26, 2020
6abd2a5
Rollup merge of #78349 - JohnTitor:issue-75962, r=davidtwco
JohnTitor Oct 26, 2020
5a33fa5
Rollup merge of #78375 - taiki-e:question-in-macros, r=kennytm
JohnTitor Oct 26, 2020
b72d70e
Rollup merge of #78377 - LeSeulArtichaut:patch-docs, r=jonas-schievink
JohnTitor Oct 26, 2020
98e2a95
Rollup merge of #78388 - camelid:regression-tests, r=lcnr
JohnTitor Oct 26, 2020
f6f8764
Rollup merge of #78394 - rubik:master, r=m-ou-se
JohnTitor Oct 26, 2020
46b8e46
Rollup merge of #78396 - josephlr:ermsb, r=petrochenkov
JohnTitor Oct 26, 2020
7824d9a
Rollup merge of #78405 - notriddle:patch-3, r=lcnr
JohnTitor Oct 26, 2020
4236d27
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
JohnTitor Oct 26, 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
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