Skip to content

Commit 12c5b1e

Browse files
committed
Auto merge of #99586 - ehuss:beta-backports, r=ehuss
[beta] Beta 1.63 backports * Reference: Revert $$ macro_metavar rust-lang/reference#1192 * Revert "Stabilize $$ in Rust 1.63.0" #99435 * rustdoc: avoid inlining items with duplicate `(type, name)` #99344 * Do not call `check_expr` twice in `check_compatible` #99397
2 parents efd3583 + 3c1ef01 commit 12c5b1e

File tree

17 files changed

+216
-47
lines changed

17 files changed

+216
-47
lines changed

compiler/rustc_expand/src/mbe/quoted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ fn parse_tree(
234234
sess,
235235
&Token { kind: token::Dollar, span },
236236
);
237+
} else {
238+
maybe_emit_macro_metavar_expr_feature(features, sess, span);
237239
}
238240
TokenTree::token(token::Dollar, span)
239241
}

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
303303

304304
let provided_arg: &hir::Expr<'tcx> = &provided_args[input_idx];
305305
let expectation = Expectation::rvalue_hint(self, expected_input_ty);
306-
// FIXME: check that this is safe; I don't believe this commits any of the obligations, but I can't be sure.
307-
//
308-
// I had another method of "soft" type checking before,
309-
// but it was failing to find the type of some expressions (like "")
310-
// so I prodded this method and made it pub(super) so I could call it, and it seems to work well.
311-
let checked_ty = self.check_expr_kind(provided_arg, expectation);
306+
let already_checked_ty = self.typeck_results.borrow().expr_ty_adjusted_opt(provided_arg);
307+
let checked_ty = already_checked_ty.unwrap_or_else(|| self.check_expr(provided_arg));
312308

313309
let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty);
314310
let can_coerce = self.can_coerce(checked_ty, coerced_ty);

src/doc/reference

src/librustdoc/clean/mod.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,43 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> {
5757
.map(|(item, renamed)| clean_maybe_renamed_foreign_item(cx, item, *renamed)),
5858
);
5959
items.extend(self.mods.iter().map(|x| x.clean(cx)));
60-
items.extend(
61-
self.items
62-
.iter()
63-
.flat_map(|(item, renamed)| clean_maybe_renamed_item(cx, item, *renamed)),
64-
);
60+
61+
// Split up imports from all other items.
62+
//
63+
// This covers the case where somebody does an import which should pull in an item,
64+
// but there's already an item with the same namespace and same name. Rust gives
65+
// priority to the not-imported one, so we should, too.
66+
let mut inserted = FxHashSet::default();
67+
items.extend(self.items.iter().flat_map(|(item, renamed)| {
68+
// First, lower everything other than imports.
69+
if matches!(item.kind, hir::ItemKind::Use(..)) {
70+
return Vec::new();
71+
}
72+
let v = clean_maybe_renamed_item(cx, item, *renamed);
73+
for item in &v {
74+
if let Some(name) = item.name {
75+
inserted.insert((item.type_(), name));
76+
}
77+
}
78+
v
79+
}));
80+
items.extend(self.items.iter().flat_map(|(item, renamed)| {
81+
// Now we actually lower the imports, skipping everything else.
82+
if !matches!(item.kind, hir::ItemKind::Use(..)) {
83+
return Vec::new();
84+
}
85+
let mut v = clean_maybe_renamed_item(cx, item, *renamed);
86+
v.drain_filter(|item| {
87+
if let Some(name) = item.name {
88+
// If an item with the same type and name already exists,
89+
// it takes priority over the inlined stuff.
90+
!inserted.insert((item.type_(), name))
91+
} else {
92+
false
93+
}
94+
});
95+
v
96+
}));
6597

6698
// determine if we should display the inner contents or
6799
// the outer `mod` item for the source code.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
pub struct Option;
2+
impl Option {
3+
pub fn unwrap(self) {}
4+
}
5+
6+
mod macros {
7+
use crate::Option;
8+
/// [`Option::unwrap`]
9+
#[macro_export]
10+
macro_rules! print {
11+
() => ()
12+
}
13+
}
14+
15+
mod structs {
16+
use crate::Option;
17+
/// [`Option::unwrap`]
18+
pub struct Print;
19+
}
20+
pub use structs::Print;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// aux-build:issue-99221-aux.rs
2+
// build-aux-docs
3+
// ignore-cross-compile
4+
5+
#![crate_name = "foo"]
6+
7+
#[macro_use]
8+
extern crate issue_99221_aux;
9+
10+
pub use issue_99221_aux::*;
11+
12+
// @count foo/index.html '//a[@class="macro"]' 1
13+
14+
mod inner {
15+
#[macro_export]
16+
macro_rules! print {
17+
() => ()
18+
}
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// aux-build:issue-99221-aux.rs
2+
// build-aux-docs
3+
// ignore-cross-compile
4+
5+
#![crate_name = "foo"]
6+
7+
#[macro_use]
8+
extern crate issue_99221_aux;
9+
10+
pub use issue_99221_aux::*;
11+
12+
// @count foo/index.html '//a[@class="macro"]' 1
13+
14+
#[macro_export]
15+
macro_rules! print {
16+
() => ()
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// aux-build:issue-99221-aux.rs
2+
// build-aux-docs
3+
// ignore-cross-compile
4+
5+
#![crate_name = "foo"]
6+
7+
#[macro_use]
8+
extern crate issue_99221_aux;
9+
10+
pub use issue_99221_aux::*;
11+
12+
// @count foo/index.html '//a[@class="struct"][@title="foo::Print struct"]' 1
13+
14+
pub struct Print;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
(|_, ()| ())(if true {} else {return;});
3+
//~^ ERROR this function takes 2 arguments but 1 argument was supplied
4+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0057]: this function takes 2 arguments but 1 argument was supplied
2+
--> $DIR/issue-98894.rs:2:5
3+
|
4+
LL | (|_, ()| ())(if true {} else {return;});
5+
| ^^^^^^^^^^^^--------------------------- an argument of type `()` is missing
6+
|
7+
note: closure defined here
8+
--> $DIR/issue-98894.rs:2:6
9+
|
10+
LL | (|_, ()| ())(if true {} else {return;});
11+
| ^^^^^^^
12+
help: provide the argument
13+
|
14+
LL | (|_, ()| ())(if true {} else {return;}, ());
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0057`.

0 commit comments

Comments
 (0)