Skip to content

Rollup of 7 pull requests #82341

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

Merged
merged 19 commits into from
Feb 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b08bc78
fix MIR fn-ptr pretty-printing
RalfJung Feb 16, 2021
026be9d
Keep consistency in example for Stdin StdinLock
pickfire Feb 18, 2021
5fd1ebe
Fix panic in 'remove semicolon' when types are not local
osa1 Feb 11, 2021
ad47fb1
Check opaque type def ids before bailing out
osa1 Feb 11, 2021
15fdccc
Update 'match-prev-arm-needing-semi'
osa1 Feb 11, 2021
9ef67e0
Add regression test
osa1 Feb 18, 2021
9b9c5ea
rustc: Show `@path` usage in stable
ojeda Feb 18, 2021
1839748
`impl PartialEq<Punct> for char`; symmetry for #78636
pthariensflame Jan 1, 2021
bf8563d
Fix minor mistake in LTO docs.
ehuss Feb 20, 2021
e906745
fn ptr pretty printing: fall back to raw ptr printing
RalfJung Feb 20, 2021
3071685
Don't render [src] link on dummy spans
GuillaumeGomez Feb 20, 2021
0c511c9
Add test for no src links on dummy spans
GuillaumeGomez Feb 20, 2021
d38f6e8
Rollup merge of #80595 - pthariensflame:patch-1, r=m-ou-se
GuillaumeGomez Feb 20, 2021
39af025
Rollup merge of #81991 - osa1:issue81839, r=estebank
GuillaumeGomez Feb 20, 2021
2d39300
Rollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obk
GuillaumeGomez Feb 20, 2021
c26a8bb
Rollup merge of #82244 - pickfire:patch-6, r=dtolnay
GuillaumeGomez Feb 20, 2021
8c09561
Rollup merge of #82260 - ojeda:rustc-argfile, r=jyn514
GuillaumeGomez Feb 20, 2021
77b6f96
Rollup merge of #82316 - ehuss:lto-doc-fix, r=GuillaumeGomez
GuillaumeGomez Feb 20, 2021
fc0cb5d
Rollup merge of #82332 - GuillaumeGomez:no-src-link-on-dummy-spans, r…
GuillaumeGomez Feb 20, 2021
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 compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ fn usage(verbose: bool, include_unstable_options: bool, nightly_build: bool) {
} else {
"\n --help -v Print the full set of options rustc accepts"
};
let at_path = if verbose && nightly_build {
let at_path = if verbose {
" @path Read newline separated options from `path`\n"
} else {
""
Expand Down
21 changes: 12 additions & 9 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ pub trait PrettyPrinter<'tcx>:
p!(write("{:?}", char::try_from(int).unwrap()))
}
// Raw pointers
(Scalar::Int(int), ty::RawPtr(_)) => {
(Scalar::Int(int), ty::RawPtr(_) | ty::FnPtr(_)) => {
let data = int.assert_bits(self.tcx().data_layout.pointer_size);
self = self.typed_value(
|mut this| {
Expand All @@ -1030,15 +1030,18 @@ pub trait PrettyPrinter<'tcx>:
)?;
}
(Scalar::Ptr(ptr), ty::FnPtr(_)) => {
// FIXME: this can ICE when the ptr is dangling or points to a non-function.
// We should probably have a helper method to share code with the "Byte strings"
// FIXME: We should probably have a helper method to share code with the "Byte strings"
// printing above (which also has to handle pointers to all sorts of things).
let instance = self.tcx().global_alloc(ptr.alloc_id).unwrap_fn();
self = self.typed_value(
|this| this.print_value_path(instance.def_id(), instance.substs),
|this| this.print_type(ty),
" as ",
)?;
match self.tcx().get_global_alloc(ptr.alloc_id) {
Some(GlobalAlloc::Function(instance)) => {
self = self.typed_value(
|this| this.print_value_path(instance.def_id(), instance.substs),
|this| this.print_type(ty),
" as ",
)?;
}
_ => self = self.pretty_print_const_pointer(ptr, ty, print_ty)?,
}
}
// For function type zsts just printing the path is enough
(Scalar::Int(int), ty::FnDef(d, s)) if int == ScalarInt::ZST => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
}
ScalarMaybeUninit::Uninit => cx.typed_value(
|mut this| {
this.write_str("{uninit ")?;
this.write_str("uninit ")?;
Ok(this)
},
|this| this.print_type(ty),
Expand Down
17 changes: 15 additions & 2 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,13 +1074,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
let last_expr_ty = self.node_ty(last_expr.hir_id);
let needs_box = match (last_expr_ty.kind(), expected_ty.kind()) {
(ty::Opaque(last_def_id, _), ty::Opaque(exp_def_id, _))
if last_def_id == exp_def_id =>
{
StatementAsExpression::CorrectType
}
(ty::Opaque(last_def_id, last_bounds), ty::Opaque(exp_def_id, exp_bounds)) => {
debug!(
"both opaque, likely future {:?} {:?} {:?} {:?}",
last_def_id, last_bounds, exp_def_id, exp_bounds
);
let last_hir_id = self.tcx.hir().local_def_id_to_hir_id(last_def_id.expect_local());
let exp_hir_id = self.tcx.hir().local_def_id_to_hir_id(exp_def_id.expect_local());

let (last_local_id, exp_local_id) =
match (last_def_id.as_local(), exp_def_id.as_local()) {
(Some(last_hir_id), Some(exp_hir_id)) => (last_hir_id, exp_hir_id),
(_, _) => return None,
};

let last_hir_id = self.tcx.hir().local_def_id_to_hir_id(last_local_id);
let exp_hir_id = self.tcx.hir().local_def_id_to_hir_id(exp_local_id);

match (
&self.tcx.hir().expect_item(last_hir_id).kind,
&self.tcx.hir().expect_item(exp_hir_id).kind,
Expand Down
9 changes: 8 additions & 1 deletion library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,13 +842,20 @@ impl fmt::Debug for Punct {
}
}

#[stable(feature = "proc_macro_punct_eq", since = "1.49.0")]
#[stable(feature = "proc_macro_punct_eq", since = "1.50.0")]
impl PartialEq<char> for Punct {
fn eq(&self, rhs: &char) -> bool {
self.as_char() == *rhs
}
}

#[stable(feature = "proc_macro_punct_eq_flipped", since = "1.52.0")]
impl PartialEq<Punct> for char {
fn eq(&self, rhs: &Punct) -> bool {
*self == rhs.as_char()
}
}

/// An identifier (`ident`).
#[derive(Clone)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ pub struct Stdin {
/// let mut buffer = String::new();
/// let stdin = io::stdin(); // We get `Stdin` here.
/// {
/// let mut stdin_lock = stdin.lock(); // We get `StdinLock` here.
/// stdin_lock.read_to_string(&mut buffer)?;
/// let mut handle = stdin.lock(); // We get `StdinLock` here.
/// handle.read_to_string(&mut buffer)?;
/// } // `StdinLock` is dropped here.
/// Ok(())
/// }
Expand Down
6 changes: 3 additions & 3 deletions src/doc/rustc/src/codegen-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ opt-level=0`](#opt-level)). That is:
* When `-C lto` is not specified:
* `codegen-units=1`: disable LTO.
* `opt-level=0`: disable LTO.
* When `-C lto=true`:
* `lto=true`: 16 codegen units, perform fat LTO across crates.
* `codegen-units=1` + `lto=true`: 1 codegen unit, fat LTO across crates.
* When `-C lto` is specified:
* `lto`: 16 codegen units, perform fat LTO across crates.
* `codegen-units=1` + `lto`: 1 codegen unit, fat LTO across crates.

See also [linker-plugin-lto](#linker-plugin-lto) for cross-language LTO.

Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,10 @@ impl Span {
self.0
}

crate fn is_dummy(&self) -> bool {
self.0.is_dummy()
}

crate fn filename(&self, sess: &Session) -> FileName {
sess.source_map().span_to_filename(self.0)
}
Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,9 @@ impl Context<'_> {
/// may happen, for example, with externally inlined items where the source
/// of their crate documentation isn't known.
fn src_href(&self, item: &clean::Item) -> Option<String> {
if item.source.is_dummy() {
return None;
}
let mut root = self.root_path();
let mut path = String::new();
let cnum = item.source.cnum(self.sess());
Expand Down
12 changes: 12 additions & 0 deletions src/test/rustdoc/src-links-auto-impls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![crate_name = "foo"]

// @has foo/struct.Unsized.html
// @has - '//h3[@id="impl-Sized"]/code' 'impl !Sized for Unsized'
// @!has - '//h3[@id="impl-Sized"]/a[@class="srclink"]' '[src]'
// @has - '//h3[@id="impl-Sync"]/code' 'impl Sync for Unsized'
// @!has - '//h3[@id="impl-Sync"]/a[@class="srclink"]' '[src]'
// @has - '//h3[@id="impl-Any"]/code' 'impl<T> Any for T'
// @has - '//h3[@id="impl-Any"]/a[@class="srclink"]' '[src]'
pub struct Unsized {
data: [u8],
}
9 changes: 9 additions & 0 deletions src/test/ui/suggestions/auxiliary/issue-81839.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// edition:2018

pub struct Test {}

impl Test {
pub async fn answer_str(&self, _s: &str) -> Test {
Test {}
}
}
17 changes: 17 additions & 0 deletions src/test/ui/suggestions/issue-81839.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// aux-build:issue-81839.rs
// edition:2018

extern crate issue_81839;

async fn test(ans: &str, num: i32, cx: &issue_81839::Test) -> u32 {
match num {
1 => {
cx.answer_str("hi");
}
_ => cx.answer_str("hi"), //~ `match` arms have incompatible types
}

1
}

fn main() {}
27 changes: 27 additions & 0 deletions src/test/ui/suggestions/issue-81839.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/issue-81839.rs:11:14
|
LL | / match num {
LL | | 1 => {
LL | | cx.answer_str("hi");
| | --------------------
| | | |
| | | help: consider removing this semicolon
| | this is found to be of type `()`
LL | | }
LL | | _ => cx.answer_str("hi"),
| | ^^^^^^^^^^^^^^^^^^^ expected `()`, found opaque type
LL | | }
| |_____- `match` arms have incompatible types
|
::: $DIR/auxiliary/issue-81839.rs:6:49
|
LL | pub async fn answer_str(&self, _s: &str) -> Test {
| ---- the `Output` of this `async fn`'s found opaque type
|
= note: expected type `()`
found opaque type `impl Future`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
9 changes: 3 additions & 6 deletions src/test/ui/suggestions/match-prev-arm-needing-semi.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ help: consider `await`ing on the `Future`
|
LL | false => async_dummy().await,
| ^^^^^^
help: consider removing this semicolon and boxing the expressions
|
LL | Box::new(async_dummy())
LL |
LL | }
LL | false => Box::new(async_dummy()),
help: consider removing this semicolon
|
LL | async_dummy()
| --

error[E0308]: `match` arms have incompatible types
--> $DIR/match-prev-arm-needing-semi.rs:39:18
Expand Down