mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Auto merge of #82341 - GuillaumeGomez:rollup-t7y7tyg, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #80595 (`impl PartialEq<Punct> for char`; symmetry for #78636) - #81991 (Fix panic in 'remove semicolon' when types are not local) - #82176 (fix MIR fn-ptr pretty-printing) - #82244 (Keep consistency in example for Stdin StdinLock) - #82260 (rustc: Show ``@path`` usage in stable) - #82316 (Fix minor mistake in LTO docs.) - #82332 (Don't generate src link on dummy spans) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
d2b38d6b3c
@ -812,7 +812,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 {
|
||||
""
|
||||
|
@ -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| {
|
||||
@ -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 => {
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
|
@ -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")]
|
||||
|
@ -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(())
|
||||
/// }
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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());
|
||||
|
12
src/test/rustdoc/src-links-auto-impls.rs
Normal file
12
src/test/rustdoc/src-links-auto-impls.rs
Normal file
@ -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
src/test/ui/suggestions/auxiliary/issue-81839.rs
Normal file
9
src/test/ui/suggestions/auxiliary/issue-81839.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// edition:2018
|
||||
|
||||
pub struct Test {}
|
||||
|
||||
impl Test {
|
||||
pub async fn answer_str(&self, _s: &str) -> Test {
|
||||
Test {}
|
||||
}
|
||||
}
|
17
src/test/ui/suggestions/issue-81839.rs
Normal file
17
src/test/ui/suggestions/issue-81839.rs
Normal file
@ -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
src/test/ui/suggestions/issue-81839.stderr
Normal file
27
src/test/ui/suggestions/issue-81839.stderr
Normal file
@ -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`.
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user