Skip to content

Commit 770b9e3

Browse files
committed
Auto merge of #65644 - Centril:rollup-gez1xhe, r=Centril
Rollup of 8 pull requests Successful merges: - #65314 (rustdoc: forward -Z options to rustc) - #65592 (clarify const_prop ICE protection comment) - #65603 (Avoid ICE when include! is used by stdin crate) - #65614 (Improve error message for APIT with explicit generic arguments) - #65629 (Remove `borrowck_graphviz_postflow` from test) - #65633 (Remove leading :: from paths in doc examples) - #65638 (Rename the default argument 'def' to 'default') - #65639 (Fix parameter name in documentation) Failed merges: r? @ghost
2 parents 7979016 + 836e45d commit 770b9e3

27 files changed

+124
-68
lines changed

src/libcore/iter/traits/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub trait FromIterator<A>: Sized {
167167
/// // and we'll implement IntoIterator
168168
/// impl IntoIterator for MyCollection {
169169
/// type Item = i32;
170-
/// type IntoIter = ::std::vec::IntoIter<Self::Item>;
170+
/// type IntoIter = std::vec::IntoIter<Self::Item>;
171171
///
172172
/// fn into_iter(self) -> Self::IntoIter {
173173
/// self.0.into_iter()

src/libcore/ops/unsize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
7676
/// ```
7777
/// # #![feature(dispatch_from_dyn, unsize)]
7878
/// # use std::{ops::DispatchFromDyn, marker::Unsize};
79-
/// # struct Rc<T: ?Sized>(::std::rc::Rc<T>);
79+
/// # struct Rc<T: ?Sized>(std::rc::Rc<T>);
8080
/// impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Rc<U>> for Rc<T>
8181
/// where
8282
/// T: Unsize<U>,

src/libcore/option.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ impl<T> Option<T> {
395395
/// ```
396396
#[inline]
397397
#[stable(feature = "rust1", since = "1.0.0")]
398-
pub fn unwrap_or(self, def: T) -> T {
398+
pub fn unwrap_or(self, default: T) -> T {
399399
match self {
400400
Some(x) => x,
401-
None => def,
401+
None => default,
402402
}
403403
}
404404

src/libcore/str/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ Section: Creating a string
176176
/// ```
177177
/// fn from_utf8_lossy<F>(mut input: &[u8], mut push: F) where F: FnMut(&str) {
178178
/// loop {
179-
/// match ::std::str::from_utf8(input) {
179+
/// match std::str::from_utf8(input) {
180180
/// Ok(valid) => {
181181
/// push(valid);
182182
/// break
183183
/// }
184184
/// Err(error) => {
185185
/// let (valid, after_valid) = input.split_at(error.valid_up_to());
186186
/// unsafe {
187-
/// push(::std::str::from_utf8_unchecked(valid))
187+
/// push(std::str::from_utf8_unchecked(valid))
188188
/// }
189189
/// push("\u{FFFD}");
190190
///

src/librustc_mir/transform/const_prop.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -518,27 +518,30 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
518518
}
519519
}
520520

521-
// Work around: avoid ICE in miri.
522-
// FIXME(wesleywiser) we don't currently handle the case where we try to make a ref
523-
// from a function argument that hasn't been assigned to in this function. The main
524-
// issue is if an arg is a fat-pointer, miri `expects()` to be able to read the value
525-
// of that pointer to get size info. However, since this is `ConstProp`, that argument
526-
// doesn't actually have a backing value and so this causes an ICE.
521+
// Work around: avoid ICE in miri. FIXME(wesleywiser)
522+
// The Miri engine ICEs when taking a reference to an uninitialized unsized
523+
// local. There's nothing it can do here: taking a reference needs an allocation
524+
// which needs to know the size. Normally that's okay as during execution
525+
// (e.g. for CTFE) it can never happen. But here in const_prop
526+
// unknown data is uninitialized, so if e.g. a function argument is unsized
527+
// and has a reference taken, we get an ICE.
527528
Rvalue::Ref(_, _, Place { base: PlaceBase::Local(local), projection: box [] }) => {
528529
trace!("checking Ref({:?})", place);
529530
let alive =
530531
if let LocalValue::Live(_) = self.ecx.frame().locals[*local].value {
531532
true
532-
} else { false };
533+
} else {
534+
false
535+
};
533536

534-
if local.as_usize() <= self.ecx.frame().body.arg_count && !alive {
535-
trace!("skipping Ref({:?})", place);
537+
if !alive {
538+
trace!("skipping Ref({:?}) to uninitialized local", place);
536539
return None;
537540
}
538541
}
539542

540-
// Work around: avoid extra unnecessary locals.
541-
// FIXME(wesleywiser): const eval will turn this into a `const Scalar(<ZST>)` that
543+
// Work around: avoid extra unnecessary locals. FIXME(wesleywiser)
544+
// Const eval will turn this into a `const Scalar(<ZST>)` that
542545
// `SimplifyLocals` doesn't know it can remove.
543546
Rvalue::Aggregate(_, operands) if operands.len() == 0 => {
544547
return None;

src/librustc_typeck/astconv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
232232
tcx.sess,
233233
span,
234234
E0632,
235-
"cannot provide explicit type parameters when `impl Trait` is \
236-
used in argument position."
235+
"cannot provide explicit generic arguments when `impl Trait` is \
236+
used in argument position"
237237
};
238238

239239
err.emit();

src/librustc_typeck/error_codes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5048,8 +5048,8 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
50485048
// E0612, // merged into E0609
50495049
// E0613, // Removed (merged with E0609)
50505050
E0627, // yield statement outside of generator literal
5051-
E0632, // cannot provide explicit type parameters when `impl Trait` is used
5052-
// in argument position.
5051+
E0632, // cannot provide explicit generic arguments when `impl Trait` is
5052+
// used in argument position
50535053
E0634, // type has conflicting packed representaton hints
50545054
E0640, // infer outlives requirements
50555055
E0641, // cannot cast to/from a pointer with an unknown kind

src/librustdoc/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub struct Options {
5353
pub codegen_options_strs: Vec<String>,
5454
/// Debugging (`-Z`) options to pass to the compiler.
5555
pub debugging_options: DebuggingOptions,
56+
/// Debugging (`-Z`) options strings to pass to the compiler.
57+
pub debugging_options_strs: Vec<String>,
5658
/// The target used to compile the crate against.
5759
pub target: TargetTriple,
5860
/// Edition used when reading the crate. Defaults to "2015". Also used by default when
@@ -478,6 +480,7 @@ impl Options {
478480
let generate_redirect_pages = matches.opt_present("generate-redirect-pages");
479481
let test_builder = matches.opt_str("test-builder").map(PathBuf::from);
480482
let codegen_options_strs = matches.opt_strs("C");
483+
let debugging_options_strs = matches.opt_strs("Z");
481484
let lib_strs = matches.opt_strs("L");
482485
let extern_strs = matches.opt_strs("extern");
483486
let runtool = matches.opt_str("runtool");
@@ -499,6 +502,7 @@ impl Options {
499502
codegen_options,
500503
codegen_options_strs,
501504
debugging_options,
505+
debugging_options_strs,
502506
target,
503507
edition,
504508
maybe_sysroot,

src/librustdoc/test.rs

+3
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ fn run_test(
280280
for codegen_options_str in &options.codegen_options_strs {
281281
compiler.arg("-C").arg(&codegen_options_str);
282282
}
283+
for debugging_option_str in &options.debugging_options_strs {
284+
compiler.arg("-Z").arg(&debugging_option_str);
285+
}
283286
if no_run {
284287
compiler.arg("--emit=metadata");
285288
}

src/libstd/io/stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ pub fn set_print(sink: Option<Box<dyn Write + Send>>) -> Option<Box<dyn Write +
762762
/// otherwise. `label` identifies the stream in a panic message.
763763
///
764764
/// This function is used to print error messages, so it takes extra
765-
/// care to avoid causing a panic when `local_stream` is unusable.
765+
/// care to avoid causing a panic when `local_s` is unusable.
766766
/// For instance, if the TLS key for the local stream is
767767
/// already destroyed, or if the local stream is locked by another
768768
/// thread, it will just fall back to the global stream.

src/libstd/net/udp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl UdpSocket {
202202
///
203203
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
204204
/// assert_eq!(socket.peer_addr().unwrap_err().kind(),
205-
/// ::std::io::ErrorKind::NotConnected);
205+
/// std::io::ErrorKind::NotConnected);
206206
/// ```
207207
#[stable(feature = "udp_peer_addr", since = "1.40.0")]
208208
pub fn peer_addr(&self) -> io::Result<SocketAddr> {

src/libstd/process.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1488,12 +1488,12 @@ impl Child {
14881488
/// }
14891489
///
14901490
/// fn main() {
1491-
/// ::std::process::exit(match run_app() {
1492-
/// Ok(_) => 0,
1493-
/// Err(err) => {
1494-
/// eprintln!("error: {:?}", err);
1495-
/// 1
1496-
/// }
1491+
/// std::process::exit(match run_app() {
1492+
/// Ok(_) => 0,
1493+
/// Err(err) => {
1494+
/// eprintln!("error: {:?}", err);
1495+
/// 1
1496+
/// }
14971497
/// });
14981498
/// }
14991499
/// ```

src/libsyntax_expand/base.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,11 @@ impl<'a> ExtCtxt<'a> {
10721072
/// This unifies the logic used for resolving `include_X!`, and `#[doc(include)]` file paths.
10731073
///
10741074
/// Returns an absolute path to the file that `path` refers to.
1075-
pub fn resolve_path(&self, path: impl Into<PathBuf>, span: Span) -> PathBuf {
1075+
pub fn resolve_path(
1076+
&self,
1077+
path: impl Into<PathBuf>,
1078+
span: Span,
1079+
) -> Result<PathBuf, DiagnosticBuilder<'a>> {
10761080
let path = path.into();
10771081

10781082
// Relative paths are resolved relative to the file in which they are found
@@ -1082,13 +1086,16 @@ impl<'a> ExtCtxt<'a> {
10821086
let mut result = match self.source_map().span_to_unmapped_path(callsite) {
10831087
FileName::Real(path) => path,
10841088
FileName::DocTest(path, _) => path,
1085-
other => panic!("cannot resolve relative path in non-file source `{}`", other),
1089+
other => return Err(self.struct_span_err(
1090+
span,
1091+
&format!("cannot resolve relative path in non-file source `{}`", other),
1092+
)),
10861093
};
10871094
result.pop();
10881095
result.push(path);
1089-
result
1096+
Ok(result)
10901097
} else {
1091-
path
1098+
Ok(path)
10921099
}
10931100
}
10941101
}

src/libsyntax_expand/expand.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14181418
return noop_visit_attribute(at, self);
14191419
}
14201420

1421-
let filename = self.cx.resolve_path(&*file.as_str(), it.span());
1421+
let filename = match self.cx.resolve_path(&*file.as_str(), it.span()) {
1422+
Ok(filename) => filename,
1423+
Err(mut err) => {
1424+
err.emit();
1425+
continue;
1426+
}
1427+
};
1428+
14221429
match self.cx.source_map().load_file(&filename) {
14231430
Ok(source_file) => {
14241431
let src = source_file.src.as_ref()

src/libsyntax_ext/source_util.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
7676
None => return DummyResult::any(sp),
7777
};
7878
// The file will be added to the code map by the parser
79-
let file = cx.resolve_path(file, sp);
79+
let file = match cx.resolve_path(file, sp) {
80+
Ok(f) => f,
81+
Err(mut err) => {
82+
err.emit();
83+
return DummyResult::any(sp);
84+
},
85+
};
8086
let directory_ownership = DirectoryOwnership::Owned { relative: None };
8187
let p = parse::new_sub_parser_from_file(cx.parse_sess(), &file, directory_ownership, None, sp);
8288

@@ -122,7 +128,13 @@ pub fn expand_include_str(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
122128
Some(f) => f,
123129
None => return DummyResult::any(sp)
124130
};
125-
let file = cx.resolve_path(file, sp);
131+
let file = match cx.resolve_path(file, sp) {
132+
Ok(f) => f,
133+
Err(mut err) => {
134+
err.emit();
135+
return DummyResult::any(sp);
136+
},
137+
};
126138
match cx.source_map().load_binary_file(&file) {
127139
Ok(bytes) => match std::str::from_utf8(&bytes) {
128140
Ok(src) => {
@@ -147,7 +159,13 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
147159
Some(f) => f,
148160
None => return DummyResult::any(sp)
149161
};
150-
let file = cx.resolve_path(file, sp);
162+
let file = match cx.resolve_path(file, sp) {
163+
Ok(f) => f,
164+
Err(mut err) => {
165+
err.emit();
166+
return DummyResult::any(sp);
167+
},
168+
};
151169
match cx.source_map().load_binary_file(&file) {
152170
Ok(bytes) => {
153171
base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::new(bytes))))

src/test/rustdoc-ui/failed-doctest-missing-codes.stdout

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ failures:
66

77
---- $DIR/failed-doctest-missing-codes.rs - Foo (line 8) stdout ----
88
error[E0308]: mismatched types
9-
--> $DIR/failed-doctest-missing-codes.rs:9:13
10-
|
11-
3 | let x: () = 5i32;
12-
| ^^^^ expected (), found i32
13-
|
14-
= note: expected type `()`
15-
found type `i32`
9+
--> $DIR/failed-doctest-missing-codes.rs:9:13
10+
|
11+
LL | let x: () = 5i32;
12+
| ^^^^ expected (), found i32
13+
|
14+
= note: expected type `()`
15+
found type `i32`
1616

1717
error: aborting due to previous error
1818

src/test/rustdoc-ui/failed-doctest-output.stdout

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ failures:
77

88
---- $DIR/failed-doctest-output.rs - OtherStruct (line 21) stdout ----
99
error[E0425]: cannot find value `no` in this scope
10-
--> $DIR/failed-doctest-output.rs:22:1
11-
|
12-
3 | no
13-
| ^^ not found in this scope
10+
--> $DIR/failed-doctest-output.rs:22:1
11+
|
12+
LL | no
13+
| ^^ not found in this scope
1414

1515
error: aborting due to previous error
1616

src/test/rustdoc-ui/unparseable-doc-test.stdout

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ failures:
66

77
---- $DIR/unparseable-doc-test.rs - foo (line 6) stdout ----
88
error: unterminated double quote string
9-
--> $DIR/unparseable-doc-test.rs:8:1
10-
|
11-
2 | "unterminated
12-
| ^^^^^^^^^^^^^
9+
--> $DIR/unparseable-doc-test.rs:8:1
10+
|
11+
LL | "unterminated
12+
| ^^^^^^^^^^^^^
1313

1414
error: aborting due to previous error
1515

src/test/rustdoc/sanitizer-option.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// needs-sanitizer-support
2+
// compile-flags: --test -Z sanitizer=address
3+
//
4+
// #43031: Verify that rustdoc passes `-Z` options to rustc. Use an extern
5+
// function that is provided by the sanitizer runtime, if flag is not passed
6+
// correctly, then linking will fail.
7+
8+
/// ```
9+
/// extern {
10+
/// fn __sanitizer_print_stack_trace();
11+
/// }
12+
///
13+
/// fn main() {
14+
/// unsafe { __sanitizer_print_stack_trace() };
15+
/// }
16+
/// ```
17+
pub fn z_flag_is_passed_to_rustc() {}

src/test/ui/consts/const-eval/issue-65394.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Test for absence of validation mismatch ICE in #65394
22

3-
#![feature(rustc_attrs)]
4-
5-
#[rustc_mir(borrowck_graphviz_postflow="hello.dot")]
63
const _: Vec<i32> = {
74
let mut x = Vec::<i32>::new();
85
let r = &mut x; //~ ERROR references in constants may only refer to immutable values
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0017]: references in constants may only refer to immutable values
2-
--> $DIR/issue-65394.rs:8:13
2+
--> $DIR/issue-65394.rs:5:13
33
|
44
LL | let r = &mut x;
55
| ^^^^^^ constants require immutable values
66

7-
[ERROR rustc_mir::transform::qualify_consts] old validator: [($DIR/issue-65394.rs:8:13: 8:19, "MutBorrow(Mut { allow_two_phase_borrow: false })")]
8-
[ERROR rustc_mir::transform::qualify_consts] new validator: [($DIR/issue-65394.rs:8:13: 8:19, "MutBorrow(Mut { allow_two_phase_borrow: false })"), ($DIR/issue-65394.rs:7:9: 7:14, "LiveDrop")]
7+
[ERROR rustc_mir::transform::qualify_consts] old validator: [($DIR/issue-65394.rs:5:13: 5:19, "MutBorrow(Mut { allow_two_phase_borrow: false })")]
8+
[ERROR rustc_mir::transform::qualify_consts] new validator: [($DIR/issue-65394.rs:5:13: 5:19, "MutBorrow(Mut { allow_two_phase_borrow: false })"), ($DIR/issue-65394.rs:4:9: 4:14, "LiveDrop")]
99
error: aborting due to previous error
1010

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ use std::fmt::Debug;
55
fn foo<T>(x: impl Debug) { }
66

77
fn main() {
8-
foo::<String>('a'); //~ ERROR cannot provide explicit type parameters
8+
foo::<String>('a'); //~ ERROR cannot provide explicit generic arguments
99
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
1+
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
22
--> $DIR/universal-issue-48703.rs:8:5
33
|
44
LL | foo::<String>('a');

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ struct TestEvent(i32);
1212
fn main() {
1313
let mut evt = EventHandler {};
1414
evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
15-
//~^ ERROR cannot provide explicit type parameters
15+
//~^ ERROR cannot provide explicit generic arguments
1616
});
1717
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
1+
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
22
--> $DIR/universal-turbofish-in-method-issue-50950.rs:14:9
33
|
44
LL | evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {

0 commit comments

Comments
 (0)