Skip to content

Commit

Permalink
Auto merge of rust-lang#99586 - ehuss:beta-backports, r=ehuss
Browse files Browse the repository at this point in the history
[beta] Beta 1.63 backports

* Reference: Revert $$ macro_metavar rust-lang/reference#1192
* Revert "Stabilize $$ in Rust 1.63.0" rust-lang#99435
* rustdoc: avoid inlining items with duplicate `(type, name)` rust-lang#99344
* Do not call `check_expr` twice in `check_compatible` rust-lang#99397
  • Loading branch information
bors committed Jul 22, 2022
2 parents efd3583 + 3c1ef01 commit 12c5b1e
Show file tree
Hide file tree
Showing 17 changed files with 216 additions and 47 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ fn parse_tree(
sess,
&Token { kind: token::Dollar, span },
);
} else {
maybe_emit_macro_metavar_expr_feature(features, sess, span);
}
TokenTree::token(token::Dollar, span)
}
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

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

let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty);
let can_coerce = self.can_coerce(checked_ty, coerced_ty);
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference
42 changes: 37 additions & 5 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,43 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> {
.map(|(item, renamed)| clean_maybe_renamed_foreign_item(cx, item, *renamed)),
);
items.extend(self.mods.iter().map(|x| x.clean(cx)));
items.extend(
self.items
.iter()
.flat_map(|(item, renamed)| clean_maybe_renamed_item(cx, item, *renamed)),
);

// Split up imports from all other items.
//
// This covers the case where somebody does an import which should pull in an item,
// but there's already an item with the same namespace and same name. Rust gives
// priority to the not-imported one, so we should, too.
let mut inserted = FxHashSet::default();
items.extend(self.items.iter().flat_map(|(item, renamed)| {
// First, lower everything other than imports.
if matches!(item.kind, hir::ItemKind::Use(..)) {
return Vec::new();
}
let v = clean_maybe_renamed_item(cx, item, *renamed);
for item in &v {
if let Some(name) = item.name {
inserted.insert((item.type_(), name));
}
}
v
}));
items.extend(self.items.iter().flat_map(|(item, renamed)| {
// Now we actually lower the imports, skipping everything else.
if !matches!(item.kind, hir::ItemKind::Use(..)) {
return Vec::new();
}
let mut v = clean_maybe_renamed_item(cx, item, *renamed);
v.drain_filter(|item| {
if let Some(name) = item.name {
// If an item with the same type and name already exists,
// it takes priority over the inlined stuff.
!inserted.insert((item.type_(), name))
} else {
false
}
});
v
}));

// determine if we should display the inner contents or
// the outer `mod` item for the source code.
Expand Down
20 changes: 20 additions & 0 deletions src/test/rustdoc/auxiliary/issue-99221-aux.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pub struct Option;
impl Option {
pub fn unwrap(self) {}
}

mod macros {
use crate::Option;
/// [`Option::unwrap`]
#[macro_export]
macro_rules! print {
() => ()
}
}

mod structs {
use crate::Option;
/// [`Option::unwrap`]
pub struct Print;
}
pub use structs::Print;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// aux-build:issue-99221-aux.rs
// build-aux-docs
// ignore-cross-compile

#![crate_name = "foo"]

#[macro_use]
extern crate issue_99221_aux;

pub use issue_99221_aux::*;

// @count foo/index.html '//a[@class="macro"]' 1

mod inner {
#[macro_export]
macro_rules! print {
() => ()
}
}
17 changes: 17 additions & 0 deletions src/test/rustdoc/issue-99221-multiple-macro-rules-w-same-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// aux-build:issue-99221-aux.rs
// build-aux-docs
// ignore-cross-compile

#![crate_name = "foo"]

#[macro_use]
extern crate issue_99221_aux;

pub use issue_99221_aux::*;

// @count foo/index.html '//a[@class="macro"]' 1

#[macro_export]
macro_rules! print {
() => ()
}
14 changes: 14 additions & 0 deletions src/test/rustdoc/issue-99221-multiple-structs-w-same-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// aux-build:issue-99221-aux.rs
// build-aux-docs
// ignore-cross-compile

#![crate_name = "foo"]

#[macro_use]
extern crate issue_99221_aux;

pub use issue_99221_aux::*;

// @count foo/index.html '//a[@class="struct"][@title="foo::Print struct"]' 1

pub struct Print;
4 changes: 4 additions & 0 deletions src/test/ui/argument-suggestions/issue-98894.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
(|_, ()| ())(if true {} else {return;});
//~^ ERROR this function takes 2 arguments but 1 argument was supplied
}
19 changes: 19 additions & 0 deletions src/test/ui/argument-suggestions/issue-98894.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0057]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/issue-98894.rs:2:5
|
LL | (|_, ()| ())(if true {} else {return;});
| ^^^^^^^^^^^^--------------------------- an argument of type `()` is missing
|
note: closure defined here
--> $DIR/issue-98894.rs:2:6
|
LL | (|_, ()| ())(if true {} else {return;});
| ^^^^^^^
help: provide the argument
|
LL | (|_, ()| ())(if true {} else {return;}, ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to previous error

For more information about this error, try `rustc --explain E0057`.
4 changes: 4 additions & 0 deletions src/test/ui/argument-suggestions/issue-98897.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
(|_, ()| ())([return, ()]);
//~^ ERROR this function takes 2 arguments but 1 argument was supplied
}
19 changes: 19 additions & 0 deletions src/test/ui/argument-suggestions/issue-98897.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0057]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/issue-98897.rs:2:5
|
LL | (|_, ()| ())([return, ()]);
| ^^^^^^^^^^^^-------------- an argument of type `()` is missing
|
note: closure defined here
--> $DIR/issue-98897.rs:2:6
|
LL | (|_, ()| ())([return, ()]);
| ^^^^^^^
help: provide the argument
|
LL | (|_, ()| ())([return, ()], ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to previous error

For more information about this error, try `rustc --explain E0057`.
3 changes: 1 addition & 2 deletions src/test/ui/issues/issue-3044.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ fn main() {
let needlesArr: Vec<char> = vec!['a', 'f'];
needlesArr.iter().fold(|x, y| {
});
//~^^ ERROR mismatched types
//~| ERROR this function takes 2 arguments but 1 argument was supplied
//~^^ ERROR this function takes 2 arguments but 1 argument was supplied
}
16 changes: 2 additions & 14 deletions src/test/ui/issues/issue-3044.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
error[E0308]: mismatched types
--> $DIR/issue-3044.rs:3:35
|
LL | needlesArr.iter().fold(|x, y| {
| ___________________________________^
LL | | });
| |_____^ expected closure, found `()`
|
= note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 4:6]`
found unit type `()`

error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/issue-3044.rs:3:23
|
Expand All @@ -28,7 +17,6 @@ LL ~ needlesArr.iter().fold(|x, y| {
LL ~ }, /* value */);
|

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0061, E0308.
For more information about an error, try `rustc --explain E0061`.
For more information about this error, try `rustc --explain E0061`.
12 changes: 0 additions & 12 deletions src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ macro_rules! count {
};
}

macro_rules! dollar_dollar {
() => {
macro_rules! bar {
( $$( $$any:tt )* ) => { $$( $$any )* };
//~^ ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
}
};
}

macro_rules! index {
( $( $e:stmt ),* ) => {
$( ${ignore(e)} ${index()} )*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: meta-variable expressions are unstable
--> $DIR/required-features.rs:3:10
--> $DIR/required-feature.rs:3:10
|
LL | ${ count(e) }
| ^^^^^^^^^^^^
Expand All @@ -8,7 +8,43 @@ LL | ${ count(e) }
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-features.rs:10:13
--> $DIR/required-feature.rs:11:16
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:20
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:39
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:43
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:22:13
|
LL | $( ${ignore(e)} ${index()} )*
| ^^^^^^^^^^^
Expand All @@ -17,7 +53,7 @@ LL | $( ${ignore(e)} ${index()} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-features.rs:10:26
--> $DIR/required-feature.rs:22:26
|
LL | $( ${ignore(e)} ${index()} )*
| ^^^^^^^^^
Expand All @@ -26,7 +62,7 @@ LL | $( ${ignore(e)} ${index()} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-features.rs:18:19
--> $DIR/required-feature.rs:30:19
|
LL | 0 $( + 1 ${ignore(i)} )*
| ^^^^^^^^^^^
Expand All @@ -35,7 +71,7 @@ LL | 0 $( + 1 ${ignore(i)} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-features.rs:25:13
--> $DIR/required-feature.rs:37:13
|
LL | $( ${ignore(e)} ${length()} )*
| ^^^^^^^^^^^
Expand All @@ -44,14 +80,14 @@ LL | $( ${ignore(e)} ${length()} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-features.rs:25:26
--> $DIR/required-feature.rs:37:26
|
LL | $( ${ignore(e)} ${length()} )*
| ^^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error: aborting due to 6 previous errors
error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0658`.

0 comments on commit 12c5b1e

Please sign in to comment.