File tree 3 files changed +27
-29
lines changed
3 files changed +27
-29
lines changed Original file line number Diff line number Diff line change @@ -1071,26 +1071,25 @@ impl<'a> ExtCtxt<'a> {
1071
1071
) -> Result < PathBuf , DiagnosticBuilder < ' a > > {
1072
1072
let path = path. into ( ) ;
1073
1073
1074
+ if path. is_absolute ( ) {
1075
+ return Ok ( path) ;
1076
+ }
1074
1077
// Relative paths are resolved relative to the file in which they are found
1075
1078
// after macro expansion (that is, they are unhygienic).
1076
- if !path. is_absolute ( ) {
1077
- let callsite = span. source_callsite ( ) ;
1078
- let mut result = match self . source_map ( ) . span_to_unmapped_path ( callsite) {
1079
- FileName :: Real ( name) => name. into_local_path ( ) ,
1080
- FileName :: DocTest ( path, _) => path,
1081
- other => {
1082
- return Err ( self . struct_span_err (
1083
- span,
1084
- & format ! ( "cannot resolve relative path in non-file source `{}`" , other) ,
1085
- ) ) ;
1086
- }
1087
- } ;
1088
- result. pop ( ) ;
1089
- result. push ( path) ;
1090
- Ok ( result)
1091
- } else {
1092
- Ok ( path)
1093
- }
1079
+ let callsite = span. source_callsite ( ) ;
1080
+ let mut result = match self . source_map ( ) . span_to_unmapped_path ( callsite) {
1081
+ FileName :: Real ( name) => name. into_local_path ( ) ,
1082
+ FileName :: DocTest ( path, _) => path,
1083
+ other => {
1084
+ return Err ( self . struct_span_err (
1085
+ span,
1086
+ & format ! ( "cannot resolve relative path in non-file source `{}`" , other) ,
1087
+ ) ) ;
1088
+ }
1089
+ } ;
1090
+ result. pop ( ) ;
1091
+ result. push ( path) ;
1092
+ Ok ( result)
1094
1093
}
1095
1094
}
1096
1095
Original file line number Diff line number Diff line change @@ -263,10 +263,10 @@ impl<'a> ResolverExpand for Resolver<'a> {
263
263
// than by individual derives.
264
264
// - Derives in the container need to know whether one of them is a built-in `Copy`.
265
265
// FIXME: Try to avoid repeated resolutions for derives here and in expansion.
266
- let mut exts = Vec :: new ( ) ;
267
266
let mut helper_attrs = Vec :: new ( ) ;
268
- for path in derives {
269
- exts. push (
267
+ let exts = derives
268
+ . iter ( )
269
+ . map ( |path| {
270
270
match self . resolve_macro_path (
271
271
path,
272
272
Some ( MacroKind :: Derive ) ,
@@ -288,15 +288,15 @@ impl<'a> ResolverExpand for Resolver<'a> {
288
288
if ext. is_derive_copy {
289
289
self . containers_deriving_copy . insert ( invoc_id) ;
290
290
}
291
- ext
291
+ Ok ( ext)
292
292
}
293
293
Ok ( _) | Err ( Determinacy :: Determined ) => {
294
- self . dummy_ext ( MacroKind :: Derive )
294
+ Ok ( self . dummy_ext ( MacroKind :: Derive ) )
295
295
}
296
- Err ( Determinacy :: Undetermined ) => return Err ( Indeterminate ) ,
297
- } ,
298
- )
299
- }
296
+ Err ( Determinacy :: Undetermined ) => Err ( Indeterminate ) ,
297
+ }
298
+ } )
299
+ . collect :: < Result < Vec < _ > , _ > > ( ) ? ;
300
300
self . helper_attrs . insert ( invoc_id, helper_attrs) ;
301
301
return Ok ( InvocationRes :: DeriveContainer ( exts) ) ;
302
302
}
Original file line number Diff line number Diff line change @@ -347,13 +347,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
347
347
seg : & hir:: PathSegment < ' _ > ,
348
348
is_method_call : bool ,
349
349
) -> GenericArgCountResult {
350
- let empty_args = hir:: GenericArgs :: none ( ) ;
351
350
let suppress_mismatch = Self :: check_impl_trait ( tcx, seg, & def) ;
352
351
Self :: check_generic_arg_count (
353
352
tcx,
354
353
span,
355
354
def,
356
- if let Some ( ref args ) = seg. args { args } else { & empty_args } ,
355
+ seg. args . unwrap_or ( & hir :: GenericArgs :: none ( ) ) ,
357
356
if is_method_call { GenericArgPosition :: MethodCall } else { GenericArgPosition :: Value } ,
358
357
def. parent . is_none ( ) && def. has_self , // `has_self`
359
358
seg. infer_args || suppress_mismatch, // `infer_args`
You can’t perform that action at this time.
0 commit comments