Skip to content

Commit 866335b

Browse files
committed
Auto merge of #86757 - JohnTitor:rollup-acevhz7, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #85504 (the foundation owns rust trademarks) - #85520 (Fix typo and improve documentation for E0632) - #86680 (Improve error for missing -Z with debugging option) - #86728 (Check node kind to avoid ICE in `check_expr_return()`) - #86740 (copy rust-lld as ld in dist) - #86746 (Fix rustdoc query type filter) - #86750 (Test cross-crate usage of `feature(const_trait_impl)`) - #86755 (alloc: `RawVec<T, A>::shrink` can be in `no_global_oom_handling`.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e6f450b + 9e007e7 commit 866335b

30 files changed

+258
-22
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,14 @@ See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and
272272
273273
## Trademark
274274
275-
The Rust programming language is an open source, community project governed
276-
by a core team. It is also sponsored by the Mozilla Foundation (“Mozilla”),
277-
which owns and protects the Rust and Cargo trademarks and logos
278-
(the “Rust Trademarks”).
275+
[The Rust Foundation][rust-foundation] owns and protects the Rust and Cargo
276+
trademarks and logos (the “Rust Trademarks”).
279277
280278
If you want to use these names or brands, please read the [media guide][media-guide].
281279
282280
Third-party logos may be subject to third-party copyrights and trademarks. See
283281
[Licenses][policies-licenses] for details.
284282
283+
[rust-foundation]: https://foundation.rust-lang.org/
285284
[media-guide]: https://www.rust-lang.org/policies/media-guide
286285
[policies-licenses]: https://www.rust-lang.org/policies/licenses

compiler/rustc_driver/src/lib.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_middle::middle::cstore::MetadataLoader;
2929
use rustc_save_analysis as save;
3030
use rustc_save_analysis::DumpHandler;
3131
use rustc_serialize::json::{self, ToJson};
32-
use rustc_session::config::nightly_options;
32+
use rustc_session::config::{nightly_options, CG_OPTIONS, DB_OPTIONS};
3333
use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest, TrimmedDefPaths};
3434
use rustc_session::getopts;
3535
use rustc_session::lint::{Lint, LintId};
@@ -1010,9 +1010,18 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10101010
for option in config::rustc_optgroups() {
10111011
(option.apply)(&mut options);
10121012
}
1013-
let matches = options
1014-
.parse(args)
1015-
.unwrap_or_else(|f| early_error(ErrorOutputType::default(), &f.to_string()));
1013+
let matches = options.parse(args).unwrap_or_else(|e| {
1014+
let msg = match e {
1015+
getopts::Fail::UnrecognizedOption(ref opt) => CG_OPTIONS
1016+
.iter()
1017+
.map(|&(name, ..)| ('C', name))
1018+
.chain(DB_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
1019+
.find(|&(_, name)| *opt == name.replace("_", "-"))
1020+
.map(|(flag, _)| format!("{}. Did you mean `-{} {}`?", e, flag, opt)),
1021+
_ => None,
1022+
};
1023+
early_error(ErrorOutputType::default(), &msg.unwrap_or_else(|| e.to_string()));
1024+
});
10161025

10171026
// For all options we just parsed, we check a few aspects:
10181027
//

compiler/rustc_error_codes/src/error_codes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ E0626: include_str!("./error_codes/E0626.md"),
361361
E0627: include_str!("./error_codes/E0627.md"),
362362
E0628: include_str!("./error_codes/E0628.md"),
363363
E0631: include_str!("./error_codes/E0631.md"),
364+
E0632: include_str!("./error_codes/E0632.md"),
364365
E0633: include_str!("./error_codes/E0633.md"),
365366
E0634: include_str!("./error_codes/E0634.md"),
366367
E0635: include_str!("./error_codes/E0635.md"),
@@ -623,8 +624,6 @@ E0783: include_str!("./error_codes/E0783.md"),
623624
// E0629, // missing 'feature' (rustc_const_unstable)
624625
// E0630, // rustc_const_unstable attribute must be paired with stable/unstable
625626
// attribute
626-
E0632, // cannot provide explicit generic arguments when `impl Trait` is
627-
// used in argument position
628627
E0640, // infer outlives requirements
629628
// E0645, // trait aliases not finished
630629
E0667, // `impl Trait` in projections
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
An explicit generic argument was provided when calling a function that
2+
uses `impl Trait` in argument position.
3+
4+
Erroneous code example:
5+
6+
```compile_fail,E0632
7+
fn foo<T: Copy>(a: T, b: impl Clone) {}
8+
9+
foo::<i32>(0i32, "abc".to_string());
10+
```
11+
12+
Either all generic arguments should be inferred at the call site, or
13+
the function definition should use an explicit generic type parameter
14+
instead of `impl Trait`. Example:
15+
16+
```
17+
fn foo<T: Copy>(a: T, b: impl Clone) {}
18+
fn bar<T: Copy, U: Clone>(a: T, b: U) {}
19+
20+
foo(0i32, "abc".to_string());
21+
22+
bar::<i32, String>(0i32, "abc".to_string());
23+
bar::<_, _>(0i32, "abc".to_string());
24+
bar(0i32, "abc".to_string());
25+
```

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ declare_lint! {
10841084
///
10851085
/// ### Explanation
10861086
///
1087-
/// An function with generics must have its symbol mangled to accommodate
1087+
/// A function with generics must have its symbol mangled to accommodate
10881088
/// the generic parameter. The [`no_mangle` attribute] has no effect in
10891089
/// this situation, and should be removed.
10901090
///

compiler/rustc_metadata/src/rmeta/encoder.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,12 @@ impl EncodeContext<'a, 'tcx> {
12231223
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
12241224
FnData {
12251225
asyncness: sig.header.asyncness,
1226-
constness: sig.header.constness,
1226+
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
1227+
constness: if self.tcx.is_const_fn_raw(def_id) {
1228+
hir::Constness::Const
1229+
} else {
1230+
hir::Constness::NotConst
1231+
},
12271232
param_names: self.encode_fn_param_names_for_body(body),
12281233
}
12291234
} else {

compiler/rustc_typeck/src/check/expr.rs

+17-3
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
682682
};
683683

684684
let encl_item_id = self.tcx.hir().get_parent_item(expr.hir_id);
685-
let encl_item = self.tcx.hir().expect_item(encl_item_id);
686685

687-
if let hir::ItemKind::Fn(..) = encl_item.kind {
686+
if let Some(hir::Node::Item(hir::Item {
687+
kind: hir::ItemKind::Fn(..),
688+
span: encl_fn_span,
689+
..
690+
}))
691+
| Some(hir::Node::TraitItem(hir::TraitItem {
692+
kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)),
693+
span: encl_fn_span,
694+
..
695+
}))
696+
| Some(hir::Node::ImplItem(hir::ImplItem {
697+
kind: hir::ImplItemKind::Fn(..),
698+
span: encl_fn_span,
699+
..
700+
})) = self.tcx.hir().find(encl_item_id)
701+
{
688702
// We are inside a function body, so reporting "return statement
689703
// outside of function body" needs an explanation.
690704

@@ -698,7 +712,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
698712
let encl_body = self.tcx.hir().body(encl_body_id);
699713

700714
err.encl_body_span = Some(encl_body.value.span);
701-
err.encl_fn_span = Some(encl_item.span);
715+
err.encl_fn_span = Some(*encl_fn_span);
702716
}
703717

704718
self.tcx.sess.emit_err(err);

library/alloc/src/raw_vec.rs

-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ impl<T, A: Allocator> RawVec<T, A> {
463463
Ok(())
464464
}
465465

466-
#[cfg(not(no_global_oom_handling))]
467466
fn shrink(&mut self, amount: usize) -> Result<(), TryReserveError> {
468467
assert!(amount <= self.capacity(), "Tried to shrink to a larger capacity");
469468

src/bootstrap/dist.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ impl Step for Rustc {
400400

401401
// Copy over lld if it's there
402402
if builder.config.lld_enabled {
403-
let exe = exe("rust-lld", compiler.host);
404-
builder.copy(&src_dir.join(&exe), &dst_dir.join(&exe));
403+
let rust_lld = exe("rust-lld", compiler.host);
404+
builder.copy(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
405405
// for `-Z gcc-ld=lld`
406406
let gcc_lld_dir = dst_dir.join("gcc-ld");
407407
t!(fs::create_dir(&gcc_lld_dir));
408-
builder.copy(&src_dir.join(&exe), &gcc_lld_dir.join(&exe));
408+
builder.copy(&src_dir.join(&rust_lld), &gcc_lld_dir.join(exe("ld", compiler.host)));
409409
}
410410

411411
// Copy over llvm-dwp if it's there

src/librustdoc/html/static/search.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,8 @@ window.initSearch = function(rawSearchIndex) {
801801
results_returned[fullId].lev =
802802
Math.min(results_returned[fullId].lev, returned);
803803
}
804-
if (index !== -1 || lev <= MAX_LEV_DISTANCE) {
804+
if (typePassesFilter(typeFilter, ty.ty) &&
805+
(index !== -1 || lev <= MAX_LEV_DISTANCE)) {
805806
if (index !== -1 && paths.length < 2) {
806807
lev = 0;
807808
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// exact-check
2+
3+
const QUERY = 'macro:print';
4+
5+
const EXPECTED = {
6+
'others': [
7+
{ 'path': 'std', 'name': 'print' },
8+
{ 'path': 'std', 'name': 'eprint' },
9+
{ 'path': 'std', 'name': 'println' },
10+
{ 'path': 'std', 'name': 'eprintln' },
11+
],
12+
};

src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | assert_eq!(f::<4usize>(Usizable), 20usize);
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0632`.

src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | assert_eq!(f::<4usize>(Usizable), 20usize);
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0632`.

src/test/ui/impl-trait/issues/universal-issue-48703.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | foo::<String>('a');
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0632`.

src/test/ui/impl-trait/issues/universal-turbofish-in-method-issue-50950.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ LL | evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
88

99
error: aborting due to previous error
1010

11+
For more information about this error, try `rustc --explain E0632`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// compile-flags: --llvm-args
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: Unrecognized option: 'llvm-args'. Did you mean `-C llvm-args`?
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// compile-flags: --unpretty=hir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: Unrecognized option: 'unpretty'. Did you mean `-Z unpretty`?
2+

src/test/ui/return/issue-86188-return-not-in-fn-body.rs

+19
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ const C: [(); 42] = {
1212
}]
1313
};
1414

15+
struct S {}
16+
trait Tr {
17+
fn foo();
18+
fn bar() {
19+
//~^ NOTE: ...not the enclosing function body
20+
[(); return];
21+
//~^ ERROR: return statement outside of function body [E0572]
22+
//~| NOTE: the return is part of this body...
23+
}
24+
}
25+
impl Tr for S {
26+
fn foo() {
27+
//~^ NOTE: ...not the enclosing function body
28+
[(); return];
29+
//~^ ERROR: return statement outside of function body [E0572]
30+
//~| NOTE: the return is part of this body...
31+
}
32+
}
33+
1534
fn main() {
1635
//~^ NOTE: ...not the enclosing function body
1736
[(); return || {

src/test/ui/return/issue-86188-return-not-in-fn-body.stderr

+26-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,31 @@ LL | | }]
99
| |_____^
1010

1111
error[E0572]: return statement outside of function body
12-
--> $DIR/issue-86188-return-not-in-fn-body.rs:17:10
12+
--> $DIR/issue-86188-return-not-in-fn-body.rs:20:14
13+
|
14+
LL | / fn bar() {
15+
LL | |
16+
LL | | [(); return];
17+
| | ^^^^^^ the return is part of this body...
18+
LL | |
19+
LL | |
20+
LL | | }
21+
| |_____- ...not the enclosing function body
22+
23+
error[E0572]: return statement outside of function body
24+
--> $DIR/issue-86188-return-not-in-fn-body.rs:28:14
25+
|
26+
LL | / fn foo() {
27+
LL | |
28+
LL | | [(); return];
29+
| | ^^^^^^ the return is part of this body...
30+
LL | |
31+
LL | |
32+
LL | | }
33+
| |_____- ...not the enclosing function body
34+
35+
error[E0572]: return statement outside of function body
36+
--> $DIR/issue-86188-return-not-in-fn-body.rs:36:10
1337
|
1438
LL | / fn main() {
1539
LL | |
@@ -23,6 +47,6 @@ LL | || }];
2347
LL | | }
2448
| |_- ...not the enclosing function body
2549

26-
error: aborting due to 2 previous errors
50+
error: aborting due to 4 previous errors
2751

2852
For more information about this error, try `rustc --explain E0572`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![feature(const_trait_impl)]
2+
#![allow(incomplete_features)]
3+
4+
pub trait MyTrait {
5+
fn func(self);
6+
}
7+
8+
pub struct NonConst;
9+
10+
impl MyTrait for NonConst {
11+
fn func(self) {
12+
13+
}
14+
}
15+
16+
pub struct Const;
17+
18+
impl const MyTrait for Const {
19+
fn func(self) {
20+
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// aux-build: cross-crate.rs
2+
extern crate cross_crate;
3+
4+
use cross_crate::*;
5+
6+
fn non_const_context() {
7+
NonConst.func();
8+
Const.func();
9+
}
10+
11+
const fn const_context() {
12+
NonConst.func();
13+
//~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
14+
Const.func();
15+
//~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
2+
--> $DIR/cross-crate-feature-disabled.rs:12:5
3+
|
4+
LL | NonConst.func();
5+
| ^^^^^^^^^^^^^^^
6+
7+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
8+
--> $DIR/cross-crate-feature-disabled.rs:14:5
9+
|
10+
LL | Const.func();
11+
| ^^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0015`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![feature(const_trait_impl)]
2+
#![allow(incomplete_features)]
3+
4+
// aux-build: cross-crate.rs
5+
extern crate cross_crate;
6+
7+
use cross_crate::*;
8+
9+
fn non_const_context() {
10+
NonConst.func();
11+
Const.func();
12+
}
13+
14+
const fn const_context() {
15+
NonConst.func();
16+
//~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
17+
Const.func();
18+
}
19+
20+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
2+
--> $DIR/cross-crate-feature-enabled.rs:15:5
3+
|
4+
LL | NonConst.func();
5+
| ^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0015`.

src/test/ui/synthetic-param.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ LL | Bar::<i8>::func::<u8>(42);
1818

1919
error: aborting due to 3 previous errors
2020

21+
For more information about this error, try `rustc --explain E0632`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0572]: return statement outside of function body
2+
--> $DIR/issue-86721-return-expr-ice.rs:9:22
3+
|
4+
LL | const U: usize = return;
5+
| ^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0572`.

0 commit comments

Comments
 (0)