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 7 pull requests #63807

Merged
merged 21 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0337cc1
Use more optimal Ord implementation for integers
tesuji Aug 21, 2019
96983fc
Add comment to avoid accidentally remove the changes.
tesuji Aug 21, 2019
3375b05
Fix confusion in theme picker functions
GuillaumeGomez Aug 21, 2019
a9900be
add amanjeev
mark-i-m Aug 21, 2019
f5b16f6
Add codegen test for integers compare
tesuji Aug 21, 2019
1c82987
Fix typo in E0308 if/else label
estebank Aug 21, 2019
ba8e094
Add clarification on E0308 about opaque types
estebank Aug 21, 2019
8c07d78
When declaring a declarative macro in an item it's only accessible in…
estebank Aug 16, 2019
4971667
review comments
estebank Aug 21, 2019
a710c61
review comments: reword and add test
estebank Aug 21, 2019
4f613ff
Fix naming misspelling
howjmay Aug 20, 2019
b7ad3f9
Apply clippy::redundant_field_names suggestion
mati865 Aug 22, 2019
7f4aba4
Apply clippy::needless_return suggestions
mati865 Aug 22, 2019
edabcdd
Apply clippy::let_and_return suggestion
mati865 Aug 22, 2019
8a26ba7
Rollup merge of #63624 - estebank:unreachable-macro, r=petrochenkov
Centril Aug 22, 2019
0784395
Rollup merge of #63737 - HowJMay:fix_naming, r=jonas-schievink
Centril Aug 22, 2019
30fd79c
Rollup merge of #63767 - lzutao:integer-ord-suboptimal, r=nagisa
Centril Aug 22, 2019
1f56441
Rollup merge of #63782 - GuillaumeGomez:theme-switch-fix, r=kinnison
Centril Aug 22, 2019
6c1cdb7
Rollup merge of #63788 - mark-i-m:rustc-guide-toolstate-add, r=ehuss
Centril Aug 22, 2019
aa9490b
Rollup merge of #63796 - estebank:opaque_future, r=Centril
Centril Aug 22, 2019
3068064
Rollup merge of #63805 - mati865:clippy, r=Centril
Centril Aug 22, 2019
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
2 changes: 1 addition & 1 deletion src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn native_lib_boilerplate(
if !up_to_date(Path::new("build.rs"), &timestamp) || !up_to_date(src_dir, &timestamp) {
Ok(NativeLibBoilerplate {
src_dir: src_dir.to_path_buf(),
out_dir: out_dir,
out_dir,
})
} else {
Err(())
Expand Down
8 changes: 5 additions & 3 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,11 @@ mod impls {
impl Ord for $t {
#[inline]
fn cmp(&self, other: &$t) -> Ordering {
if *self == *other { Equal }
else if *self < *other { Less }
else { Greater }
// The order here is important to generate more optimal assembly.
// See <https://github.com/rust-lang/rust/issues/63758> for more info.
if *self < *other { Less }
else if *self > *other { Greater }
else { Equal }
}
}
)*)
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ impl<I> DoubleEndedIterator for Peekable<I> where I: DoubleEndedIterator {
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
match self.peeked.take() {
Some(None) => return Try::from_ok(init),
Some(None) => Try::from_ok(init),
Some(Some(v)) => match self.iter.try_rfold(init, &mut f).into_result() {
Ok(acc) => f(acc, v),
Err(e) => {
Expand All @@ -1326,7 +1326,7 @@ impl<I> DoubleEndedIterator for Peekable<I> where I: DoubleEndedIterator {
where Fold: FnMut(Acc, Self::Item) -> Acc,
{
match self.peeked {
Some(None) => return init,
Some(None) => init,
Some(Some(v)) => {
let acc = self.iter.rfold(init, &mut fold);
fold(acc, v)
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3026,8 +3026,7 @@ macro_rules! len {
if size == 0 {
// This _cannot_ use `unchecked_sub` because we depend on wrapping
// to represent the length of long ZST slice iterators.
let diff = ($self.end as usize).wrapping_sub(start as usize);
diff
($self.end as usize).wrapping_sub(start as usize)
} else {
// We know that `start <= end`, so can do better than `offset_from`,
// which needs to deal in signed. By setting appropriate flags here
Expand Down
15 changes: 12 additions & 3 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ impl<'hir> Map<'hir> {
&self.forest.krate.attrs
}

pub fn get_module(&self, module: DefId) -> (&'hir Mod, Span, HirId)
{
pub fn get_module(&self, module: DefId) -> (&'hir Mod, Span, HirId) {
let hir_id = self.as_local_hir_id(module).unwrap();
self.read(hir_id);
match self.find_entry(hir_id).unwrap().node {
Expand All @@ -525,7 +524,7 @@ impl<'hir> Map<'hir> {
..
}) => (m, span, hir_id),
Node::Crate => (&self.forest.krate.module, self.forest.krate.span, hir_id),
_ => panic!("not a module")
node => panic!("not a module: {:?}", node),
}
}

Expand Down Expand Up @@ -679,6 +678,16 @@ impl<'hir> Map<'hir> {
}
}

/// Wether `hir_id` corresponds to a `mod` or a crate.
pub fn is_hir_id_module(&self, hir_id: HirId) -> bool {
match self.lookup(hir_id) {
Some(Entry { node: Node::Item(Item { node: ItemKind::Mod(_), .. }), .. }) |
Some(Entry { node: Node::Crate, .. }) => true,
_ => false,
}
}


/// If there is some error when walking the parents (e.g., a node does not
/// have a parent in the map or a node can't be found), then we return the
/// last good `HirId` we found. Note that reaching the crate root (`id == 0`),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ impl<'tcx> ObligationCause<'tcx> {
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
_ => "match arms have compatible types",
},
IfExpression { .. } => "if and else have compatible types",
IfExpression { .. } => "if and else have incompatible types",
IfExpressionWithNoElse => "if missing an else returns ()",
MainFunctionType => "`main` function has the correct type",
StartFunctionType => "`start` function has the correct type",
Expand Down
22 changes: 17 additions & 5 deletions src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,32 @@ impl<'tcx> ty::TyS<'tcx> {
}

impl<'tcx> TyCtxt<'tcx> {
pub fn note_and_explain_type_err(self,
db: &mut DiagnosticBuilder<'_>,
err: &TypeError<'tcx>,
sp: Span) {
pub fn note_and_explain_type_err(
self,
db: &mut DiagnosticBuilder<'_>,
err: &TypeError<'tcx>,
sp: Span,
) {
use self::TypeError::*;

match err.clone() {
match err {
Sorts(values) => {
let expected_str = values.expected.sort_string(self);
let found_str = values.found.sort_string(self);
if expected_str == found_str && expected_str == "closure" {
db.note("no two closures, even if identical, have the same type");
db.help("consider boxing your closure and/or using it as a trait object");
}
if expected_str == found_str && expected_str == "opaque type" { // Issue #63167
db.note("distinct uses of `impl Trait` result in different opaque types");
let e_str = values.expected.to_string();
let f_str = values.found.to_string();
if &e_str == &f_str && &e_str == "impl std::future::Future" {
// FIXME: use non-string based check.
db.help("if both `Future`s have the same `Output` type, consider \
`.await`ing on both of them");
}
}
if let (ty::Infer(ty::IntVar(_)), ty::Float(_)) =
(&values.found.sty, &values.expected.sty) // Issue #53280
{
Expand Down
20 changes: 7 additions & 13 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,7 @@ impl EmbargoVisitor<'tcx> {
}
}

fn update_macro_reachable_mod(
&mut self,
reachable_mod: hir::HirId,
defining_mod: DefId,
) {
fn update_macro_reachable_mod(&mut self, reachable_mod: hir::HirId, defining_mod: DefId) {
let module_def_id = self.tcx.hir().local_def_id(reachable_mod);
let module = self.tcx.hir().get_module(module_def_id).0;
for item_id in &module.item_ids {
Expand All @@ -524,19 +520,13 @@ impl EmbargoVisitor<'tcx> {
self.update_macro_reachable_def(hir_id, def_kind, vis, defining_mod);
}
}

if let Some(exports) = self.tcx.module_exports(module_def_id) {
for export in exports {
if export.vis.is_accessible_from(defining_mod, self.tcx) {
if let Res::Def(def_kind, def_id) = export.res {
let vis = def_id_visibility(self.tcx, def_id).0;
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
self.update_macro_reachable_def(
hir_id,
def_kind,
vis,
defining_mod,
);
self.update_macro_reachable_def(hir_id, def_kind, vis, defining_mod);
}
}
}
Expand Down Expand Up @@ -892,10 +882,14 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
self.tcx.hir().local_def_id(md.hir_id)
).unwrap();
let mut module_id = self.tcx.hir().as_local_hir_id(macro_module_def_id).unwrap();
if !self.tcx.hir().is_hir_id_module(module_id) {
// `module_id` doesn't correspond to a `mod`, return early (#63164).
return;
}
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
let new_level = self.update(md.hir_id, level);
if new_level.is_none() {
return
return;
}

loop {
Expand Down
16 changes: 8 additions & 8 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,22 +876,22 @@ r#"var themes = document.getElementById("theme-choices");
var themePicker = document.getElementById("theme-picker");

function showThemeButtonState() {{
themes.style.display = "none";
themePicker.style.borderBottomRightRadius = "3px";
themePicker.style.borderBottomLeftRadius = "3px";
}}

function hideThemeButtonState() {{
themes.style.display = "block";
themePicker.style.borderBottomRightRadius = "0";
themePicker.style.borderBottomLeftRadius = "0";
}}

function hideThemeButtonState() {{
themes.style.display = "none";
themePicker.style.borderBottomRightRadius = "3px";
themePicker.style.borderBottomLeftRadius = "3px";
}}

function switchThemeButtonState() {{
if (themes.style.display === "block") {{
showThemeButtonState();
}} else {{
hideThemeButtonState();
}} else {{
showThemeButtonState();
}}
}};

Expand Down
12 changes: 6 additions & 6 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ if (!DOMTokenList.prototype.remove) {
sidebar.appendChild(div);
}
}
var themePicker = document.getElementsByClassName("theme-picker");
if (themePicker && themePicker.length > 0) {
themePicker[0].style.display = "none";
var themePickers = document.getElementsByClassName("theme-picker");
if (themePickers && themePickers.length > 0) {
themePickers[0].style.display = "none";
}
}

Expand All @@ -123,9 +123,9 @@ if (!DOMTokenList.prototype.remove) {
filler.remove();
}
document.getElementsByTagName("body")[0].style.marginTop = "";
var themePicker = document.getElementsByClassName("theme-picker");
if (themePicker && themePicker.length > 0) {
themePicker[0].style.display = null;
var themePickers = document.getElementsByClassName("theme-picker");
if (themePickers && themePickers.length > 0) {
themePickers[0].style.display = null;
}
}

Expand Down
28 changes: 28 additions & 0 deletions src/test/codegen/integer-cmp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This is test for more optimal Ord implementation for integers.
// See <https://github.com/rust-lang/rust/issues/63758> for more info.

// compile-flags: -C opt-level=3

#![crate_type = "lib"]

use std::cmp::Ordering;

// CHECK-LABEL: @cmp_signed
#[no_mangle]
pub fn cmp_signed(a: i64, b: i64) -> Ordering {
// CHECK: icmp slt
// CHECK: icmp sgt
// CHECK: zext i1
// CHECK: select i1
a.cmp(&b)
}

// CHECK-LABEL: @cmp_unsigned
#[no_mangle]
pub fn cmp_unsigned(a: u32, b: u32) -> Ordering {
// CHECK: icmp ult
// CHECK: icmp ugt
// CHECK: zext i1
// CHECK: select i1
a.cmp(&b)
}
8 changes: 8 additions & 0 deletions src/test/ui/macros/macro-in-fn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// run-pass
#![feature(decl_macro)]

pub fn moo() {
pub macro ABC() {{}}
}

fn main() {}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,95 +1,95 @@
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-interger-atomic.rs:13:5
--> $DIR/non-integer-atomic.rs:13:5
|
LL | intrinsics::atomic_load(p);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-interger-atomic.rs:18:5
--> $DIR/non-integer-atomic.rs:18:5
|
LL | intrinsics::atomic_store(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-interger-atomic.rs:23:5
--> $DIR/non-integer-atomic.rs:23:5
|
LL | intrinsics::atomic_xchg(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-interger-atomic.rs:28:5
--> $DIR/non-integer-atomic.rs:28:5
|
LL | intrinsics::atomic_cxchg(p, v, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-interger-atomic.rs:33:5
--> $DIR/non-integer-atomic.rs:33:5
|
LL | intrinsics::atomic_load(p);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-interger-atomic.rs:38:5
--> $DIR/non-integer-atomic.rs:38:5
|
LL | intrinsics::atomic_store(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-interger-atomic.rs:43:5
--> $DIR/non-integer-atomic.rs:43:5
|
LL | intrinsics::atomic_xchg(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-interger-atomic.rs:48:5
--> $DIR/non-integer-atomic.rs:48:5
|
LL | intrinsics::atomic_cxchg(p, v, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()`
--> $DIR/non-interger-atomic.rs:53:5
--> $DIR/non-integer-atomic.rs:53:5
|
LL | intrinsics::atomic_load(p);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()`
--> $DIR/non-interger-atomic.rs:58:5
--> $DIR/non-integer-atomic.rs:58:5
|
LL | intrinsics::atomic_store(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()`
--> $DIR/non-interger-atomic.rs:63:5
--> $DIR/non-integer-atomic.rs:63:5
|
LL | intrinsics::atomic_xchg(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()`
--> $DIR/non-interger-atomic.rs:68:5
--> $DIR/non-integer-atomic.rs:68:5
|
LL | intrinsics::atomic_cxchg(p, v, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-interger-atomic.rs:73:5
--> $DIR/non-integer-atomic.rs:73:5
|
LL | intrinsics::atomic_load(p);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-interger-atomic.rs:78:5
--> $DIR/non-integer-atomic.rs:78:5
|
LL | intrinsics::atomic_store(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-interger-atomic.rs:83:5
--> $DIR/non-integer-atomic.rs:83:5
|
LL | intrinsics::atomic_xchg(p, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-interger-atomic.rs:88:5
--> $DIR/non-integer-atomic.rs:88:5
|
LL | intrinsics::atomic_cxchg(p, v, v);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading